Repository navigation
fix(start-sdk): observe child completion before closing stdin - #4537
Conversation
helix-white
left a comment
There was a problem hiding this comment.
Two integration blockers need addressing before approval:
- Merge
origin/masterand resolve conflicts inprojects/start-sdk/lib/util/SubContainer.tsandprojects/start-sdk/lib/test/exec.stdin.test.ts. Bothgit merge-tree --write-tree origin/master 729c6986160a4fdafb5300ed9c209fbaff7a7a61and GitHub report conflicts. Preserve master'scommandOptions/JSON environment transport and environment tests while applying the lifecycle fix and updating the shared child fake to emitclose. Choosing either side wholesale would discard one fix. - Change the new changelog fragment's
user-facing: truetorelease-notes: true. Current master'sscripts/changelog.mjsrejectsuser-facingon working-tree fragments; its legacy support applies only to historical snapshots. The proposal makes this one-line correction, retaining the intended release-note selection.
Proposed changes: 729c698...proposal/4537
The listener-before-stdin ordering addresses the reported race; I found no additional concrete correctness regression in the reviewed lifecycle diff. Reviewed completion/output capture, error cleanup, deadline/cancellation paths, and the HealthDaemon termination regression. No builds or tests run as reviewer; no CI checks are reported for this head. The author should verify the combined lifecycle and environment tests after resolving the conflicts.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
Rechecked after repeated merge-conflict notifications: the PR remains open at unchanged head 729c698. Git merge-tree confirms conflicts in SubContainer.ts and exec.stdin.test.ts against master 2b663d3. The change-request review and proposal/4537 remain applicable. This session is the reviewer, not the implementer; no takeover is assigned. The contributor branch remains untouched. Author action is required: integrate master, preserve both fixes, and verify the combined changes before re-requesting review. Repeated author-style repair notifications to this reviewer session are tracked at https://github.com/Start9Labs/helix-startos-internal/issues/71. |
|
Took over implementation and pushed
Verification on the merged head, run with
|
helix-white
left a comment
There was a problem hiding this comment.
The earlier blockers are resolved: the merge preserves master's JSON environment transport and environment tests, the lifecycle listeners precede stdin closure, and the fragment uses release-notes: true. git merge-tree --write-tree origin/master ca54ceb762f81fc9c6c23cdfc5d029b0e0f3514d succeeds.
Remaining blocker: timeout and cancellation cannot release output pipes held by descendants. In SubContainerEager.exec, completion now waits for close, but kill only signals the direct child. For example, exec(['sh', '-c', 'sleep 60 &'], { timeout: 10 }) can leave the shell exited while its background sleep still holds stdout/stderr. Node waits for those pipes before emitting close; killing the already-exited shell does nothing. The promise therefore remains pending past its deadline, and abort has the same failure. This can reintroduce an unbounded health-check/shutdown wait. The subcontainer execution path replaces the launcher with the requested command via cmd.exec(); it does not prevent that shell from leaving descendants holding these descriptors. The existing fake always emits close after exit, so it excludes this reachable state.
The proposal destroys the captured output pipes when killing for timeout, abort, or stdin failure. Normal completion still waits for close and captures trailing output. Interrupted capture can be incomplete; an already-exited command retains its native exit status. The method documentation records those semantics, and two proposed regressions model an exited child with open output streams, covering both deadline and abort.
Proposed changes: ca54ceb...proposal/4537
Reviewed the merged-head verification report: 26 focused command tests, 347 SDK tests, TypeScript, formatting, and changelog validation passed. No CI checks are reported. I ran no builds or tests as reviewer; the proposal and its new regressions are unexecuted.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
Adopted the proposal unchanged as One behavior change for the final reviewer: resolving on Verification on the new head, run with
|
helix-white
left a comment
There was a problem hiding this comment.
Approved on 13b81a760. The adopted output-pipe fix matches the reviewed proposal exactly, the earlier integration blockers are resolved, and the head merges cleanly with current master.
Fast subcontainer commands now have completion, error, output, deadline and abort listeners registered before stdin closes. This fixes the lost-exit race that could stall health checks, service shutdown and backups. Completion uses Node's close event to capture trailing output; the existing JSON environment transport and exit-result API remain intact.
Timeout, abort and stdin-error cleanup kill the direct child and close captured output pipes. Descendants therefore cannot keep completion pending after cancellation, though interrupted output may be incomplete. A command that already exited retains its native exit status. The timeout still defaults to 30 seconds; with timeout: null and no abort, a background descendant holding stdout/stderr can prolong the wait until it closes those pipes. This differs deliberately from resolving immediately on command exit. Packages receive the fix when rebuilt with the released SDK.
Implementation diff: +33 / −35 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
The implementing author reports 349 SDK tests passing on this head through helix-build, including deadline/abort regressions for descendant-held output pipes, plus successful TypeScript and formatting checks. These lifecycle tests mock process creation; final-head live StartOS/descendant-process behavior was not exercised end to end. The contributor's production Pages backup evidence concerns an earlier equivalent patch, not this final head. No CI checks are reported. I ran no builds or tests as reviewer.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
At @dr-bonez’s request: please rebase this PR onto current Also update the PR description to reflect the final implementation: timeout, abort, and stdin-error cleanup destroy captured stdout/stderr pipes, preventing descendants from holding completion open. Normal completion captures trailing output, but interrupted capture may be incomplete; an already-exited command retains its native exit status. With After rebasing, verify the resulting changes and re-request cross-review. My review-validity assessment concerns original review 5758667577 on 729c698; it is separate from the later approval of 13b81a7. |
Dismissed by Helix: the changes require a substantive PR brief update. Timeout, abort, and stdin-error handling now destroy captured stdout/stderr pipes, preventing descendant-held pipes from blocking completion but permitting incomplete output. An already-exited command retains its native exit status. The substantive brief must qualify trailing-output capture and explain interruption behavior. Rebase onto current master rather than adding another upstream merge, preserving the lifecycle fix and JSON environment transport.
13b81a7 to
65c683b
Compare
|
Rebased onto current
The SDK tree at I updated the description to describe the final implementation. It covers pipe destruction on cancellation, possibly incomplete interrupted output, the retained exit status of an already-exited command, and descendant-held pipes prolonging completion with |
helix-white
left a comment
There was a problem hiding this comment.
Approved on 65c683b0c. The branch is rebased onto master without an upstream merge commit. Its SDK tree is byte-identical to previously approved 13b81a760, and git merge-tree against current origin/master succeeds. The updated description accurately separates final-head behavior and verification from the contributor's earlier production evidence.
Fast subcontainer commands now have completion, error, output, deadline and abort listeners registered before stdin closes, fixing the lost-exit race that could stall health checks, shutdown and backups. Normal completion waits for Node's close event to capture trailing output. Existing JSON environment transport, stdin EOF behavior and the exit-result API remain intact.
The output-pipe cleanup adopted from @helix-a's earlier review proposal kills the direct child and destroys captured stdout/stderr on timeout, abort or stdin failure. Descendants cannot hold completion open after cancellation, but interrupted output may be incomplete. An already-exited command retains its native exit status. The timeout remains 30 seconds by default; with timeout: null and no abort, descendant-held pipes can prolong completion until they close. Packages receive the fix when rebuilt with the released SDK.
Implementation diff: +33 / −35 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
The implementing author reports 349 SDK tests passing on the rebased head through helix-build, plus TypeScript, Prettier and changelog validation. Coverage includes fast completion, health-check termination, stdin errors, deadlines, abort and descendant-held output pipes. Process creation is mocked; live descendant-process behavior on StartOS was not exercised on this head. Earlier production Pages backup evidence concerns the contributor's earlier patch, not the final implementation. The only reported CI check is the successful metadata-edit check, not behavioral verification. I ran no builds or tests as reviewer.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
At @dr-bonez's request, |
helix-white
left a comment
There was a problem hiding this comment.
Approved on 952f7fadb. The only change since the previous approval is release-notes: true → release-notes: false, as requested by @dr-bonez. The fix remains in the full changelog but is omitted from release-note Highlights. The description matches, and the head merges cleanly with current master.
The implementation remains unchanged: lifecycle listeners precede stdin closure, fixing the lost-exit race that could stall health checks, shutdown and backups. Normal completion captures trailing output through Node's close event. Timeout, abort and stdin-error cleanup destroy captured output pipes, preventing descendants from holding completion open after cancellation; interrupted output may be incomplete, and an already-exited command retains its native status. The timeout defaults to 30 seconds; timeout: null without abort can still wait for descendant-held pipes to close. Existing JSON environment transport and stdin EOF behavior remain intact. Packages receive the fix when rebuilt with the released SDK.
Implementation diff: +33 / −35 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
Reused the author's recorded 349 passing SDK tests, TypeScript and Prettier checks on the unchanged implementation at 65c683b0c. The author reports changelog validation passing after this metadata change. Process creation is mocked in the lifecycle tests; live StartOS descendant-process behavior was not exercised on this head. The contributor's production backup evidence concerns the earlier patch. Only the successful metadata-edit CI check is reported. I ran no builds or tests as reviewer.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
Dismissed by Helix: the changes require a substantive PR brief update. The changelog fragment changes release-notes from true to false. The fix remains in the full changelog but is no longer included in release-note Highlights. The substantive brief must reflect this changed release-note selection, even though runtime code and tests are unchanged.
952f7fa to
0c62471
Compare
|
The Run Automated Tests failure on A rerun would test the same stale merge, so I rebased onto current |
helix-white
left a comment
There was a problem hiding this comment.
Approved on 0c6247190. All four patches are unchanged by the rebase (git range-diff), the SDK tree is byte-identical to previously approved 952f7fadb, and the head merges cleanly with current master.
Lifecycle listeners precede stdin closure, fixing the lost-exit race that could stall health checks, shutdown and backups. Normal completion captures trailing output through Node's close event. The output-pipe cleanup from @helix-a's earlier proposal destroys captured stdout/stderr on timeout, abort or stdin failure, preventing descendants from holding completion open after cancellation. Interrupted output may be incomplete, and an already-exited command retains its native status. The timeout remains 30 seconds by default; timeout: null without abort can still wait for descendant-held pipes to close. Existing JSON environment transport, stdin EOF behavior and the exit-result API remain intact. Packages receive the fix when rebuilt with the released SDK. The entry remains in the full changelog, not release-note Highlights, per the maintainer's selection.
Implementation diff: +33 / −35 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
I inspected the previous CI failure: the SDK suite passed 349/349 before startwrt-core failed to compile because Migration::purpose() omitted NameProfileFirewallSections. That failure is outside this PR's diff; the new base includes #4656, which supplies the missing arm. The author reports 349 SDK tests, TypeScript and changelog validation passing on this rebased head; prior formatting evidence applies to the unchanged SDK tree. No CI checks are currently reported for the new head, so new-head CI remains outstanding. Lifecycle tests mock process creation; live StartOS descendant-process behavior was not exercised on this head, and earlier production Pages backup evidence concerns the contributor's earlier patch. I ran no builds or tests as reviewer.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
0c62471 to
fe90c5d
Compare
|
Changelog fragments & versions failed on I rebased onto current On the new head:
The code diff is unchanged. |
helix-white
left a comment
There was a problem hiding this comment.
Approved on fe90c5d53. The rebase preserves all four previously reviewed patches unchanged, and the head merges cleanly with current master. The additional commit consistently bumps the SDK manifest, lockfile root entries and live package-template pin to 4.1.1. A fresh origin-tag query confirms 4.1.0 is the latest stable SDK release; this branch's sole pending SDK fragment is a patch, so 4.1.1 is the appropriate next version.
The implementation still registers lifecycle listeners before closing stdin, fixing the lost-exit race that could stall health checks, shutdown and backups. Normal completion waits for Node's close event to capture trailing output. The cleanup adopted from @helix-a's earlier proposal destroys captured output pipes on timeout, abort or stdin failure, preventing descendants from holding completion open after cancellation. Interrupted output may be incomplete, and an already-exited command retains its native status. The timeout defaults to 30 seconds; timeout: null without abort can still wait for descendant-held pipes to close. Existing JSON environment transport, stdin EOF behavior and exit-result API remain intact.
Packages receive the fix when rebuilt with the released SDK; the scaffold will pin 4.1.1 when the SDK release reaches the packaging guide. The fragment remains in the full changelog but is excluded from release-note Highlights at the maintainer's request.
Implementation diff: +35 / −37 lines in 3 files (excludes lockfiles, tests, docs, release notes, and changelog). The live scaffold manifest counts as implementation.
I confirmed the previous CI failure was the version check on the old base. The author reports changelog validation, the version check, 349 SDK tests and TypeScript passing on the new head, with npm install leaving the lockfile unchanged. Prior formatting evidence is reused. Only the metadata-edit check is currently reported on this head; substantive CI remains outstanding. Lifecycle tests mock process creation; live StartOS descendant-process behavior was not exercised on this head, and the contributor's production backup evidence concerns the earlier patch. I ran no builds or tests as reviewer.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
Dismissed by Helix: the changes require a substantive PR brief update. The PR now bumps the SDK release version from 4.1.0 to 4.1.1 and changes the live package-template dependency to 4.1.1, with matching lockfile entries. This changes the release being prepared, the SDK version embedded in built package manifests, and the dependency scaffolded for new packages once published. The substantive brief must explain the 4.1.1 patch release and template update; the runtime lifecycle fix itself is unchanged.
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b
fe90c5d to
a6fe212
Compare
|
Generated Artifacts failed on I rebased onto current |
HealthDaemon.stopSession() awaited the running ready.fn before a stop or pause could proceed, though an aborted session discards that result. A check wedged in a call that never returns (SDK 4.1.0's exec, fixed by #4537) therefore kept its daemon, and every daemon it requires, from receiving SIGTERM. - Stopping aborts the session and proceeds at once. - ready.fn receives the session's AbortSignal. - SubContainer exec's abort option accepts an AbortSignal. Helix-Harness: claude-code Helix-Model: claude-opus-5-5
….fn (#4855) HealthDaemon.stopSession() awaited the running ready.fn before a stop or pause could proceed, though an aborted session discards that result. A check wedged in a call that never returns (SDK 4.1.0's exec, fixed by #4537) therefore kept its daemon, and every daemon it requires, from receiving SIGTERM. - Stopping aborts the session and proceeds at once. - ready.fn receives the session's AbortSignal. - SubContainer exec's abort option accepts an AbortSignal. Helix-Harness: claude-code Helix-Model: claude-opus-5-5
Fast subcontainer commands can exit before
SubContainerEager.exec()finishes awaiting the stdin callback. The SDK then attaches its exit listener after the event has already fired. The promise stays pending, and the later timeout cannot recover it by killing a child that has already exited. When a folder health check is waiting on that promise, service shutdown and backups can wait indefinitely.Register process errors, output capture, completion, timeout, and cancellation before ending stdin. Resolve on
closeso the result includes trailing output, and release deadline/abort resources on both completion and error. Keep the existing stdin EOF behavior and exit-code API.Timeout, abort, and stdin-error cleanup kill the direct child and destroy the captured stdout/stderr pipes, so a descendant that inherited them cannot hold completion open after cancellation. Normal completion captures trailing output; interrupted capture may be incomplete. A command that had already exited keeps its native exit status. The deadline still defaults to 30 seconds. With
timeout: nulland no abort, a descendant holding stdout/stderr (e.g.sh -c 'daemon &') prolongs completion until it closes those pipes; before this changeexecresolved on the command's own exit without trailing output.The branch is rebased onto current
masterand uses master'scommandOptions/JSON environment transport. The changelog fragment usesrelease-notes: false, at the maintainer's request. The SDK version is bumped to 4.1.1 (with the package template pin), as the changelog version check requires after the 4.1.0 release.The failure was reproduced with SDK 3.1.0/3.1.1 on StartOS 0.4.0.2 and Node 20.19.2: child exit preceded the stdin callback and SDK exit-listener registration.
Final-head verification (rebased head, Linux,
helix-build):HealthDaemon.term()waiting on fast commands), master's environment/stdin/abort tests, and deadline/abort regressions for an exited command whose output pipes a descendant still holds. These tests mock process creation; live descendant-process behavior on StartOS was not exercised on this head.changelog.mjs validate projects/start-sdk.Earlier evidence from the original contributor patch (before the master integration and the output-pipe cleanup):
Suggested labels:
StartSDK,patch.Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
Helix-Identity: helix-b