Repository navigation
test: fix two timing flakes in the keys proxy tests - #1795
Merged
Merged
Conversation
…back The keys-budget burst checks held each admitted request at the stub for a fixed 400 ms. On a loaded runner a burst request could reach the budget check after an admitted one completed, so it saw completed use instead of a reservation and the admitted count drifted. The stub now holds admitted requests until every expected refusal has come back, with a 10 s bound so a wrong count fails instead of hanging.
Contributor
Live test: ✅ PASSHead Stages |
The proxy's presence heartbeat goes through the stubbed fetch every 5 s. A pulse that landed between a reset of the recorded calls and a check made 'nothing went upstream' (and the per-seat counts) fail on a slow runner. The stub now answers presence pulses without recording them.
sprayberry-redline
approved these changes
Nov 2, 2026
sprayberry-redline
left a comment
Collaborator
There was a problem hiding this comment.
Verdict: approve. The burst helper keeps admitted requests in flight until the expected refusals have returned, and the upstream stub now excludes presence heartbeats from routed-request assertions. The tests retain their status-count assertions while avoiding timing-dependent completion ordering.
Minor:
test/keys-budget-proxy.mjs:102: This comment narrates the prior timing failure and the patch history rather than only documenting the helper's current contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an intermittent failure in
test/keys-budget-proxy.mjs(the burst checks for dan, erin and gina).Each admitted burst request was held at the stub for a fixed 400 ms so the burst overlapped at the budget check. On a loaded runner a burst request could reach that check after an admitted one had already completed, so it saw completed use instead of a reservation and the admitted count came out different from the expected one.
What changes:
burstOf(n, want, send)helper fires the burst and holds the admitted requests at the stub until alln - wantrefusals have come back. Every request is then decided while the admitted ones are still in flight, however slowly the runner delivers them.No product code changes. Ran the file three times locally: 53 passed, 0 failed each run.
Second fix, in
test/keys-proxy.mjs: the proxy's presence heartbeat goes through the stubbed fetch every 5 s, and the stub recorded it like a routed request. A pulse landing between a reset ofstartedand a check failed "nothing went upstream" (it can also skew the per-seat counts). The stub now answers presence pulses without recording them. Ran it twice locally: 68 passed, 0 failed.