Skip to content

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

Open
lukasIO wants to merge 12 commits into
mainfrom
lukas/fix-data-stream-order
Open

fix: error on uncompressed datastreams when chunks are missing#2073
lukasIO wants to merge 12 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: 57aba77

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.04% 🔺)
dist/livekit-client.umd.js 119.66 KB (-0.09% 🔽)

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.

Comment thread src/room/data-stream/incoming/IncomingDataStreamManager.ts
Comment thread src/room/data-stream/incoming/IncomingDataStreamManager.ts
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.

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!)

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