Skip to content

Fix data stream header length field#1845

Open
ladvoc wants to merge 1 commit intomainfrom
jacobgelman/bot-260-fix-data-stream-header-size-in-js
Open

Fix data stream header length field#1845
ladvoc wants to merge 1 commit intomainfrom
jacobgelman/bot-260-fix-data-stream-header-size-in-js

Conversation

@ladvoc
Copy link
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

changeset-bot bot commented Mar 19, 2026

⚠️ No Changeset found

Latest commit: 16cac5e

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
Contributor

github-actions bot commented Mar 19, 2026

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 86.78 KB (+0.03% 🔺)
dist/livekit-client.umd.js 97.34 KB (+0.01% 🔺)

Copy link
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 on lines +117 to +119
totalLength: info.size !== undefined
? numberToBigInt(info.size)
: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: FYI that numberToBigInt actually is resilient to undefined, so something like the below could be a little simpler:

Suggested change
totalLength: info.size !== undefined
? numberToBigInt(info.size)
: undefined,
totalLength: numberToBigInt(info.size),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My editor shows the typing as numberToBigInt<number>(value: number): bigint

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be because you have info.size in there - I bet if you removed it it would show the full un-narrowed generic value.

For reference, here is the actual function definition allowing both options:

export function numberToBigInt<T extends number | undefined>(
value: T,
): T extends number ? bigint : undefined {
return (value !== undefined ? BigInt(value) : undefined) as T extends number ? bigint : undefined;
}

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