Skip to content

fix(web): use a UUID participantId for session viewers (not useId)#27

Merged
ralyodio merged 1 commit into
masterfrom
fix/web-viewer-uuid-participant
Jun 23, 2026
Merged

fix(web): use a UUID participantId for session viewers (not useId)#27
ralyodio merged 1 commit into
masterfrom
fix/web-viewer-uuid-participant

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Bug

Opening a desktop join link on the web (/session/<id>) failed: Connection Failed — Invalid participant ID.

Web session viewers set participantId via React useId(), which returns opaque ids like :r0:. But /api/livekit/token (and the signal routes) validate participantId with z.string().uuid() — so the SFU viewer's id was rejected.

It "worked earlier" only because P2P viewers never hit the token route. The recent SFU host migration routes web viewers through SFUSessionVieweruseWebRTCSFU/api/livekit/token, which exposed the mismatch.

Fix

Generate a real, render-stable UUID instead of useId():

const [participantId] = useState(() => crypto.randomUUID());

Applied to both the P2P and SFU viewers (the signal routes validate uuid too). crypto.randomUUID is available in the browser (https / secure context) and on the SSR side (Node).

Tests

Capture the options each WebRTC hook receives and assert participantId matches the UUID format the routes require — for both the SFU and P2P viewer paths. 22/22 in the file pass; lint clean.

Web (apps/web) — deploys to Railway on merge.

🤖 Generated with Claude Code

Web session viewers set participantId via React useId(), which returns opaque
ids like ":r0:". /api/livekit/token (and the signal routes) validate
participantId with z.string().uuid(), so opening a desktop join link on the
web SFU path failed with "Invalid participant ID" / Connection Failed. (It
"worked earlier" only because P2P viewers never hit the token route; the SFU
host migration routed web viewers through it.)

Generate a real, render-stable UUID instead: useState(() => crypto.randomUUID()).
Applied to both the P2P and SFU viewers (signal routes validate uuid too).

Tests: assert each viewer is handed a UUID participantId.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio ralyodio merged commit e8e18b5 into master Jun 23, 2026
11 checks passed
@ralyodio ralyodio deleted the fix/web-viewer-uuid-participant branch June 23, 2026 09:41
@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