Repository navigation
Conversation
Release a oneshot's SubContainer hold in Daemon.runLoop() once the process exits cleanly, instead of holding the container alive until stop() or term() runs. releaseHold() clears releaseSubcontainerHold before awaiting the release callback and is shared by both runLoop() and stop(). On a concurrent stop(), stop() clears onExitFns and awaits loop.done (waiting for any in-flight hold release to complete); checking signal.aborted right after await this.releaseHold() keeps exitedSuccess false and prevents any onExit callback registered after an un-awaited stop() from firing. Fixes Start9Labs#4632
…hot-releases-subcontainer-hold # Conflicts: # projects/start-sdk/lib/test/DaemonLifecycle.test.ts
|
Reviewed, looks good to merge.
|
helix-white
left a comment
There was a problem hiding this comment.
Approved on code review at bc3cd5521872dcca19f926015ac23019c44d50d9. No correctness findings; git merge-tree confirms a clean merge with current master.
A successful oneshot releases its subcontainer hold without requesting destruction. This fixes direct callers that share a subcontainer with another daemon; the reconciler already restarts shared peers together. Failed retries and ordinary daemons retain their holds. The existing stop-path release operation is shared rather than duplicated, and stopping during an asynchronous release still drains the loop and suppresses exit callbacks.
As Matt noted, success callbacks now wait for any destruction triggered by the final hold release. In that pending-destruction case, dependent readiness waits for filesystem teardown. This is not a blocker to the fix.
Implementation diff: +15 / −9 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
Verification evidence: The author records passing full SDK/core TypeScript suites, typecheck, bundle, formatting, and five failing negative controls on Linux x86_64 with Node 24.22.3 at c428aabf6; the daemon implementation is unchanged in the merge head. Matt additionally reports 36/36 lifecycle tests passing. I did not run builds or tests. Live StartOS/LXC execution was not covered.
CI still needs workflow approval: Current-head Automated Tests and Build Products runs report action_required; the successful metadata check does not establish test success. The open #4853 also edits the lifecycle tests, so the second merge may require conflict resolution.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
@dr-bonez A completed oneshot must remain restartable when its dependency recovers. I traced that path again; releasing the hold does not itself destroy the subcontainer:
The PR's An explicit teardown of a sharing consumer is different: it can request destruction, and this PR allows that pending request to complete after the oneshot exits. Reusing that destroyed handle is not supported; the dynamic reconciler replaces all sharing peers together with fresh handles. Ordinary dependency crashes/exits do not take that teardown path, so I do not find a rerun regression there. |
|
@dr-bonez You are right that GC cleanup is another destruction path: However, the last hold is not the last JavaScript reference. The live daemon chain retains GC cleanup applies after the owning objects become unreachable, not merely when the hold count reaches zero. The dependency pause/resume path keeps those objects reachable. This conclusion is from the reference graph and finalizer code, not from a GC test run. |
Problem
Daemon.start()takes aSubContainerhold (Daemon.ts:131) thatrunLoop()never releases on clean oneshot exit (Daemon.ts:174). Shared-volumes PR #4485 (34e0813) already resolves theDaemons.dynamicsymptom onmasterby restarting shared peers together;Daemon.tsstill leaks the hold for direct callers. Fixes #4632.Change
Daemon.ts: extractreleaseHold()forstop()and clean oneshot exit (success && this.oneshot) with a post-awaitsignal.abortedguard; failed retries and non-oneshot daemons keep holds; clean exit does not calldestroy().DaemonLifecycle.test.ts: 5 regression tests + 1 non-oneshot guard; patch changelog fragment.Verification
AI agents ran every check below.
Setup. Linux x86_64, Node v24.22.3, compiled
@start9labs/start-sdkdist/.Steps. Spawn child-process
Oneshoton sharedSubContainerEager→ exit 0 → startDaemon→daemon.term()→oneshot.term().Before (e914710):
After (c428aab):
Negative control (e914710):
5 failed, 30 passed. Candidate c428aab: SDK checks,format-check,check-version,merge-treepassed.Changed files, negative control, and candidate check details
Changed files:
projects/start-sdk/lib/mainFn/Daemon.tsprojects/start-sdk/lib/test/DaemonLifecycle.test.tsprojects/start-sdk/changelog/patch-fixed-oneshot-subcontainer-hold.mdNegative control (e914710
Daemon.ts+ newDaemonLifecycle.test.ts):Candidate c428aab:
make -C projects/start-sdk check(tsc --noEmit): exit 0.make -C projects/start-sdk bundle: exit 0.npx jest --detectOpenHandles lib/test/DaemonLifecycle.test.ts: 35/35 passed, 0 open handles (exit 0).make start-sdk-test:@start9labs/start-core(TS) 39 suites / 542 tests;start-sdk63/63 script tests + 32 Jest suites / 422 tests;test-rpc-docs.cjs2/2 (exit 0).make -C projects/start-sdk check-fmtandmake format-check(rustfmt, prettier, taplo): exit 0.node scripts/changelog.mjs check-version projects/start-sdk: exit 0 (5.0.0).git merge-tree --write-tree origin/master HEADvs e914710: clean treecb15384c471effe5078b395bd2b1d21d9412dbd3(exit 0).Links
projects/start-sdk/lib/test/DaemonLifecycle.test.tsNot shown
start-cli package attachin LXC (verified on compiled SDK in Node).start-core-test,start-os-scripts-test(N/A;start-sdkonly); PR CI (test.yaml, post-open).model: gemini-4-neon
Generated with Gemini 4 Neon in T3 Code Nightly
review effort: 'xhigh'