Skip to content

test(core): wait for fake stop handlers before reaping - #281

Merged
ElbertePlinio merged 2 commits into
mainfrom
fix/265-reap-order
Oct 7, 2026
Merged

ElbertePlinio merged 2 commits into
mainfrom
fix/265-reap-order

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Fixes the reap-order flake in packages/core/test/session.test.ts. The cause was in the test, not the product.

Each fake process is a node -e script that installs its SIGTERM handler only after Node starts up. The test waited a fixed 100 ms before reaping. Under load, Node startup took 90 to 140 ms, so the reaper sometimes signalled the fake browser before its handler existed. The default action killed it before it wrote browser to the order file, which gave [vnc, xvfb]. Each fake now writes a ready file right after it installs its handler. A waitForReadyFiles helper replaces the fixed delay, polls every 10 ms with a 10 s limit, and fails at once if a fake exits early. The order assertion is unchanged.

Requirement Verified by Scenario Result Evidence
Find why the browser stop is missing under load Measurement and forced repro Spawn-to-handler time with 48 busy loops on 16 cores; a temporary 300 ms delay before the fake browser's handler Startup 90 to 140 ms (16 of 20 over 100 ms); old test failed 3 of 3 with the delay, fixed test passed 3 of 3 Worker report
Fix it without weakening the assertion Code review of the diff Order assertion [browser, vnc, xvfb] kept; only setup changed Done This diff
Repeat-run evidence under load Repeated runs of the target test 48 busy loops: before 36/40 pass, after 40/40; lead rerun with 24 busy loops: 15/15 pass Pass Worker report and lead rerun
Test timeout covers readiness and teardown (review finding) Forced-delay runs 6 s browser startup delay passes in about 6.1 s; 12 s delay fails through the readiness path and the finally cleanup leaves no fake alive Pass; Astra recheck: resolved Worker report, Astra recheck
No regressions Automated bun run lint, bun run typecheck, bun run build, bunx vitest run packages/core test/security (1271 passed); PickCheck no new or worsened violations Pass Local runs

QA pass skipped: this is a test-only change with nothing to drive.

Closes #265

The reap order test waited a fixed 100 ms before it signaled the fake
browser, VNC and Xvfb processes. Under load, Node startup can take
longer, so the reaper sent SIGTERM to the browser group before its
handler existed and the fake died without a record.

Each fake now writes a ready file after it installs its SIGTERM
handler, and the test waits for all three before it reaps.

Closes #265
@ElbertePlinio
ElbertePlinio merged commit bea2833 into main Oct 7, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/265-reap-order branch October 7, 2026 21:26
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.

test(core): reap order test sees no browser stop under full-suite load

1 participant