Repository navigation
fix(cli): os start leaves no process of its group behind on SIGTERM - #34518
Conversation
On a config project, `serve` bundles objectstack.config.ts with esbuild, whose async API runs in a long-lived `esbuild --service` child that leaves only after its caller has exited. When `start` exited on SIGTERM (after its serve child, with its code), that service was still in start's process group. `serve` now stops the bundler service once the config module has loaded, so the service exits while `serve` can still reap it. Pinned by test/start-sigterm-process-group.integration.test.ts on the built entry: kill(-pgid, 0) at start's exit answers ESRCH; with the stop removed the esbuild service is read in the group and the pin is red. Claude-Session: https://claude.ai/code/session_01ADHkmRfW5u1LRmhWwaYHRp Co-authored-by: Claude <noreply@anthropic.com>
…s-group pin check-cli-test-child-env pins the exact set of test files that spawn bin/run.js. The new start-sigterm-process-group pin spawns the built entry on purpose (the source entry runs under tsx, whose own esbuild service would be read as the defect), so it joins the set with its reason. Claude-Session: https://claude.ai/code/session_01ADHkmRfW5u1LRmhWwaYHRp Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 37 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 1957932ffa4995ea67e2449c0a45440f9455ab56 && git checkout 1957932ffa4995ea67e2449c0a45440f9455ab56
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0c7869c03c9c6ff3a38bd6b09206edeee0184769 0fb55f6ec76cb38958d4128803e81729e815613f && git checkout -B drift-repro 0c7869c03c9c6ff3a38bd6b09206edeee0184769 && git merge --no-ff 0fb55f6ec76cb38958d4128803e81729e815613f
node scripts/docs-audit/affected-docs.mjs --json 0c7869c03c9c6ff3a38bd6b09206edeee0184769 |
|
repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp Final head for review: |
|
repo:objectstack#2 · os-steve · session_01ADHkmQVWXw7KT8ThxT4CBy 席位核对L1 verdict: ACCEPT · PR #34518 · card #34337 · first review · read 2026-11-17T00:14Z Head-sha: Read from GitHub at this head ( Checklist
Spot checks (mine)
L2 owed: no. None of the four contract faces is touched: Landing tier: |
|
repo:objectstack#2 · os-steve · session_01ADHkmRfW5u1LRmhWwaYHRp Landing · Head-sha: 0fb55f6 · ACCEPT → comment 6933488940
State: ready for review and auto-merge enabled; #34337 closes with the merge ( |
Requested by Steve · project thread
Fixes #34337
Clause-②: no
Metadata-protocol: none
维护者速读
objectstack start收到 SIGTERM 退出时,它的进程组里不再残留进程。serve载入objectstack.config.ts后立即关掉打包器 esbuild 的常驻服务进程。serve退出后才走,所以start退出那一刻它还在。容器运行时、systemd、多副本演练这类监管者读到「已停」时,组里其实还有进程。serve用配置文件启动时,于启动阶段多一次 esbuildstop();之后再有 esbuild 调用会自动重开服务。回滚即撤本 PR。packages/cli/src/utils/config.ts(stopConfigBundler与原因)、packages/cli/src/commands/serve.ts(唯一调用点)、packages/cli/test/start-sigterm-process-group.integration.test.ts;scripts/check-cli-test-child-env.mjs的名单因新测试加一项(21→22)。pnpm --filter @objectstack/cli build && cd packages/cli && npx vitest run --project integration test/start-sigterm-process-group.integration.test.ts,预期 1 passed。What changes
os startalready forwards SIGTERM to itsservechild and exits with the child's code once the child has exited (ServeRestartCoordinator, #21114). The process the card's drill found alive is the child ofserve, notserveitself.On a config project,
servebundlesobjectstack.config.tsthroughbundle-require, which runs esbuild's async API. esbuild serves that API from a long-livedesbuild --servicechild process, and that child leaves only when it reads end-of-file on its stdin, a moment after its parent has exited. So whenstartexited, the bundler service was still in its process group.servenow calls esbuild'sstop()right after the config module loads (stopConfigBundlerinutils/config.ts, one call site incommands/serve.ts). The service exits at boot whileserveis alive to reap it, so the group a SIGTERM later finds isstartandserveonly. Boots with--artifact/--artifact-fallbackor--prebuiltnever start the bundler and skip the call.bundle-requiretakes esbuild as a peer dependency, so it runs the copy this package declares, which is the instance stopped.The premise was re-measured on
origin/maine8cba8f before the change (built entry, SIGTERM to thestartpid alone):startexit[esbuild](child ofserve, reparented)--artifactproject, beforeTests
packages/cli/test/start-sigterm-process-group.integration.test.ts(integration tier: spawns the builtbin/run.js). It bootsstarton adefineStackconfig project in its own process group, checks that the probe seesstartandservein the group (positive control), sends SIGTERM to thestartpid alone, and readskill(-pgid, 0)in the exit handler: it must answer ESRCH, and the exit code must be 0 (the child's).stopConfigBundler()call removed and the CLI rebuilt (grep -c stopConfigBundler dist/commands/serve.js= 0), the pin is red:expected [ '8309 8270 [esbuild] <defunct>' ] to deeply equal []andkill(-pgid, 0) still found a member of the start process group at its exit. Restored and rebuilt: 1 passed.bin/run-dev.jsunder tsx) is not used by the pin: tsx's own esbuild service is a child of thestartparent there and would be read as this defect.No existing test was changed. One gate's census changed with it:
scripts/check-cli-test-child-env.mjspins the exact set of test files that spawn the built entrypoint, and the new pin joins that set (twenty-one files become twenty-two), with an entry saying why it spawns the built entry. The gate's self-test and scan both pass at the head.Acceptance notes
Verification
Gate readings are in the os-dev report on the card.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmRfW5u1LRmhWwaYHRp