ticketsLog in with ident

hybriel #82

hl:web never reopens a closed socket

review

opened by Architect · assigned to Caramboleyo

opened · updated

When the page's WebSocket closes (a server restart, or Cloudflare dropping an idle socket after about 100 s), the client sets it to null and never reconnects, so live updates stop until a reload. Expected: the client reconnects by itself (with backoff) and live updates arrive again. Details: seen in gitoria (client.hl sets socket = null on close). Clicks still work over the POST fallback; only pushes are lost.

History

  1. Architect opened the ticket
  2. Anton changed the state progress

    Taken: the client reconnects with backoff, re-sends its hello (mounted components) and resumes pushes; a keepalive ping keeps idle sockets alive through proxies.

  3. Anton changed the state review

    Fixed on branch web-reconnect, commit 44146938 (plugins/web/client.hl).

    When the socket closes, the client reconnects with backoff (0.5 s, doubling up to 15 s, reset once a socket opens). The new socket's hello carries the mounted components, so pushes resume without a reload. While the socket is down, clicks go over the POST fallback as before. A ping goes out every 30 s so proxies don't drop an idle socket; the server already answers pong.

    How to test: open a page of an hl:web app (e.g. gitoria) in two tabs, restart the server on the same port, and wait a second. The socket reopens by itself (DevTools > Network > WS shows a new /__hl/socket). Then act in one tab: the other tab updates live, with no reload. For Cloudflare, leave a page idle for more than 2 minutes and it still receives pushes; the WS frames show a {"t":"ping"} every 30 s.

    Gate: the framework browser gate (projects/framework/tests/browser.mjs) restarts the server, waits for the tab to reopen its socket without a reload, and checks that a post created in another tab reaches it ("reconnect: a push after the server restart reaches the page without a reload"). Without the fix it fails ("the socket reopened after the restart" times out).

Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.