The gateway only publishes `connected` once the directory snapshot lands in
`sendInitialState()`. Between authenticating and that point the session is in
`syncing` while `hasConnectedOnce` is still false. `onDisconnect` required both
`hasConnectedOnce` and `state === "connected"`, so a transport drop inside that
gap returned early and did nothing:
* no `disconnected` frame for the browser,
* no `scheduleReconnect`,
* no peer/WeRTC rollback, no teardown.
The session stayed in `syncing` with the browser socket still open, the client
kept showing the connecting state forever, and nothing could recover it short
of the user closing the tab. `onKick` had the same gap via its own
`if (!hasConnectedOnce) return;` guard, so a kick or ban during the same window
was silently ignored while the gateway kept the dead session alive.
The window is not momentary. `tsClient.connect()` resolves even when the
directory reconciliation fails (the failure is logged and the explicit snapshot
emit is skipped), and `resetDirectoryForReconnect()` clears the snapshot on
every recovery, so each reconnect attempt opens the window again.
Treat the settling states (`authenticating`, `syncing`) as an explicit concept
and handle transport loss there:
* a drop during the first connect is a connect failure, not an interruption:
report `connectionFailed`, close with 4003 and tear the session down;
* the same reporting is now shared by the rejected-`connect()` path through a
single `failConnect` helper, so a transport that reports itself twice (a
`disconnected` event plus a rejected connect) still fails exactly once;
* a drop during a *reconnect* handshake returns the session to `reconnecting`
and schedules another attempt instead of stalling in `syncing`;
* a kick that lands before the session settles is reported and terminal.
A drop on an established session keeps the previous behaviour: `disconnected`
plus a scheduled reconnect.
Covered by three regression tests over the real WebSocket wiring with only the
external SDK stubbed: a drop before the directory sync, a kick in the same
window, and a drop during a reconnect handshake. All three hang on the old code.
An acceleration tunnel can tear itself down on its own: a socket error, a relay
OPEN_ERR/CLOSE frame, or an open timeout runs closeSockets(), which closes both
UDP sockets and leaves every later sendFrame() a silent no-op.
TSClient kept the adapter bound to that tunnel's now-dead local port and only
rebuilt the transport when adapter or client were null. An auto-reconnect
therefore dialed a port nobody reads, and because a closed tunnel reports
nothing, the session could never recover and never surfaced an error either.
- expose isClosed() on AccelerationRelayClient so callers can distinguish a live
tunnel from one that tore itself down
- drop a stale tunnel together with its adapter and SDK client before connect()
decides whether to rebuild the transport, detaching first so a late
"disconnected" from the retired client cannot re-enter the reconnect path
- cover the reconnect guard with regression tests in ts-client.test.ts
Verified: tsc clean; ts-client.test.ts 35/35 pass (incl. the two new guards).
The relay's socket error listener ended with `throw error`. A listener that throws
escapes EventEmitter.emit, so it became an uncaught exception that terminated the
whole process. Because the throw also aborts the remaining listeners, it prevented
the startup promise from ever settling when the socket failed to bind.
- extract an idempotent shutdown() used by both close() and error handling
- reject the startup promise when the failure happens before listening, so a failed
bind behaves like any other rejected startup rather than a process crash
- tear the relay down and report via a new onError callback once it is running
- release the socket and sweep interval on a synchronous bind failure, which never
emits error at all
- add 3 regression tests covering bind failure, a surviving relay after a failed
sibling startup, and idempotent close
- register the new test file in the npm test list so CI actually runs it
Verified: tsc --noEmit is clean and the 3 new tests pass. Before the fix the same
bind failure terminated the process with an uncaught EADDRINUSE instead of
rejecting the startup promise.
setCodecPreferences requires codecs from RTCRtpSender.getCapabilities;
feeding it RTCRtpReceiver.getCapabilities throws InvalidModificationError
in Chrome and the swallowed exception left VP8 as the negotiated codec.
Switch the capability source so H264/AV1 preferences actually apply.
Add a bitrate select to the screen share settings dialog (auto by
resolution, or a fixed 1.5/3/5/8/12 Mbps cap), persist the choice in
localStorage, and pass it through ScreenShareOutputSettings.maxBitrate
so configureScreenShareVideoSender applies the user-chosen budget
instead of only the height-scaled default.