Skip to content

fix(ethereum): deflake monitor timeout tests in l1_tx_utils#24545

Merged
spalladino merged 1 commit into
merge-train/spartan-v5from
cb/fix-flake-l1-tx-utils-network-error
Jul 6, 2026
Merged

fix(ethereum): deflake monitor timeout tests in l1_tx_utils#24545
spalladino merged 1 commit into
merge-train/spartan-v5from
cb/fix-flake-l1-tx-utils-network-error

Conversation

@AztecBot

@AztecBot AztecBot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

l1_tx_utils.test.ts flaked in CI (log, seen on #24454, which is unrelated to the failure). The failing test was monitors all sent txs:

● L1TxUtils › L1TxUtils with blobs › monitors all sent txs
  TimeoutError: L1 transaction 0x82cf...aa3a timed out
      at TestL1TxUtils.monitorTransaction (l1_tx_utils/l1_tx_utils.ts:601:11)

Root cause

The test creates the monitor promise and only attaches its rejection expectation after several intervening awaits:

const monitorPromise = gasUtils.monitorTransaction(state);
await sleep(100);
await cheatCodes.mineEmptyBlock();
await expect(monitorPromise).rejects.toThrow('timed out'); // handler attached here

Anvil timestamps have 1s granularity, so when the wall clock crosses a second boundary between the send and the monitor's timeout check, the monitor (with txTimeoutMs: 200, checkIntervalMs: 100) can observe the L1 timestamp already 1s past sentAt and reject before mineEmptyBlock() completes. In the failing run the timeout fired at 16:41:20.355, before the empty block was mined at .356 and before the .rejects handler attached at .357. Node emitted unhandledRejection in that window and jest 30 reported it as the test failure — which is why the failure stack has no test-file frame and the test's own assertions all passed in the log.

The same file already uses the safe idiom in a dozen newer tests: attach the handler synchronously with .catch(err => err) and assert via resolves.toBeInstanceOf(TimeoutError).

Fix

Apply that established pattern to the three remaining tests that expect a monitor timeout but attach the handler only after intervening awaits:

  • stops trying after timeout once block is mined
  • attempts to cancel timed out transactions
  • monitors all sent txs (the observed flake)

Test-only change; no product code touched. TimeoutError is exactly what monitorTransaction throws on timeout, so the assertions are equivalent-or-stricter than the previous message matching.

Evidence: CI log http://ci.aztec-labs.com/390c881d64e094b6 (search for monitors all sent txs).


Created by claudebox · group: slackbot

@AztecBot AztecBot added ci-draft Run CI on draft PRs. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure claudebox Owned by claudebox. it can push to this PR. labels Jul 6, 2026
@AztecBot AztecBot changed the base branch from next to merge-train/spartan-v5 July 6, 2026 17:39
@AztecBot AztecBot force-pushed the cb/fix-flake-l1-tx-utils-network-error branch from bb86cf0 to 7d1c105 Compare July 6, 2026 20:10
@spalladino spalladino marked this pull request as ready for review July 6, 2026 20:37
@spalladino spalladino enabled auto-merge (squash) July 6, 2026 20:37
@spalladino spalladino merged commit 99abdfe into merge-train/spartan-v5 Jul 6, 2026
14 of 18 checks passed
@spalladino spalladino deleted the cb/fix-flake-l1-tx-utils-network-error branch July 6, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants