Repository navigation
Description
Description
With the default @Push transport (WEBSOCKET_XHR), the client does not show that the server connection is lost unless the browser fires an offline event or a UIDL request fails. If the network drops silently (packets are lost and the TCP connection is not reset, as with Wi-Fi loss on a phone or laptop), nothing detects the loss: server push updates just stop, and the UI looks connected. How fast the user sees "Connection lost" depends on how quickly the browser fires offline. That is almost immediate in Chrome on desktop and noticeably delayed or missing in Safari.
Observed behavior
Measured with Playwright (Chromium and WebKit), Vaadin 25.3.1, @Push with default settings, and a TCP proxy between browser and server:
- Connection reset (proxy closes the sockets), no
offlineevent: Atmosphere logsWebsocket closed … wasClean: falseand firesonReconnectevery 5 s, butconnectionStatestaysconnectedand no indicator is shown.DefaultConnectionStateHandler.pushReconnectPendingonly reacts whenpushConnection.isBidirectional(), which is false forWEBSOCKET_XHR. That branch is meant for long polling behind a proxy, but it also catches websocket push with XHR to the server. - Silent drop (proxy swallows packets), no
offlineevent, 3 minutes:connectionStatenever leavesconnectedin either browser. The websocket never closes and no heartbeat is sent (default interval 300 s). Push updates stop for good: after the network is back, the half-open websocket is never replaced, so server changes only arrive piggybacked on the next XHR response. - Neither the UIDL XHR nor the heartbeat XHR has a timeout. A request sent over a dead (reused keep-alive) connection can hang indefinitely, which is what Flow client never recovers if a UIDL request hangs during a network outage (Safari / WebKit) #26261 covers for the UIDL request.
Expected behavior
- Losing the websocket of a
WEBSOCKET_XHRpush connection is reported like it is forWEBSOCKET: the indicator shows reconnecting, and a heartbeat verifies the connection. - A silent network drop is detected within a reasonable time without relying on the browser's
offlineevent. After recovery the push connection is re-established, so server push resumes without user interaction.
Steps to reproduce
- Failing unit test on branch
fix/report-lost-websocket-xhr-push(DefaultConnectionStateHandlerTests, "reconnects a pending websocket push reconnect when messages are sent over xhr"). - End-to-end: the project attached to Flow client never recovers if a UIDL request hangs during a network outage (Safari / WebKit) #26261 (
@Push,@PWA(offline = true)) with a server push every 2 s. Drop the network through theBlackholeProxywithout firingoffline/online, then observewindow.Vaadin.connectionState.state.
Versions
Flow main / 25.3.2. The handling of non-bidirectional push is the same as in the earlier GWT client.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fields✅ Closed
- StatusShow more project fieldsDone
Activity
totally-not-ai commentedon Oct 9, 2026
Triage
Valid bug. It has two separate parts. The first has a small, contained fix. The second needs a design decision.
1. A lost websocket is ignored for
WEBSOCKET_XHRAtmospherePushConnection.onReconnect()callsDefaultConnectionStateHandler.pushReconnectPending(). That method only entersRECONNECTINGwhenpushConnection.isBidirectional()is true. ForWEBSOCKET_XHR,isBidirectional()returnsfalsebecauseisAlwaysXhrToServer()is set. The connection then falls into theelsebranch, which is a no-op written for "long polling behind a proxy". The decision really depends on the transport (does Atmosphere tell us when the connection comes back?), not on the client-to-server direction.Proposed fix: base the check on the transport, for example
pushConnection.getTransportType() === 'websocket'(or a newPushConnectionmethod that says the transport reports reconnects). The failing test onfix/report-lost-websocket-xhr-pushcovers this. Points to check while doing it:pushOk()ends the active request on a push reconnect. WithWEBSOCKET_XHR, that request is an XHR that may still be in flight, so it must not be ended there. It should probably only happen when the transport is bidirectional.PUSHhas higher priority thanXHRinReconnectStateMachine. While push is the reconnect cause, a failed UIDL XHR is not retried on its own. AfterpushOk()the pending invocations have to be resent over XHR, assendInvocationsToServer()already does for the bidirectional case.2. A silent drop (half-open TCP) is never detected
Nothing in the stack sends a liveness probe often enough to notice this:
timeout: -1and no Atmosphere heartbeat. The server does not registerAtmosphereHeartbeatInterceptor, so a half-open websocket stays "open" forever and is never replaced after recovery.Options:
heartbeatconfig). The Atmosphere client closes and reopens the socket when heartbeats stop arriving. After part 1 is fixed, that close is reported as reconnecting. This fixes push recovery with no new Flow logic, but adds periodic server traffic for every push UI, so the interval needs a config option.Recommendation: fix part 1 on its own first, since it is a small and testable change in
DefaultConnectionStateHandler. Settle part 2 separately because it changes defaults and network traffic. A maintainer should choose between A and C.fix(flow-client): show reconnecting when a websocket-xhr push is lost
vaadin-bot commentedon Nov 6, 2026
This ticket/PR has been released with Vaadin 25.4.0-alpha5.
fix(flow-client): show reconnecting when a websocket-xhr push is lost (…