Skip to content

Back off in the web client too, on the same schedule as Rust - #104

Merged
otsobide merged 1 commit into
devfrom
feature/web-poll-backoff
Aug 27, 2026
Merged

Back off in the web client too, on the same schedule as Rust#104
otsobide merged 1 commit into
devfrom
feature/web-poll-backoff

Conversation

@otsobide

Copy link
Copy Markdown
Owner

The half of #48 that v0.9.0 missed.

Why this exists

#48's body names two targets:

apps/server-frontend/src/api.js has its own polling loop with the same shape and deserves the same treatment.

Only the Rust client was fixed. The browser still slept a flat POLL_INTERVAL = 400 before asking a second time, so after v0.9.0 the web app was waiting twice as long as the CLI for the same job.

This was caught by an audit of the v0.9.0 release, along with the fact that Closes #48 had already fired from a commit message. #48 has been reopened with an account of what landed and what did not.

The change

Same schedule as apps/remote/src/waiting.rs, deliberately: 10 ms doubling to a 200 ms ceiling.

keeps_the_same_schedule_the_rust_client_uses fails if the two ever drift. That drift is the failure mode that made this half worth doing rather than leaving as a nicety: one client quietly slower than the other, for the same server, is exactly what the issue reported.

Tests

Three, and all three mutations are caught:

mutation tests that fail
start at the ceiling (the old flat wait) 2
never grow the delay 1
drift from the Rust ceiling 2

The first two spy on setTimeout to record what the loop asks for and fire it immediately, so a schedule spanning seconds of nominal waiting is checked instantly with no wall clock in the assertions. That is the same property the Rust side gets from its injected Sleeper, reached a different way because JavaScript hands you the seam for free.

45 Vitest cases in server-frontend (was 42), 116 across the repo.

Closes #48

Issue #48 names two targets and only one was fixed in v0.9.0. Its body says
`apps/server-frontend/src/api.js` "has its own polling loop with the same
shape and deserves the same treatment", and it did: a flat `POLL_INTERVAL` of
400 ms before the second question, so a job the server had already finished
cost the browser that much. Worse, after the Rust half landed the browser was
waiting twice as long as the CLI for the same job.

Same schedule, deliberately: 10 ms doubling to a 200 ms ceiling, mirroring
`apps/remote/src/waiting.rs`. `keeps_the_same_schedule_the_rust_client_uses`
fails if the two ever drift, which is the failure mode that made this half
worth doing rather than leaving as a nicety.

Three tests. The first two spy on `setTimeout` to record what the loop asks
for and fire it at once, so a schedule spanning seconds of nominal waiting is
checked instantly and with no wall clock in the assertions, which is the same
property the Rust side gets from its injected `Sleeper`. All three mutations
are caught: starting at the ceiling, never growing, and drifting from the
Rust ceiling.
@otsobide
otsobide merged commit 6c6742d into dev Aug 27, 2026
18 checks passed
@otsobide
otsobide deleted the feature/web-poll-backoff branch August 27, 2026 09:30
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