Skip to content

test(node): hermetic data root for the lifecycle suite (RelaunchedAfterCrash flake) - #76

Merged
krassx merged 1 commit into
mainfrom
fix/lifecycle-test-hermetic
Oct 20, 2026
Merged

krassx merged 1 commit into
mainfrom
fix/lifecycle-test-hermetic

Conversation

@krassx

@krassx krassx commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

launch-lifecycle.test.ts launched with token tok and the default data root, which is <tmpdir>/bugsee/<hash(tok)> — shared with every other test (and every parallel worker) in the process tree. A dead sibling instance's incident marker left there by an unrelated crash test makes this suite's launch emit RelaunchedAfterCrash at random. Seen as a CI-only failure on #73 (relaunch > the lifecycle listener passed as an option sees Launching/Launched, and survives relaunch: received an extra com.bugsee.lifecycle.RelaunchedAfterCrash); it passes locally and on re-run.

The suite's opts() default now sets dataRootBase to a per-process temp directory (removed in afterAll). Tests that pass their own dataDir are unaffected.

Notes

  • Test-only change; no product code touched.
  • Other suites that launch with the default root may have the same exposure; I only changed the one that flaked. A webworker RelaunchedAfterCrash timing flake was also seen earlier — worth a separate look.

Test plan

  • pnpm ci:local; the suite passes repeatedly

🤖 Generated with Claude Code

@claude

claude Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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


Review of #76: hermetic data root for the lifecycle suite

I found no real issues. I read the diff and the surrounding code. I didn't run tests or CI.

Checks

  • relaunch() keeps the isolation. The flaking test calls relaunch() with no options. relaunch in packages/core/src/relaunch.ts reuses only the options in RELAUNCH_KEPT_OPTIONS, and dataRootBase is in that list (packages/core/src/carrier.ts:249). The relaunched client therefore stays in the hermetic root, not the shared <tmpdir>/bugsee/<hash(tok)>.
  • The option is wired through. dataRootBase is a real launch option, resolved as options.dataRootBase ?? tmpdir() (packages/node/src/launch.ts:648). Only the default-root path uses it. Tests that pass their own dataDir ignore it, as the PR says.
  • The default-root hardening check should still pass. mkdtempSync creates the directory with mode 0700, so the check on <base>/bugsee shouldn't be affected. launch.test.ts:2735 already covers a fresh default root made through dataRootBase.
  • Cleanup is safe. afterEach stops every tracked client before afterAll removes the root. The new imports (afterAll, mkdtempSync, rmSync, tmpdir, join) are all present.

Not a blocker

  • Sharing inside the suite. The tests in this file still share one root and one token. Cross-test marker leakage inside the suite is still possible, but only if one test leaves a dead instance behind. That is unlikely here, because tests that simulate a crash use their own dataDir.
  • Other suites. The PR already notes that other suites launching on the default root may have the same exposure, plus the separate webworker RelaunchedAfterCrash timing flake. A follow-up that sets a per-worker dataRootBase in a shared vitest setup would fix this for every suite. That is optional.

Overall risk: Low (test-only change)
Merge recommendation: Approve and merge.
Positives:

  • The change is small and targeted.
  • The comment explains the cause of the flake.
  • It uses an existing public option instead of touching product code.

@coderabbitai

coderabbitai Bot commented Oct 19, 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: bc0a6428-0ddc-443b-9a7d-311dcd3bc58c
📥 Commits

Reviewing files that changed from the base of the PR and between fb27e0b and 82ed847.

📒 Files selected for processing: 1
  • packages/node/src/launch-lifecycle.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Tests
    • Isolated lifecycle test data to prevent interference from persistent data created by other tests.
    • Cleaned up temporary test data after the suite completes.

The lifecycle test suite now uses a unique temporary data root through its shared launch options. An afterAll hook removes the root after the tests complete.

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to 82ed8

The lifecycle tests use isolated temporary data roots; no concrete merge-blocking concern remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the test-only change and its purpose: isolating the Node lifecycle suite data root to address a RelaunchedAfterCrash flake.
Description check Passed The description is directly related to the changeset. It explains the shared data root, the observed CI failure, the per-process temporary root, cleanup, scope, and test plan.
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

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

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