Repository navigation
Stop draining pending events for types with no listeners - #782
Merged
Merged
Conversation
takePendingEvents consumes the events natively, so asking for a type with nothing to deliver them to throws them away. removeAllListeners left an empty array behind and removeListener left one when the last listener went, so dispatchEvents kept asking for those types and the events were lost silently. Both now drop the entry, and dispatchEvents skips an empty one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
crow
approved these changes
Oct 21, 2026
khmMouna
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Remove an event type from the listener map once its last listener goes, and
skip any type with no listeners when draining.
Why are these changes necessary?
takePendingEventsconsumes the events on the native side, so asking for atype that has nowhere to deliver them throws them away.
removeAllListenersleft an empty array behind, and
removeListenerleft one when the lastlistener was removed, so
dispatchEventskept asking for those types and theevents were lost with nothing reporting it.
An app that adds a listener, removes it, and later adds one again loses every
event that arrived in between.
How did you verify these changes?
Compiled this version and the one on main, stubbed
react-native, and ran bothagainst a mock native module:
removeAllListeners('push'):takePendingEvents('push')is stillcalled, so native hands the events over and they are dropped. Same when the
last listener is removed individually.
registered receives all of its events.
🤖 Generated with Claude Code