Skip to content

fix: settle pending data track sends when the Room disconnects - #87

Merged
luisrivas merged 1 commit into
mainfrom
VBLOCKS-7580-send-settles-on-disconnect
Nov 13, 2026
Merged

luisrivas merged 1 commit into
mainfrom
VBLOCKS-7580-send-settles-on-disconnect

Conversation

@luisrivas

Copy link
Copy Markdown
Collaborator

Pull Request Details

Description

A LocalDataTrack.send() pending when the Room disconnects now resolves with ok: false without waiting for room.dispose(). A send after the disconnect resolves with ok: false at once instead of reporting success.

Public API changes

None to the types. send() now resolves with ok: false after the track's last Room disconnects.

Burndown

Before review

  • Updated CHANGELOG.md under the unreleased heading if the change is user-visible
  • Added or updated unit tests
  • Updated affected documentation
  • Verified locally with npm run lint and npm test
  • Manually sanity tested against a real Room
  • Ready for review

@charliesantos charliesantos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix looks right; one ordering issue on the disconnect settle path, inline.

Comment thread lib/room.ts
// End every frames() iterator and settle pending data track sends
// before surfacing the event, so neither hangs on a dead Room.
this._tracks.releaseAllRemoteTracks();
this._releaseDataTracks('Room disconnected before the send completed');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Settling inline here can drop a send result already queued on the track's AsyncContext (the two queues are unordered), so a delivered message resolves ok: false. Dispatch the settle through the track's asyncContext_ so queued results drain first.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! The settle is now dispatched on the track's AsyncContext, so queued results drain first. This also fixes the same race in room.dispose()

A LocalDataTrack.send() pending when the Room emits disconnected now
resolves with ok: false without waiting for room.dispose(), and a send
made afterwards resolves with ok: false at once instead of reporting
success.
@luisrivas
luisrivas force-pushed the VBLOCKS-7580-send-settles-on-disconnect branch from cf8f624 to 205970f Compare November 12, 2026 22:38
@luisrivas
luisrivas merged commit cd01171 into main Nov 13, 2026
13 checks passed
@luisrivas
luisrivas deleted the VBLOCKS-7580-send-settles-on-disconnect branch November 13, 2026 15:13
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