Test the WebSocket reconnect backoff - #138
Conversation
Co-authored-by: Radhey Kalra <radheykalra901@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| websocketStore.connect(true); | ||
| for (let attempt = 0; attempt < 8; attempt++) { | ||
| FakeSocket.instances.at(-1)?.onclose?.({ code: 1006 }); | ||
| scheduled.shift()?.(); | ||
| } |
There was a problem hiding this comment.
Retries never open new sockets The test starts with
connect(true), but each recorded retry calls connect() without that flag. With no access token set, the retry returns before opening a socket. The loop then closes the original fake socket again, so the expected delays can pass without a successful reconnect. The open-and-reset test also opens that stale socket. Set up authentication or preserve the connection mode, and assert that each retry creates a new socket.
Knowledge Base Used: Frontend data and real-time state
|
|
||
| test('delays double on each failed attempt and stop at the maximum', () => { | ||
| websocketStore.connect(true); | ||
| for (let attempt = 0; attempt < 8; attempt++) { |
There was a problem hiding this comment.
Attempt limit remains untested The test stops after eight failed attempts, but the configured limit is ten. It checks that delays stop growing, not that retries stop at the attempt limit. A regression that keeps retrying past that limit would still pass; extend the test through the limit and assert that no further retry is scheduled.
Knowledge Base Used: Frontend data and real-time state
Co-authored-by: Radhey Kalra <radheykalra901@gmail.com>
* Fix auto_discover mounts being dropped at startup (#131) * Fix auto_discover mounts being dropped at startup Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Make the auto_discover test pick a mounted directory and check it is returned Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Make chunk_size_mb control browser upload chunks (#132) * Make chunk_size_mb control browser upload chunks Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Share one chunk size request across upload workers and respect cancel Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Resolve virtual paths in one place (#133) Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Parse WebSocket and job data at the boundary (#134) * Parse WebSocket and job data at the boundary Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Validate job progress range, add parser tests, log rejected frames briefly Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Move frontend state to runes and split the browse page (#136) * Migrate jobs and websocket stores to runes Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Migrate settings store to runes and split out appearance helpers Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Migrate auth store to runes Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Split the browse page into composables Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Keep the WebSocket reconnect backoff when connect runs in an effect Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Fix the auth API docs, drop stale comments, add AGENTS.md (#137) * Fix the auth API docs, drop stale spec comments, add AGENTS.md Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Add the frontend test command to AGENTS.md Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Correct the logout docs and scope the path rule Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Fix --dev failing config validation (#139) * Fix --dev failing config validation Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Isolate the dev credentials test from inherited BoxBox settings Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Test the WebSocket reconnect backoff (#138) * Test the WebSocket reconnect backoff Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Keep the connection mode on WebSocket retries and test the attempt limit Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Fix browsing discovered mount points Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> * Skip inaccessible auto-discovered mounts Co-authored-by: Radhey Kalra <radheykalra901@gmail.com> --------- Co-authored-by: usehoplite[bot] <288093033+usehoplite[bot]@users.noreply.github.com> Co-authored-by: Radhey Kalra <radheykalra901@gmail.com>
Problem
The WebSocket store reconnects with backoff, and the root layout calls
connect()from an$effect. Before theuntrackfix in #136, that combination opened 36 sockets in 5 seconds after a server restart. Nothing in the repository would catch the bug coming back. Greptile asked for this test on #136, but the commit was pushed after #136 was squash-merged, so it did not reachstaging/main.Change
connect()without theallowUnauthenticatedflag. Against a--devserver there is no access token, so the retry stopped at "Not authenticated" and the page never reconnected. The store now remembers the mode of the lastconnect()and the retry reuses it. The first version of these tests missed this because they closed the original socket again and again, and a retry never opened a new one.websocket.test.tswith five tests. Aconnect()call from an$effectopens no socket until the retry delay passes. Each retry opens a new socket, and delays double up to the maximum. Retries stop at the configured attempt limit with "Max reconnection attempts reached". Retries keep the connection mode. A successful open resets the delay, and a clean close does not reconnect.bun testcannot load.svelte.tsfiles on its own, so add a small preload (frontend/test/svelte-plugin.js, wired bybunfig.toml) that runs the Svelte compiler on them.bun run testnow passes--conditions browserso Svelte loads its client build, whereuntrackandflushSyncwork.@types/bunas a dev dependency (withbun add) so the preload type-checks without a@ts-nocheck.AGENTS.md.The only production change is the retry mode fix, three lines in
websocket.svelte.ts.Verification
the retry must open a new socket). After it, all 9 frontend tests pass. With theuntrackline removed, the effect test fails witheffect_update_depth_exceeded(checked earlier in Move frontend state to runes and split the browse page #136).bun run check,lint,testandbuildpass, andbun install --frozen-lockfileaccepts the lockfile.WebSocketandsetTimeout. It proves retry spacing, the limit and the mode, not a real network drop. The reconnect spacing was checked in a browser in Move frontend state to runes and split the browse page #136. The--devreconnect itself was not run against a real dev server.Targets
staging/main.Written by anthropic/claude-sonnet-5-5 in the Hoplite agent harness.