Repository navigation
Description
Version
1.62.1
Steps to reproduce
Repro package with committed per-trial records:
https://github.com/jaynirmal15/webrtc-recovery-harness/tree/main/setoffline-repro
node setoffline-repro/run.mjs --engine chromium --path host --trials 3
node setoffline-repro/run.mjs --engine firefox --path host --trials 3
node setoffline-repro/summarize.mjs
Each trial opens a WebSocket, lets it reach OPEN, then calls
browserContext.setOffline(true) on the receiving context for 30 seconds while
measuring five traffic types simultaneously: fetch, XMLHttpRequest, the
already-open WebSocket, a WebSocket created after the transition, and the RTP
of an established RTCPeerConnection. Signalling is non-trickle and
Node-mediated, so no signalling socket can be mistaken for a measurement target.
Expected behavior
Per the note merged in #42624, offline emulation affects "page navigations,
fetch(), XMLHttpRequest and WebSockets". An already-open WebSocket should
therefore stop carrying traffic in both engines while the context is offline.
Actual behavior
The engines diverge, and neither matches the note.
Firefox 153.0 — the already-open socket is unaffected. It keeps delivering at
its normal rate for the entire offline window: 29-30 of the messages arrive
in-window, 1 afterwards.
Chromium 151.0.7922.34 — delivery is deferred, not failed. 0-1 messages arrive
during the 30s window; 30 then arrive together within one second of going back
online. The socket fires no close and no error, and readyState stays OPEN
throughout. Nothing is lost.
A WebSocket created while offline fails in both engines, as documented.
12 trials, four cells of three: {Chromium, Firefox} x {host candidates, TURN
relay}. All trials within each cell agreed on every categorical outcome.
| Cell | n | fetch | XHR | WebSocket (already open) | WebSocket (new) |
|---|---|---|---|---|---|
| Chromium / host | 3 | failed (4-5 ms) | failed (2-3 ms) | no close - 0-1 in-window - 30 within 1s of online - 45 total | failed |
| Chromium / relay | 3 | failed (3-4 ms) | failed (2-3 ms) | no close - 0-1 in-window - 30 within 1s of online - 60 total | failed |
| Firefox / host | 3 | failed (5-24 ms) | failed (4-24 ms) | no close - 29-30 in-window - 1 after - 45 total | failed |
| Firefox / relay | 3 | failed (4-5 ms) | failed (3-5 ms) | no close - 29 in-window - 1 after - 60 total | failed |
Consequence: setOffline cannot be used to test WebSocket message loss on an
established connection. In Chromium it produces delayed delivery with nothing
lost, and an application watching close or readyState observes nothing at all.
In Firefox it has no effect.
Additional context
Additional context
Follow-up to #42623, which I filed and which was closed by the documentation
note merged in #42624. That note groups WebSockets with fetch and XHR and does
not distinguish a socket already open at the transition from one created after
it. Those turn out to be different cases, so this issue measures them
separately.
The harness is instrumented to prove it can see an interruption, so the
unchanged Firefox result is a controlled null rather than a test that silently
did nothing. On the relay arm, after the offline window and on the same
connection, coturn is suspended with SIGSTOP:
| Cell | n | inbound while suspended | outbound (sender unaware) | burst on first sample after SIGCONT | ICE during |
|---|---|---|---|---|---|
| Chromium / relay | 3 | 0 B | +36450 B | +15633 B | connected -> disconnected |
| Firefox / relay | 3 | 0 B | +72611-72933 B | +35903-37835 B | connected -> disconnected |
The same instrument that recorded "no change" under setOffline records a clean
interruption under SIGSTOP, in the same trial.
The WebRTC half of the note is confirmed, not disputed: RTP continued
throughout the offline window in both engines and in both directions, and
neither connectionState nor iceConnectionState nor RTCIceTransport.state
reported any change while offline. Only the WebSocket clause is at issue here.
One older data point, offered as context and not as a claim about this API: in
#3393 (2020) a maintainer noted that CDP-based throttling "does not work
ideally in Chromium either since webrtc and websockets are not throttled".
That comment is about throttling and mentions neither setOffline nor UDP.
What would resolve this, either way: Firefox-side offline emulation covering
established WebSockets, or the note distinguishing new sockets from established
ones and stating that the Chromium behaviour is deferral rather than failure.
Environment
- Operating System: macOS 15.7.9 (Darwin 24.6.0, x64)
- Node.js version: v24.10.0
- Browser: Chromium 151.0.7922.34, Firefox 153.0
- Other: coturn 4.7.0 (relay arm only)
Activity
microsoft-playwright-automation commentedon Nov 11, 2026
microsoft-playwright-automation commentedon Nov 11, 2026
Hi, I'm the Playwright bot and I reproduced this.
Confirmed on tip-of-tree (
1.66.0-next,3b438229c6a2ccdbe2d3572755935892203d83c3) on macOS. Chromium deferred incoming messages until the context went back online; Firefox continued delivering them while offline. Neither closed the established socket. The note added in #42624 does not distinguish new connections from established connections.The proposed documentation correction makes that distinction in both the API reference and the emulation guide, and warns that offline emulation is not a reliable way to test WebSocket message loss or connection closure. It does not change browser behavior.
What I ran
I adapted the existing disabled
WS-012 should turn off when offlinetest to use the standard server fixture. The test received a baseline message, set the context offline, sent five messages 200 ms apart, tried a new connection, then went back online.These results matched in headless mode from a blank page and headed mode from a page served by the test server. The assertion that no messages arrive while offline failed in Firefox and WebKit in both runs.
Commands:
Build and all lint/type/documentation checks passed. The reported
1.62.1release and the WebRTC/TURN scenario were not retested; the WebSocket discrepancy is still present on current main.Condensed reproduction using the test fixtures
Draft PR: #44058
Triaged on macOS by the Playwright bot - agent run