Skip to content

Test the WebSocket reconnect backoff - #138

Merged
jR4dh3y merged 2 commits into
staging/mainfrom
hoplite/euhesperides-d9702ac5--ws-reconnect-test
Oct 1, 2026
Merged

jR4dh3y merged 2 commits into
staging/mainfrom
hoplite/euhesperides-d9702ac5--ws-reconnect-test

Conversation

@usehoplite

@usehoplite usehoplite Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The WebSocket store reconnects with backoff, and the root layout calls connect() from an $effect. Before the untrack fix 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 reach staging/main.

Change

  • Fix: a retry called connect() without the allowUnauthenticated flag. Against a --dev server 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 last connect() 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.
  • Add websocket.test.ts with five tests. A connect() call from an $effect opens 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 test cannot load .svelte.ts files on its own, so add a small preload (frontend/test/svelte-plugin.js, wired by bunfig.toml) that runs the Svelte compiler on them. bun run test now passes --conditions browser so Svelte loads its client build, where untrack and flushSync work.
  • Add @types/bun as a dev dependency (with bun add) so the preload type-checks without a @ts-nocheck.
  • Note the preload in AGENTS.md.

The only production change is the retry mode fix, three lines in websocket.svelte.ts.

Verification

  • Before the fix, 4 of the 5 reconnect tests failed (the retry must open a new socket). After it, all 9 frontend tests pass. With the untrack line removed, the effect test fails with effect_update_depth_exceeded (checked earlier in Move frontend state to runes and split the browse page #136).
  • bun run check, lint, test and build pass, and bun install --frozen-lockfile accepts the lockfile.
  • The test fakes WebSocket and setTimeout. 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 --dev reconnect itself was not run against a real dev server.

Targets staging/main.


Written by anthropic/claude-sonnet-5-5 in the Hoplite agent harness.

Co-authored-by: Radhey Kalra <radheykalra901@gmail.com>
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
box-box Ready Ready Preview Oct 1, 2026 8:42am UTC

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 23940b9a-e62e-446a-ab2f-e105fe1ed505

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment on lines +68 to +72
websocketStore.connect(true);
for (let attempt = 0; attempt < 8; attempt++) {
FakeSocket.instances.at(-1)?.onclose?.({ code: 1006 });
scheduled.shift()?.();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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>
@jR4dh3y
jR4dh3y merged commit cd1b61e into staging/main Oct 1, 2026
8 checks passed
jR4dh3y added a commit that referenced this pull request Oct 1, 2026
* 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>

This branch was successfully deployed

1 active deployment
Preview — cd4c2d33 Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant