Skip to content

fix: error on uncompressed datastreams when chunks are missing - #2073

Merged
lukasIO merged 13 commits into
mainfrom
lukas/fix-data-stream-order
Aug 31, 2026
Merged

lukasIO merged 13 commits into
mainfrom
lukas/fix-data-stream-order

Conversation

@lukasIO

@lukasIO lukasIO commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

closes #2072

@changeset-bot

changeset-bot Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 93a9260

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

@lukasIO lukasIO changed the title fix: error on datastreams when chunks are missing fix: error on uncompressed datastreams when chunks are missing Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 110.62 KB (0%)
dist/livekit-client.umd.js 119.66 KB (0%)

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@1egoman 1egoman 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.

Generally looks good, I think before merging it would be good to get this also fixed for text streams and add test(s) to make sure that this doesn't regress.

@lukasIO If you'd like me to take this over let me know. I will also see if this is an issue in the rust implementation, and if so, open a PR fixing it over there.

devin-ai-integration[bot]

This comment was marked as resolved.

@lukasIO
lukasIO requested a review from 1egoman August 27, 2026 15:08

@1egoman 1egoman 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.

Looks good to me!

Comment on lines +1389 to +1399
);
manager.handleDataStreamPacket(chunkPacket(streamId, 0, textBytes, 0), Encryption_Type.NONE);
// Chunk-level `version` retcon is not supported: a reader that has already yielded chunk 0 to
// its consumer cannot retract it, so a resend at the same index is dropped like any other
// duplicate rather than superseding the original. See the note on
// `TextStreamReader.handleChunkReceived`.
manager.handleDataStreamPacket(
chunkPacket(streamId, 0, new TextEncoder().encode('goodbye world'), 1),
Encryption_Type.NONE,
);
manager.handleDataStreamPacket(trailerPacket(streamId), Encryption_Type.NONE);

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.

nitpick: It also might be good to add a test here which sends chunk version 1 and then 0. From our conversation on slack, this is now "first one wins", so assuming I have that right I think it would be good to test both permutations.

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.

good idea, added this within the same test

Comment on lines 493 to 497
lastChunkIndex = index;
if (value.content.length === 0) {
return;
}
controller.enqueue(value);

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.

(Just wanted to say explicitly that I think moving this to the send path instead of the receive path is probably the better place for this to live!)

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.

we can also add a guard on the send path, but the receive path has additional value in so far, that we'd account for older clients interop

@lukasIO
lukasIO merged commit 4a900ed into main Aug 31, 2026
5 of 6 checks passed
@lukasIO
lukasIO deleted the lukas/fix-data-stream-order branch August 31, 2026 08:23
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.

Uncompressed data streams silently accept missing and out-of-order chunks

2 participants