Skip to content

Fix data stream header length field#1845

Merged
ladvoc merged 2 commits intomainfrom
jacobgelman/bot-260-fix-data-stream-header-size-in-js
Mar 23, 2026
Merged

Fix data stream header length field#1845
ladvoc merged 2 commits intomainfrom
jacobgelman/bot-260-fix-data-stream-header-size-in-js

Conversation

@ladvoc
Copy link
Copy Markdown
Contributor

@ladvoc ladvoc commented Mar 19, 2026

Addresses an issue where the stream header specifies zero instead of undefined for non-finite streams, causing remote clients that validate stream length to be unable to read the stream. According to the doc comment for the totalLength field in the Protobuf definition, it is “only populated for finite streams, if it's a stream of unknown size this stays empty.”

@ladvoc ladvoc requested review from 1egoman and lukasIO March 19, 2026 20:26
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 19, 2026

⚠️ No Changeset found

Latest commit: f4a9bd0

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

@ladvoc ladvoc force-pushed the jacobgelman/bot-260-fix-data-stream-header-size-in-js branch from 044bb99 to 16cac5e Compare March 19, 2026 20:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 86.76 KB (-0.01% 🔽)
dist/livekit-client.umd.js 97.31 KB (-0.03% 🔽)

Copy link
Copy Markdown
Contributor

@1egoman 1egoman left a comment

Choose a reason for hiding this comment

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

Generally makes sense to me, I would like @lukasIO to give the final ✅ since he originally wrote this code and is more familiar with the edge cases in data streams than I am.

You should be able to fix the ci error by running pnpm format locally and committing the results.

Also, if you could add a changeset that would be appreciated!

Comment thread src/room/data-stream/outgoing/OutgoingDataStreamManager.ts Outdated
Copy link
Copy Markdown
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

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

Agree with @1egoman 's comment about the numberToBigInt simplification. This util function has been written exactly for these use cases and to allow undefined values to pass through as undefined. If it doesn't work, then that's a bug in the function.

You're totally right that the protocol says that this is unset only for non-finite streams.
I think we'll be on the safer side if we interpret 0 length as non-finite additionally. I'm not sure I can think about a use case with a 0 size length.

@ladvoc ladvoc merged commit 93b49d2 into main Mar 23, 2026
6 checks passed
@ladvoc ladvoc deleted the jacobgelman/bot-260-fix-data-stream-header-size-in-js branch March 23, 2026 16:20
ladvoc added a commit that referenced this pull request Mar 23, 2026
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.

3 participants