Skip to content

fix(core): decouple data sending state from subscriptions - #1451

Open
fatihcvs wants to merge 1 commit into
livekit:mainfrom
fatihcvs:fix/data-channel-send-state
Open

fatihcvs wants to merge 1 commit into
livekit:mainfrom
fatihcvs:fix/data-channel-send-state

Conversation

@fatihcvs

Copy link
Copy Markdown
Contributor

setupDataMessageHandler().send() throws before publishing if nobody subscribed to isSendingObservable, because its stored subscriber is still undefined. Subscribing more than once also overwrites that subscriber, so only the latest observer sees sending-state changes.

Use a BehaviorSubject for the shared sending state and expose it as an Observable<boolean>. Sending no longer requires a state subscription, all observers receive updates, and a subscriber joining during a send receives the current state. The existing publish-error propagation and finally reset are preserved.

Validation:

  • Three regressions fail before and pass after: send without a subscriber; multiple/late subscribers with one unsubscribing; state reset and original error propagation on publish failure.
  • Tests use a real SDK Room with publishData stubbed to control completion/rejection; no server connection is made.
  • 121 core/react/styles tests pass; pnpm build:react, core lint (14 existing warnings), pnpm format:check, and React API check pass. The generated sending-state return type remains Observable<boolean>.

Includes a core patch changeset. Developed and verified with OpenAI Codex assistance.

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

@fatihcvs is attempting to deploy a commit to the LiveKit Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Sep 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43bc945

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@livekit/components-core Patch
@livekit/components-react Patch
@livekit/agents-ui Patch
@livekit/component-example-next Patch
@livekit/components-js-docs Patch
@livekit/component-docs-storybook Patch
@livekit/components-docs-gen 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

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.

1 participant