Skip to content

Properly handle max payload length of zero - #1966

Merged
1egoman merged 3 commits into
mainfrom
max-payload-length-zero
Jun 9, 2026
Merged

1egoman merged 3 commits into
mainfrom
max-payload-length-zero

Conversation

@1egoman

@1egoman 1egoman commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

As a follow up to #1962, I realized there were a few small discrepancies with the swift and rust versions.

  • Both have a min(maxMessageSize, 64_000) check rather than using the maxMessageSize value verbatim.
  • Both (per RFC 8841) assume that 0 is a special value that means "no limit", the web implementation didn't do this
  • Both log if the data channel gets closed before the connection is gracefully cleaned up.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 100.49 KB (+0.1% 🔺)
dist/livekit-client.umd.js 109.57 KB (+0.13% 🔺)

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 87845eb

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

Comment thread src/room/RTCEngine.ts
// than LiveKit/pion can deliver end-to-end (~64 KiB), so we trust
// the answer up untilthe built in ceiling.
const maxPublisherMessageSizeBytes = Math.min(
this.pcManager?.getMaxPublisherMessageSize() ?? DEFAULT_MAX_MESSAGE_SIZE,

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.

Realized a bit late that the react-native-webrt. didn't fill out the sctp field so the previous PR didn't actually work for it. Adding the default now covers react-native nicely 👍

Comment thread src/room/RTCEngine.ts
);
if (
typeof maxPublisherMessageSizeBytes !== 'undefined' &&
maxPublisherMessageSizeBytes !== 0 /* 0 means "no limit" */ &&

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.

can maxPublisherMessageSizeBytes be 0 at all ? I think it is protected to be min(DEFAULT_MAX_MESSAGE_SIZE)

@1egoman 1egoman Jun 9, 2026

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.

Yep, it can be zero - the expression 0 ?? n will always be zero (more info, this is actually an important key difference between ?? and ||), so min(0 ?? n, n) where n > 0 will also always be 0.

@1egoman
1egoman merged commit 7dcfdc4 into main Jun 9, 2026
7 checks passed
@1egoman
1egoman deleted the max-payload-length-zero branch June 9, 2026 14:44
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.

4 participants