Skip to content

Conversation

@brainbicycle
Copy link

@brainbicycle brainbicycle commented Dec 5, 2025

Summary:

If a subclass of RCTEventEmitter outlives the bridge and the bridge is invalidated, the invalidate method is called on RCTEventEmitter which calls stopObserving but does not change the listenerCount. Once the bridge is recreated and a listener added to the RCTEventEmitter if the listenerCount is > 1 startListening is never called:

This just resets the listenerCount to prevent this.

Probably not a good idea to have modules that outlive bridge in first place but this seems like unwanted behavior in any case :).

Changelog:

[iOS] [Fixed] - fix listenerCount not resetting for RCTEventEmitter

Test Plan:

I tested this code via a patch in the artsy/eigen app repo: artsy/eigen#13068
The app was using a native module that posts events over the bridge to handle push notifications.

Behavior before:

  1. Start app listeners added to ARNotificationManager module, startListener called listenerCount = 2
  2. Force a dev reload invalidating the bridge
  3. Invalidate called on bridge and the native module causing stopObserving to be called but listenerCount remains 2
  4. Bridge refreshes listeners added again but startObserving never called

Behavior after:

  1. Start app listeners added to ARNotificationManager module, startListener called listenerCount = 2
  2. Force a dev reload invalidating the bridge
  3. Invalidate called on bridge and the native module causing stopObserving to be called but listenerCount reset to 0
  4. Bridge refreshes listeners added again listeners added again, startObserving called after first

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 5, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants