Skip to content

test(webworker,node): hermetic data roots for the RelaunchedAfterCrash suites (flake) - #89

Merged
krassx merged 1 commit into
mainfrom
test/hermetic-launch-data-root
Oct 20, 2026
Merged

krassx merged 1 commit into
mainfrom
test/hermetic-launch-data-root

Conversation

@krassx

@krassx krassx commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Root cause of the recurring 'RelaunchedAfterCrash needs evidence' CI flake is NOT a shared data root. The webworker suite uses a fresh in-memory fake-indexeddb IDBFactory per test (no disk, no default root), so it is already hermetic. The failure is a timing race: the test waited a fixed setTimeout(50) for the async dead-sibling recovery (IndexedDB reads) to emit the event, which loses on a loaded CI runner (expected [] to have a length of 1, expected [2 items] to deeply equal [3 items]).

Reproduced deterministically by shrinking the sleep to 0: the exact two CI assertion messages appear. Fix: poll up to 1500ms for the event (same pattern @bugsee/browser already uses), keeping a short tail so a wrong second emission still lands. No production code changed.

Node: the only default-root RelaunchedAfterCrash suite was already made hermetic in #76; launch-stop-safety.test.ts uses explicit dirs. No further node change needed.

Test plan

  • Sleep=0 mutant fails with the CI messages; clean suite passes
  • Webworker launch suite x20 under 8 CPU-burner processes: 0 failures
  • pnpm ci:local passes

🤖 Generated with Claude Code

@claude

claude Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 21s —— View job


Review of PR #89: hermetic data roots for the RelaunchedAfterCrash suites

I read the diff against the surrounding test code. I did not run the test suite, so I'm not claiming any test results. The numbers in the PR description (sleep=0 mutant, x20 under CPU load) are the author's, and I haven't verified them.

No real findings. The change is a test-only polling loop in packages/webworker/src/launch.test.ts:1645-1651, with no production code touched.

Checks I made

  • Timing: The loop uses Date.now() and real setTimeout. The file has no useFakeTimers, and recoveryClock (line 193) is only the injected SDK clock, so the loop can't hang on a frozen clock. The worst case is about 1.5s plus the 50ms tail. That's well under the 30s testTimeout in packages/webworker/vitest.config.ts:14.
  • Positive cases: Both emit-once tests now wait for the event instead of racing a fixed sleep. That removes the two CI failure messages the PR quotes (expected [] to have a length of 1 and the 2-vs-3 deep-equal).
  • Silence case (run(false)): This test now always waits the full 1.5s before asserting, so it adds about 1.5s of wall time. It still asserts absence over a longer window than before, so it is no weaker.
  • "ONCE" test (2 siblings): The loop exits on the first emission and the 50ms tail then watches for a duplicate. On a heavily loaded runner a late duplicate could be missed. That would make the test pass when it should fail, not flake, so it is not a regression. You could harden it by waiting for recovery to finish deterministically, for example on a settle signal, if one exists.
  • Stopped-client test (lines 1676-1693): It still uses a fixed setTimeout(50), but it asserts absence, so it can't flake, only pass vacuously under load. The client.stop() before the recovery gets there is also timing-dependent. That's pre-existing and out of scope here.

Summary

  1. Overall risk: Low (test-only change, no production impact).
  2. Merge recommendation: Approve and merge.
  3. Most important issues to fix: None. Optionally, make the duplicate-emission check in the multi-sibling test deterministic.
  4. Positives:

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f242087-36ae-42c4-89d4-d9a827436ff2
📥 Commits

Reviewing files that changed from the base of the PR and between 72d7936 and ee3c1a2.

📒 Files selected for processing: 1
  • packages/webworker/src/launch.test.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Summary

Summary by CodeRabbit

  • Tests
    • Improved crash-recovery test timing to better account for asynchronous recovery events.
    • Added polling and duplicate-event detection to make test results more reliable.

The RelaunchedAfterCrash test helper now polls for the recovery event at 25 ms intervals for up to 1.5 seconds. It then retains a 50 ms delay to detect duplicate emissions.

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to ee3c1

The test synchronization change is bounded and preserves duplicate-emission detection, with no merge-blocking risk established.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title identifies the webworker test suite and its CI flake. Although it emphasizes hermetic data roots rather than the timing fix, it remains related to the changeset.
Description check Passed The description clearly explains the timing race, the polling fix, the lack of production changes, and the test validation.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 1
  • Waived: $0.25 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Comment @coderabbitai help to get the list of available commands.

@krassx
krassx merged commit 031e4fb into main Oct 20, 2026
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