Skip to content

Add per-request timeout and failover to sync client - #20

Open
j0ntz wants to merge 1 commit into
masterfrom
jon/harden-account-creation
Open

Add per-request timeout and failover to sync client#20
j0ntz wants to merge 1 commit into
masterfrom
jon/harden-account-creation

Conversation

@j0ntz

@j0ntz j0ntz commented Jul 31, 2026

Copy link
Copy Markdown

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

Asana: https://app.asana.com/0/1215088146871429/1217058350202033

createRepo/readRepo/updateRepo had no per-request fetch timeout. A sync server that accepts or silently drops the connection without ever responding hung loggedRequest forever, so the shuffled failover loop never advanced to the next server. This re-created the login-server outage (a powered-off sync-tester-eu still listed in the config) on any silently-dead sync server, production included.

Changes:

  • Add requestTimeoutMs to SyncClientOptions (default 10000).
  • Race each request against that timeout in loggedRequest (Promise.race, since the injected FetchFunction is not guaranteed to honor an AbortSignal — serverlet 0.1.0's FetchOptions has no signal). On timeout the request rejects with a NetworkError and the caller fails over to the next server within seconds.

Consumer follow-up (separate): bump this dep in edge-login-server and deploy.

Testing

  • New unit test (test/unit/sync-client.test.ts) injects a fetch whose first server hangs past a shortened requestTimeoutMs and whose second server responds; asserts createRepo fails over to the second server, both servers were tried, and the elapsed time is bounded by the timeout (not the full hang). Also covers the no-timeout happy path.
  • npm test (nyc + mocha), eslint, tsc, and rollup build all pass via verify-repo.sh.

A silently-dead sync server (one that accepts or drops the connection
without ever responding) had no fetch timeout, so createRepo/readRepo/
updateRepo hung forever and the shuffled failover loop never advanced.
This re-created the login-server outage on any dead server, prod included.

Race each request against a configurable timeout (requestTimeoutMs,
default 10s) so a dead server rejects with a NetworkError and the caller
fails over to the next server within seconds.
@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

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