Skip to content

Unhandled promise rejection with raw DOM Event on post-connect WebSocket errorΒ #2062

Description

@lebaudantoine

Describe the bug

When the signal WebSocket errors after connection (common in Firefox on network drops/reloads), an unhandled promise rejection leaking a raw DOM Event escapes the SDK.

Root cause:

  1. WebSocketStream.ts: ws.onerror errors the controller with the raw Event (controller.error(e)).
  2. SignalClient.ts: handleSignalConnected() triggers startReadingLoop() fire-and-forget without a .catch().
  3. startReadingLoop lacks a try/catch around signalReader.read(), causing the stream rejection to leak.

Side note: Clean closes never call controller.close(), causing read() to hang indefinitely.

Impact

Error trackers (Sentry, PostHog) capture stackless, contentless exceptions ("Event captured as exception with keys: isTrusted"). This is a top production error (~78% Firefox) during reconnects.

Reproduction

  1. Connect to a room in Firefox.
  2. Drop connectivity or reload the page.
  3. Observe unhandledrejection with reason instanceof Event === true.

Expected behavior

Post-connect WebSocket errors should normalize to a ConnectionError and route to handleWSError/handleOnClose without unhandled rejections.

Environment

Reproduction

See the bug description.

Logs

System Info

See the bug description.

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions