Skip to content

fix: skip offer matching when connecting to old server versions - #2286

Open
lukasIO wants to merge 1 commit into
mainfrom
lukas/fix-old-server-compat
Open

lukasIO wants to merge 1 commit into
mainfrom
lukas/fix-old-server-compat

Conversation

@lukasIO

@lukasIO lukasIO commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #2185

@changeset-bot

changeset-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d0ddddd

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

@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 on lines +293 to +294
// offerId is 0 by default when connecting to older server versions
if (offerId === 0 || offerId > checkpoint) {

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.

🟡 Premature completion of queued legacy negotiations

On legacy servers, onAnswered resolves a new publish request when an older, pending offer receives its unnumbered answer. applyRemoteDescription emits OfferAnswered before sending the queued negotiation containing the new track. Publishing returns early and clears its timeout before the required answer arrives.

Learn more

A publisher offer can already be pending when another track needs negotiation. In that case, createAndSendOffer queues a follow-up using renegotiate. When the older answer arrives, applyRemoteDescription emits OfferAnswered before starting that follow-up. Accepting every zero-ID answer resolves callers whose changes were absent from the answered offer. The caller then clears its deadline, so a missing follow-up answer no longer triggers that caller's negotiation timeout. publish can finish creating and announcing the publication before the follow-up succeeds.

Example: Offer 5 is awaiting its answer when Alice adds a camera track and requests negotiation. The legacy server answers offer 5 with ID 0. The camera publish request resolves, although only the subsequent offer 6 includes the camera.

Recommended fix: Associate unnumbered answers with the outstanding local offer generation and preserve the checkpoint comparison. Capture that generation before applying the answer or starting queued renegotiation. Add regression coverage for a zero-ID answer to an offer at the checkpoint, followed by the zero-ID answer to the required follow-up offer.

Devin Review


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

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 118.36 KB (-0.01% 🔽)
dist/livekit-client.umd.js 127.87 KB (-0.01% 🔽)
dist/core/core.mjs 79.88 KB (+0.13% 🔺)

This branch has not been deployed

No deployments
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.

[react-native] Negotiation watchdog false-positives: OfferAnswered never fires → 'negotiation timed out' → reconnect loop

1 participant