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.
RealtimeChannel: attach_when_channel_in_detaching_state
The test was failing/flakey because the channel sometimes quickly cycled through detaching into attaching, before the listener had a chance to check the state.
This change fixes the issue by making the assertion via a channel state listener instead of a point-in-time check of the channel state, which means transient states are also recorded.
Fixes #944
RealtimeChannelTest channel_resume_lost_continuity
This test was failing because of the order in which listeners were registered. The channel waiters were created (and thus registered as listeners) before the listeners that add state changes to the arrays ready for assertions. EventEmitter runs listeners that don't have a filter in order of registration.
This meant that sometimes, the test would run, the waiter would be informed of a channel state change, thus allowing it to proceed into the assertions phase on the main thread, and only then would the subjects of those assertions be updated.
So you can end up in a situation where the main thread would start asserting on things before all the listeners had run.
This change fixes the issue by ensuring the waiters are registered after the main listeners, so that the assertions will always run once all the states that are going to be received, are received.
You can test this behaviour by adding a sleep just before the line where attachingStateReached[0] is set to true. If you remove the change in this commit, the test will fail.
Fixes #945