Skip to content

fix(sdk): stop a health check without waiting for its in-flight ready.fn - #4855

Merged
dr-bonez merged 1 commit into
masterfrom
fix/sdk-bounded-shutdown
Nov 21, 2026
Merged

dr-bonez merged 1 commit into
masterfrom
fix/sdk-bounded-shutdown

Conversation

@helix-red

@helix-red helix-red commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem

HealthDaemon.stopSession() waited for the health check that was already running (ready.fn) before a stop or a pause could continue. That's pointless, because an aborted session throws the result away. It's also dangerous: if the check is stuck in a call that never returns, its daemon never gets SIGTERM, and neither does any daemon it requires.

That is the likely cause of a bitcoind stop that needed a force stop. After the stop began, bitcoind kept syncing blocks for more than eight minutes and never received SIGTERM. Its health checks run bitcoin-cli through SDK 4.1.0's exec. That exec waits for stdin to close before it attaches the exit listener or starts the 30 s kill timer, so a fast-exiting command can hang it forever. #4537 fixed that on master after 4.1.0 was tagged.

Change

  • Stopping no longer waits. A stop or pause aborts the health session and continues right away; it no longer waits for the in-flight ready.fn.
  • ready.fn gets an AbortSignal. It aborts when the check stops, so the check's own work can be cancelled rather than left running.
  • exec accepts the signal. SubContainer.exec's abort option now takes an AbortSignal as well as an AbortController, so a check can pass its signal straight through.
  • Docs and changelog. One paragraph in the packaging guide (main.md) and a changelog fragment.

Verification

Run through helix-build, from projects/start-sdk:

  • make check (tsc) passes, and make fmt plus prettier on the changed Markdown are clean.
  • npx jest: 418/418.
  • node --test tests/*.test.mjs: 63/63.

New test in DaemonLifecycle.test.ts: when a ready.fn never resolves, term() still terminates the daemon and aborts the check's signal. Against master's HealthDaemon the same test fails with hung.

exec.stdin.test.ts now covers killing a command through either an AbortController or an AbortSignal.

Not verified on a live StartOS box.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

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
@helix-red
helix-red force-pushed the fix/sdk-bounded-shutdown branch from 5cdaa43 to 48fc61d Compare November 21, 2026 19:35
@helix-red helix-red changed the title fix(sdk): bound daemon shutdown so one stuck step cannot hang a service stop fix(sdk): stop a health check without waiting for its in-flight ready.fn Nov 21, 2026
@dr-bonez
dr-bonez merged commit bf3c13a into master Nov 21, 2026
27 checks passed
@dr-bonez
dr-bonez deleted the fix/sdk-bounded-shutdown branch November 21, 2026 19:38

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 48fc61df443cb8283491ff900368dbc2763c7076; it merges cleanly with current master.

The narrowed change resolves both concerns from the initial deadline-based draft: a dependency pause no longer loses its configured drain budget, and reconciliation no longer abandons pending command startup to launch a replacement. Those concerns were caused by the removed deadlines; no additional proposal is needed.

Checked stop/pause transition serialization, aborted-session result and exit-callback guards, dependency-ordered teardown, and exec cancellation/listener cleanup for both controllers and signals. No remaining correctness findings in this diff.

Code-only review; no builds or tests run. The revised head's SDK, Runtime & Script Tests check passes; other CI jobs remain pending.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

helix-red pushed a commit that referenced this pull request Nov 24, 2026
Since #4855, HealthDaemon.term() returns without awaiting an in-flight
ready.fn. "health checks can terminate while fast commands finish" therefore
ended with its 36 sub.exec calls still waiting on readFile. They spawned
after the next test pointed the cp.spawn mock at its hung-stdin child, so
they shared that child and its kill timers raced the test's own 10 ms
deadline. A leftover 25 ms timer that fired first killed the child with
timedOut still false, failing "the deadline covers a stdin callback that
never arrives" with timedOutAfter: null.

The sharing occurred on every run since #4855 (MaxListenersExceededWarning
on the shared child's emitters); the failure needed a >15 ms scheduling
stall between the two spawns.

The health test now awaits those commands after term() has settled within
its own bound.

(cherry picked from commit 2cf57f3)
(cherry picked from commit d1a9ad2)
Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
dr-bonez pushed a commit that referenced this pull request Nov 24, 2026
…hile a selection change is in flight (#4921)

* fix(patch-db): keep array positions and serialize selection updates while a selection change is in flight

Revisions that precede a selection change's extension still carry the
previous projection. Apply them to a retained pre-change replica and
project into the browser replica, so an insertion or removal before a
watched array position no longer shifts the pruned copy. Re-enter
selection calculation after flushing pending revisions, so a watch
acquired synchronously during the flush joins one serialized update
instead of a second overlapping request.

Proposed by helix-white in review of #4898.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

* test(sdk): settle health-check commands before the next exec test starts

Since #4855, HealthDaemon.term() returns without awaiting an in-flight
ready.fn. "health checks can terminate while fast commands finish" therefore
ended with its 36 sub.exec calls still waiting on readFile. They spawned
after the next test pointed the cp.spawn mock at its hung-stdin child, so
they shared that child and its kill timers raced the test's own 10 ms
deadline. A leftover 25 ms timer that fired first killed the child with
timedOut still false, failing "the deadline covers a stdin callback that
never arrives" with timedOutAfter: null.

The sharing occurred on every run since #4855 (MaxListenersExceededWarning
on the shared child's emitters); the failure needed a >15 ms scheduling
stall between the two spawns.

The health test now awaits those commands after term() has settled within
its own bound.

(cherry picked from commit 2cf57f3)
(cherry picked from commit d1a9ad2)
Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

---------

Co-authored-by: helix-white <267227783+helix-a@users.noreply.github.com>
Co-authored-by: Shadowy Super Coder <RustyShackleford311@protonmail.com>
only21mil pushed a commit to only21mil/start-technologies that referenced this pull request Nov 25, 2026
Since Start9Labs#4855, HealthDaemon.term() returns without awaiting an in-flight
ready.fn. "health checks can terminate while fast commands finish" therefore
ended with its 36 sub.exec calls still waiting on readFile. They spawned
after the next test pointed the cp.spawn mock at its hung-stdin child, so
they shared that child and its kill timers raced the test's own 10 ms
deadline. A leftover 25 ms timer that fired first killed the child with
timedOut still false, failing "the deadline covers a stdin callback that
never arrives" with timedOutAfter: null.

The sharing occurred on every run since Start9Labs#4855 (MaxListenersExceededWarning
on the shared child's emitters); the failure needed a >15 ms scheduling
stall between the two spawns.

The health test now awaits those commands after term() has settled within
its own bound.

(cherry picked from commit 2cf57f3)
Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants