Repository navigation
Description
Summary
Two owned Runtime Host lifecycle tests fail intermittently on a clean current main checkout, including during focused repetitions. Both tests assert that an owned process exits after its controlling lifetime ends.
The failures are nondeterministic: the same exact revision can pass, then fail on a later run without any source or environment change.
Environment
- Commit:
4ed6255f2998eff93414491cb14305f3bca0884b(main) - OS: macOS 26.5.2, arm64
- Node.js:
v24.19.0 - npm:
11.17.0 - Fresh detached worktree with a clean Git status
npm ci: passednpm run build --workspace @maka/runtime-host: passed
Reproduction
Run the complete Runtime Host suite repeatedly:
npm run test:dist --workspace @maka/runtime-hostThen repeat the affected tests directly:
node --test \
--test-name-pattern="an authority-supervised Candidate exits" \
packages/runtime-host/dist/__tests__/host-kernel.test.js
node --test \
--test-name-pattern="owned Host exits promptly after its first connection closes" \
packages/runtime-host/dist/__tests__/owned-candidate.test.jsA serial full-suite control was also run with:
npm run test:dist --workspace @maka/runtime-host -- --test-concurrency=1Results
| Test mode | Result |
|---|---|
| Default-concurrency complete Runtime Host suite | 2 passed / 3 failed across 5 runs |
| Focused authority-supervised Candidate exit test | 8 passed / 2 failed across 10 runs |
| Focused owned Host first-disconnect exit test | 9 passed / 1 failed across 10 runs |
| Serial complete Runtime Host suite | 3 passed / 0 failed across 3 runs |
The complete suite contains 1,687 tests: a green run reports 1,675 passed, 12 skipped, and 0 failed.
The default-concurrency failures moved between runs:
- Runs 2–4 failed
an authority-supervised Candidate exits if its launch owner is killed. - Runs 3–4 also failed
owned Host exits promptly after its first connection closes.
The focused Candidate failure reports:
Error: process <pid> did not exit
The focused owned Host failure reaches its exit assertion with:
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
false !== true
No process launched from the test worktree remained after the runs completed.
Impact
Unrelated pull requests can receive a blocking red Runtime Host result without modifying Runtime Host code. Because focused repetitions can also fail, this is not solely a full-suite concurrency artifact, although concurrent suite load appears to increase its frequency.
Related work
- test(runtime-host): investigate owned candidate connection flake #3190 recorded the earlier
owned Host exits promptly after its first connection closesflake. - fix(runtime-host): give owned-candidate connect a CI-safe election window #3221 was merged to give that specific owned-candidate connection path a CI-safe election window.
The current reproduction also covers the authority-supervised Candidate owner-death boundary, for which no matching Issue or PR was found.
Suggested investigation
- Determine whether the owned processes actually remain alive or whether the tests observe lifecycle state before settlement.
- Replace wall-clock timing assumptions with explicit lifecycle synchronization where practical.
- Preserve the existing ownership and process-exit assertions; avoid resolving the flake only through retries or weaker assertions.
- Verify any fix with repeated focused, default-concurrency, and serial suite runs.
Expected outcome
The affected tests deterministically observe the required process exit, and complete Runtime Host runs no longer fail because of scheduler-dependent lifecycle settlement.
AI assistance: OpenAI Codex assisted with reproduction, test triage, duplicate searching, and drafting this issue. The evidence and issue text were reviewed by me.
Activity
UncertaintyDeterminesYou4ndMe commentedon Sep 4, 2026
I looked into this and closed my PR (#4784) to keep review load down while the project is slimming. Leaving the findings here so they are not lost.
connected.connection.closed, which is the Client's own transport: the Client aborts it after a 2 s unanswered liveness probe, so it resolves while a busy Host is still running. The owner-loss close is also only armed after composition startup and recovery settle (launchOwnerGuard.bindruns afterstartExecutionRuntimeHostCandidateresolves), andretryConnectconnects while the Host is stillrecovering, so the SIGKILL lands mid-startup.shutdownGraceMs(10 s);settlethen SIGKILLs and reports an unclean exit.ggbdpq commentedon Sep 4, 2026
take
sunrioa commentedon Sep 7, 2026
Additional evidence that may be useful for #4814:
While investigating the failures encountered during validation of #4994, I reproduced the authority-supervised Candidate exit failure on main at
f4abd4918(macOS, Node 24.19.0, Undici 8.10.1), with lifecycle and socket instrumentation.In this occurrence, composition recovery and shutdown had already completed.
host.closedresolved, but the process remained alive for more than five seconds with an active TLS connection tomodels.dev, initiated by the startup model-metadata refresh. The process was in stateS, not a zombie, when the test timed out and killed it.The observed path is:
transport.close().host.closed, keeping the Node process running.I also reproduced the transport behavior without external networking: a local TCP server accepts a connection but never completes the TLS handshake. After aborting the fetch,
transport.close()resolved at approximately 112 ms, while the clientTLSSocketwas still not destroyed at 5,614 ms.The other two lifecycle tests also showed a similar post-close TLS wait, but passed in this instrumented run. I therefore cannot attribute every historical failure to this path.
This appears distinct from the startup synchronization and shutdown-budget issues addressed by #4814. I have not tested its latest head, so this is not a claim that the PR still fails. It may be worth tracking the pending-connection cleanup separately: a longer process-exit budget can accommodate this delay without verifying that transport shutdown actually releases the socket.
sunrioa commentedon Sep 8, 2026
Additional validation: #4814 and main
I completed local validation of #4814 at
a0c4dbaaon macOS arm64 with Node.js 24.19.0. The results below also include earlier and recent control runs on unmodified main.Both tests directly changed by #4814 passed
Each of the following tests passed all 10 focused repetitions. Both also passed in two complete Runtime Host runs:
an authority-supervised Candidate exits if its launch owner is killedowned Host exits promptly after its first connection closesProblems observed on both #4814 and main
an invocation-owned detached Host retires after launcher natural exitprocess ... did not exit.f4abd4918: failed in 1 of 5 focused rounds.an exited owned Candidate permits one real successor in the same electionsettle(5000)assertion.e60e85d77: failed in 3 of 5 focused rounds.transport.close()returns.archived-only history boots into a usable new task5a1514c1d: all three focused repetitions failed with the same error.These problems occur on both #4814 and main, but I have not established whether they share a root cause.
Failure observed on #4814 without a main failure control
an invocation-owned detached Host retires after launcher crashThis failed in the complete two-file run and both complete Host runs on #4814, with
process ... did not exit. I do not yet have a corresponding main failure control, so whether it also fails on main remains unverified.Failure observed on main, but not in this #4814 validation
a launcher-owned detached Host exits when its launcher is killedThis previously failed in 2 of 5 focused rounds on main
e60e85d77. It did not fail in this #4814 validation.TLS experiment details
I reran the local transport experiment using the current #4814 build: a loopback TCP server accepts a connection but does not complete the TLS handshake; the experiment then aborts the fetch and awaits
transport.close().transport.close()returned while the client'sTLSSocket.destroyedwas stillfalse.The experiment requires no external network access. It checks whether the client socket has closed, rather than whether the entire diagnostic process has exited.
In short, the close function returned before the connection actually closed. This run only confirmed that the socket was still alive at approximately 5.6 seconds. It did not establish whether the socket would outlive #4814's new waiting deadlines, or whether this issue causes all the other Host exit failures.
Archive E2E failure
The archive-startup test failed at
apps/desktop/e2e/new-task-reload.spec.ts:34while callingsessions:archive:The complete Electron E2E run on #4814 reported 36 passed and 1 failed. All three subsequent focused repetitions of this test failed with the same error.
I then installed dependencies and rebuilt in a fresh, unmodified main checkout at
5a1514c1d. The target test file was identical to the version on #4814. With one worker, three repetitions, and zero retries, all three runs failed with the same error. The checkout remained clean afterward.This appears different from the issue recorded in #4785: here, the archive request is rejected because the Session still has a live derived effect; #4785 describes a race between WorkHub delegation and automatic Session titles. The test corresponding to #4785 passed in both complete Host runs in this validation, so this archive failure may need separate tracking.
Complete run results
host-kernelandowned-candidatefilesBuild, lint, formatting, typechecking, all 562 script tests, browser semantic smoke, alignment checks, Storybook rendering, CLI packaging and offline installation smoke, and the production dependency audit all passed.
These are local observations from the same Mac, not independent cross-machine reproductions.
AI assistance: OpenAI Codex assisted with executing the validation, organizing the evidence, and drafting this comment. I reviewed the content.
test(runtime-host): bound owned-Host lifecycle tests to kernel contra…
test(runtime-host): bound owned-Host lifecycle tests to kernel contra…