Skip to content

fix(desktop): guard startHosting re-entry so screen share survives reconnect#25

Merged
ralyodio merged 1 commit into
masterfrom
fix/host-connect-storm
Jun 23, 2026
Merged

fix(desktop): guard startHosting re-entry so screen share survives reconnect#25
ralyodio merged 1 commit into
masterfrom
fix/host-connect-storm

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Problem (regression from 0.8.3)

After the connect retried, the host saw camera + black presentation — the screen share didn't survive. SFU logs showed a connection storm: the same identity publishing SCREEN_SHARE on multiple participant IDs with a flurry of DUPLICATE_IDENTITY / CLIENT_REQUEST_LEAVE.

Cause: the auto-start-hosting effect re-fires startHosting whenever isHosting is false — which it stays through the 0.8.3 connect retries. With no re-entrancy guard, overlapping startHosting calls each built their own Room and connect/disconnected on top of each other. The screen share got published on a connection that was then torn down → black.

Fix

  • startHosting bails if a start is already in-flight (startingRef) or a room already exists (roomRef).
  • On failure it tears down roomRef so the next attempt is clean and sequential.
  • A terminal Disconnected releases roomRef so re-hosting still works after a real drop.

Net: one connection at a time, so the screen share publishes once on the stable connection and stays up — the retry/reconnect no longer disturbs the session.

Tests (7/7)

Added: concurrent startHosting builds only one connection; re-host works after a terminal disconnect. Existing retry/reconnect cases unchanged. Full monorepo lint passes.

Ships in the Electron app (desktop release).

🤖 Generated with Claude Code

…connect

The 0.8.3 connect-retry collided with the auto-start-hosting effect, which
re-fires startHosting whenever isHosting is false — which it stays through
the retries. With no re-entrancy guard, overlapping startHosting calls each
built their own Room and connect/disconnected on top of each other (a
DUPLICATE_IDENTITY / CLIENT_REQUEST_LEAVE storm in the SFU logs). The screen
share got published on a connection that was then torn down, so the host saw
camera + black presentation.

- startHosting now bails if a start is already in-flight or a room exists.
- On failure it tears down roomRef so the next (sequential) attempt is clean.
- A terminal Disconnected releases roomRef so re-hosting still works.

Tests: concurrent start builds one connection; re-host works after a terminal
disconnect; existing retry/reconnect cases still pass (7/7).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio ralyodio merged commit 28b888f into master Jun 23, 2026
1 check passed
@ralyodio ralyodio deleted the fix/host-connect-storm branch June 23, 2026 08:13
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

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