Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix 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
- Loading branch information