Skip to content

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

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

fix: wait for ReconnectResponse to arrive before declaring signal rec…#2082
lukasIO wants to merge 3 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

🦋 Changeset detected

Latest commit: ee78bc1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

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

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 111.2 KB (+0.07% 🔺)
dist/livekit-client.umd.js 120.36 KB (+0.06% 🔺)

@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