Repository navigation
test(platform-cloudflare): stop test work outliving its test - #60
Merged
Merged
Conversation
Three Cloudflare suites failed intermittently in one CI lane under CPU contention: - the eviction progress-wait test hit its 20 s cap after a 19.6 s stall that began when it aborted the Object mid-wait; - background-workers passed every test and then reported a pending vitest module-resolution RPC while the environment was closing; - join-restart hit its 10 s cap twice, its five scenarios each running about 135 sequential SQLite operations. The waiter-count latch was a point-in-time gauge: a replayed awaitProgress request that registered and left between two observer calls was missed. It becomes a monotonic per-incarnation subscription counter, and the test latches on the count instead of the gauge. A probe confirmed the platform re-runs an in-flight awaitProgress on the fresh incarnation after state.abort() and resolves the client promise when progress arrives, so the client needs no retry. Client fibers are now tracked by the harness, and each test ends with a quiescence barrier: disarm the eviction failpoints it armed, interrupt and await its fibers, and delete the persisted alarm of every Object it touched. Every barrier step is bounded so a wedged Object cannot stall the shared environment. The join test's 10 s per-test cap and its four inner two-second Effect.timeout guards are removed; that work legitimately sits within a small factor of the cap under contention, and the suite's configured timeout is the budget. The other suites keep their caps, which the fixed tests meet with ample headroom.
Contributor
Author
|
Lead review on 4563fc4: test-only change. Waits follow real signals, and a bounded per-test quiescence barrier disarms eviction failpoints, ends client fibers and clears alarms before workerd teardown. The progress-wait and background-workers caps are restored; join-restart drops its inner wall-clock waits. Every check on the head passed on the first attempt, including both cloudflare shards and both postgres shards. Four review rounds ended with no open P0/P1. |
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.
What changed
Three Cloudflare suites failed intermittently in one lane under CPU contention. The fix removes the causes; no timeout was raised and no test was skipped or weakened.
1. The eviction wait latched on a point-in-time gauge.
progress-wait.test.ts"reconnects after eviction..." hit its 20 s cap at 20005 ms, with the eviction landing 0.4 s in and ~19.6 s of silence after it. The harness waited for the Object's live waiter count to equal one; a replayedawaitProgressrequest that registers and leaves between two observer calls is missed by such a gauge. The test worker now counts subscriptions monotonically per incarnation (incarnation+total, predicate latches), and the test waits for the count rather than the gauge. It also waits for the new incarnation to have served a subscription, which is what "the wait was reconstructed" means.A probe measured the platform behaviour this relies on: after
state.abort(), workerd re-runs the in-flightawaitProgresson the fresh incarnation (incarnation 1→2, that incarnation reports the waiter) and the client promise resolves when progress arrives. The client's retry classification never runs for an eviction, so the client needs no retry.2. Tests left work running past their end.
background-workers.test.tspassed all nine tests and then reportedEnvironmentTeardownError: [vitest-worker]: Closing rpc while "resolve" was pending38 ms later. A pool worker reuses one workerd instance across test files, so work a test leaves behind runs into the next file's environment. Every test in the affected files now ends with a quiescence barrier: disarm the eviction failpoints it armed, interrupt and await the client fibers it forked (tracked by the harness), and delete the persisted alarm of every Object it touched, so no alarm pass starts while the environment closes. Each barrier step is bounded so a wedged Object cannot stall the shared environment.progress-waitandbackground-workerskeep their per-test caps, which the fixed tests meet with ample headroom.3. A per-test cap sat below the work's legitimate cost.
join-restart.test.tshit its 10 s cap twice; each of its five scenarios runs about 135 sequential SQLite operations plus a cold reconstruction, and the cap applied per test. That cap and four innerEffect.timeout('2 seconds')guards on Deferred waits are removed; the suite's configured timeout is the budget.Rejected alternatives
Verification
pnpm --filter @systemfsoftware/agent-platform-cloudflare run test: 35 files, 187 passed, 6 skipped.pnpm typecheck,pnpm lint(0 warnings, 0 errors) andpnpm format:checkpass.test/progress-wait.test.ts,test/join-restart.test.tsandtest/background-workers.test.tstogether: 17 passed.Test-only change; the changeset is
none. A learning record accompanies it indocs/solutions/test-failures/.