Skip to content

fix: wait for ReconnectResponse to arrive before declaring signal rec… - #2082

Open
lukasIO wants to merge 2 commits into
mainfrom
lukas/resume-on-reconnectresponse-only
Open

fix: wait for ReconnectResponse to arrive before declaring signal rec…#2082
lukasIO wants to merge 2 commits into
mainfrom
lukas/resume-on-reconnectresponse-only

Conversation

@lukasIO

@lukasIO lukasIO commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

…onnected

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f0387f6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 110.92 KB (+0.04% 🔺)
dist/livekit-client.umd.js 120.02 KB (-0.03% 🔽)

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread src/api/SignalClient.ts
Comment on lines +617 to +625
if (
this.lifecycleState === 'reconnecting' &&
parsed.message?.case !== 'reconnect' &&
parsed.message?.case !== 'leave'
) {
this.log.warn('dropping signal message while awaiting reconnect response', {
messageCase: parsed.message?.case,
});
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Reconnect discards valid room updates

When parsed.message precedes the reconnect response, the client discards participant, track, room, and token updates. Room state can remain stale after resume.

Prompt for agents
During SignalClient.connect reconnect handling in src/api/SignalClient.ts, messages received before ReconnectResponse are currently consumed from the ordered stream and discarded. These messages can be legitimate server updates and will never appear in startReadingLoop. Preserve them while waiting for ReconnectResponse, then process them through handleSignalResponse after the reconnect has been validated and the lifecycle transition succeeds. Keep Leave handling immediate and ensure buffered messages from an abandoned or superseded attempt are not delivered into a later session. Add coverage proving an update before ReconnectResponse reaches its callback exactly once and in order.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is also my main question reading this, do you want to replay these updates prior to the ReconnectResponse after the ReconnectResponse is received? I would think so but I might be missing something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the server guarantees the ordering now. Any relevant updates that happen in between should be replayed by the server.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - maybe it's worth adding a comment inline mentioning this? That's not necessarily initially intuitive behavior from the client end IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants