Repository navigation
fix: emit room events that arrive right after a reconnect - #2186
Conversation
pendingReconnect stayed true until the reconnect attempt's promise settled, after the room was already Connected and had flushed its buffer, so events emitted in that window were buffered and never emitted. It now only covers a reconnect that is scheduled but not started.
🦋 Changeset detectedLatest commit: 2bc830c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Clear the field inside the timer callback and in clearReconnectTimeout instead of in the attempt's finally, so a cancelled timer no longer leaves pendingReconnect stuck and a finished attempt no longer clobbers the retry scheduled during it. Moves the tests to RTCEngine.
|
@ANDROIDHASSAN I think this makes sense to me, would you be able to rebase this on top of the latest |
…ter-reconnect # Conflicts: # src/room/RTCEngine.test.ts # src/room/RTCEngine.ts
|
Merged |
Fixes #2183
After a reconnect, the room sets itself
Connected, emitsReconnectedand flushes its event buffer. But the engine only clearedreconnectTimeoutin the.finally()of the scheduled attempt, which runs after that. Until thenengine.pendingReconnectis stilltrue, soemitWhenConnected()keeps buffering. Nothing flushes the buffer again until the next reconnect, andhandleSignalRestarted()clears it at that point, so those events are lost.reconnectTimeoutis now cleared when the timer fires (and inclearReconnectTimeout()), and the.finally()is gone, sopendingReconnectis just!!this.reconnectTimeoutand drops as soon as the attempt starts.Two related cases (thanks @1egoman) are covered by the same change:
handleBrowserOnLinecancelling the timer, and a failed attempt's retry handle being cleared by the old attempt's.finally().mainhas since fixed both on its own (the handle guard in the.finally()and the clear inclearReconnectTimeout()); after mergingmain, this PR keeps the clear inclearReconnectTimeout()and replaces the guarded.finally()with the clear in the timer callback.Tests in
RTCEngine.test.ts(pendingReconnect (#2183)):is cleared once the scheduled attempt starts— fails on currentmain, passes hereis cleared when the scheduled attempt is cancelled— passes on both (regression guard)keeps a retry scheduled while the previous attempt settles— passes on both (regression guard)main's ownkeeps pendingReconnect set while a retry is scheduled after a failed attemptstill passes. Fullvitest run src(61 files, 1075 passed, 1 skipped),pnpm lint(0 errors),tsc --noEmitandprettier --checkpass after the merge.