test(world-state): make delayed-close fork queue-cleanup wait deterministic#24106
Merged
PhilWindle merged 1 commit intoJun 15, 2026
Merged
Conversation
Collaborator
Author
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
PhilWindle
approved these changes
Jun 15, 2026
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.
Why the merge train was dequeued
PR #24053 (
merge-train/spartan-v5→v5-next) was dequeued from the merge queue because itsmerge-queue-heavyCI run failed. Tracing the failure:27568575541→ shardx4-full(ci-full-no-test-cache) failed.yarn-project/world-state/src/native/native_world_state.test.ts(code: 1), specifically:native_world_state.test.ts:966):warnSpyassertion on the preceding line passed; only the queue-cleanup assertion failed.This test and the world-state instance/facade code it exercises are not modified by this train — the test already exists unchanged in
v5-next. So this is a pre-existing timing flake that happened to fail in this grind and blocked the train.Root cause
The delayed-close path is correct and always eventually cleans up:
asyncDispose()schedulessleep(closeDelayMs).then(() => close())(fire-and-forget).close()→doClose()→instance.call(DELETE_FORK), and the per-fork queue entry is deleted incall()'sfinallyregardless of whether the native side rejects withFork not found(which it does here, because the reorg/unwind already destroyed the native fork).The test then waited a fixed
sleep(closeDelayMs * 3)(3s) before asserting the queue was gone. Under a loaded merge-queue grind, the scheduled close (fired at +closeDelayMs) plus its asyncDELETE_FORKround-trip andqueue.stop()can take longer than that fixed margin, so the queue entry was still present when the assertion ran — Receivedtrue.Fix
Replace the racy fixed sleep with a deterministic wait on the exact asserted condition:
This polls until the queue entry is removed (the cleanup runs inside the same close path), with a 30s timeout. It preserves the regression intent: if cleanup genuinely stopped happening,
retryUntilthrows a clearTimeout awaiting delayed-close fork queue cleanupinstead of a baretoBe(false). The production code is unchanged; no test is skipped or weakened. The now-unusedsleepimport is swapped forretryUntil.Verification
This is a test-only, single-statement timing change. I was unable to run
./bootstrap.sh ciin this environment — the workspace has nonode_modulesand no barretenberg/nativeworld_state_napibuild artifacts, so exercising this native test would require a multi-hour C++ + TS build that isn't proportionate to a wait-deterministically change. The change is type-checked by inspection:retryUntil(fn, name, timeoutSec, intervalSec)matches the foundation signature, and the import path (@aztec/foundation/retry) is the one used across yarn-project. CI on this PR will validate it.Created by claudebox · group:
slackbot