Skip to content

test: a missed held-sync arrival fails its own test instead of hanging cleanup - #421

Merged
ualtinok merged 1 commit into
mainfrom
test/quota-held-sync-teardown
Oct 21, 2026
Merged

ualtinok merged 1 commit into
mainfrom
test/quota-held-sync-teardown

Conversation

@antauth-alfonso

@antauth-alfonso antauth-alfonso Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Main's CI on a6efa38 hit a 10-second hook timeout in quota poll serves its reading while runtime sync is held and dispose drains publication, then two later tests reported a leaked fetch mock. The test waited on an arrival signal for the held runtime write that nothing released on teardown, so if that write never reached the spy (most plausibly the request's detached advisory quota publication being superseded or refused, which production allows), the body waited forever and cleanup couldn't finish.

The arrival is now a lifetime gate: teardown opens it, and the body returns without touching the stopping plugin, so a missed arrival is reported as this test's own timeout and nothing cascades. Every assertion and deadline is unchanged; production code is unchanged.

Not reproduced naturally in 320 fresh processes on a6efa38 and 026fe85 (0 held-sync failures); a controlled missed-arrival injection reproduced the exact hook timeout and is red as a plain test timeout after the fix, with the two following tests green. Tracing showed the request served without waiting on any pool write.


Summary by cubic

Fixes a potential hang in the quota poll serves its reading while runtime sync is held and dispose drains publication test by converting the held-sync arrival wait into a lifetime gate, so a missed arrival times out this test alone instead of hanging teardown and leaking a fetch mock into later tests.

  • Teardown opens the arrival gate and stops the plugin; the test body returns early when no interception occurred.
  • All assertions, deadlines, and production code are unchanged.
  • A controlled missed-arrival injection confirmed the original 10-second hook timeout and downstream fallout, and now reports only the test's own 5-second body timeout.

Written for commit 8f89c60. Summary will update on new commits.

View guided diff Turn on auto-fix

The raw arrival signal can leave TestLifetime waiting on bodySettled after a test timeout, before fetch and environment restoration. Register arrival as a lifetime gate and stop the late body when teardown releases it without an interception. Keep all eight successful-path assertions and the 250 ms/20 ms deadlines unchanged.

The original push-CI trigger was not naturally reproduced: 40 fresh processes each for the held-sync test and full quota-sweep file on a6efa38 and 026fe85 produced no held-sync failure. Repeat those matrices with this hardening also produced none (two unrelated full-file timeouts across 320 processes). A temporary missed-arrival control reproduced the 10s hook hang and downstream fetch/environment fallout while the request had already served 200 without joining a pool write. After hardening the same control reports only its original 5s body timeout; both follower tests pass. Production behavior is unchanged.

Verified with pinned Bun 1.3.14 on linux,4c: Core build, OpenCode TypeScript 7.0.2 checks, four 80-process reproduction matrices, and final ordered held-sync/network-guard/API-lastUsed check (3 pass, 17 assertions). Investigation evidence and baseline failures are recorded in the uncommitted internal investigation artifact.
@ualtinok
ualtinok merged commit 8f89c60 into main Oct 21, 2026
11 checks passed
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