Repository navigation
test(web): stop signaling pid 0 on an empty loader pid file (ENG-1571) - #2578
Conversation
The fake ldd writes the loader's pid with a redirect. Under load the group
kill can land between the redirect's open and the echo, leaving an empty
file. Number('') is 0, and kill(0, 0) signals the test's own process group,
so the test saw the loader alive until its poll timed out. Read a pid that
is not a positive integer as no loader recorded.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Other Merge Risk:
|
michal-e2e
left a comment
There was a problem hiding this comment.
Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.
Reviewed 7c5e1a618. Must fix: none.
The PID check keeps an empty loader.pid from making the test probe its own process group. A live positive PID still reaches the probe. Approval stays with the maintainer.
What
In
packages/web/tests/unit/host-libraries.test.ts, thealive()helper now returnsfalsewhenloader.pidis empty or does not hold a positive integer, instead of callingprocess.kill(0, 0). Test-only change, with no changeset or docs update.Why
kills an ldd that outlives its time or the signalflaked in CI on PRs #2471, #2412, andmain(run 46617624329,test (26, packages), commitd1860bf60), always timing out at the third probe where theAbortSignalhas already fired (packages/web/tests/unit/host-libraries.test.ts:120, line 117 onmain).The ticket guessed an unreaped zombie, which logging
runLdd(packages/web/src/host-libraries.ts:27) ruled out. In a failing run,process.kill(-child.pid, 'SIGKILL')killed everylddgroup, every child closed withSIGKILL, and no process survived.loader.pidheld""both 82 ms after the probe and after the 1 s poll.The bug is in the fake
lddscript atpackages/web/tests/unit/host-libraries.test.ts:97, which runsecho $! > loader.pid. Because the signal is already aborted,runLddkills the group right after spawn (packages/web/src/host-libraries.ts:51). Under CPU load, the shell runs on another core, forks/bin/sleep 30, createsloader.pidempty via the redirect, and takesSIGKILLbeforeechowrites.Number('')is0, andprocess.kill(0, 0)signals the test's own process group, soalive()stayedtrueuntilexpect.polltimed out. Returningfalsefor non-positive or non-integer pids fixes the flake without touchingrunLdd.How it works
alive()atpackages/web/tests/unit/host-libraries.test.ts:99-108parsesloader.pidand returnsfalseunlessNumber.isInteger(pid) && pid > 0, replacingprocess.kill(Number(readFileSync(loader, 'utf8')), 0). When the shell dies before writing a pid, nothing in the test names the loader anyway, andrunLdd's group kill atpackages/web/src/host-libraries.ts:34still takes it.Using a temp file and
mvwould spawn one more process beforeloader.pidexists, opening a new window for the 300 ms timeout probe'sexistsSync(loader)check atpackages/web/tests/unit/host-libraries.test.ts:112to fail.The three concurrent
lddscripts still share oneloader.pidfile, so the test only checks the last writer's loader. That is left out of scope.Issue
Fixes ENG-1571
Verified
Ran it locally: yes
On Linux (LBox, 16 cores, Node 26.3.1), ran 24 concurrent instances of
pnpm exec vitest run tests/unit/host-libraries.test.ts -t 'kills an ldd'beside 16 CPU-burner loops.loader.pidemptyThe full
packages/web/tests/unit/host-libraries.test.tsfile passes, 10/10.Changes by Claude Opus 5.5 (claude-opus-5-5) in T3 Code (Claude Code harness); PR description by Gemini 4 Neon.
Summary by CodeRabbit