Skip to content

RPC mode: resuming an existing session on Windows crashes with libuv assertion (0xC0000409) during shutdown #9507

Closed as not planned

Description

@buyi1net

What happened?

On Windows, pi in RPC mode exits with 3221226505 (0xC0000409) instead of 0, ~20–40 ms after agent_settled, even though the turn completed and the session JSONL was fully written. stderr:

Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 94

Reproduced 4/5 resume runs using an ordinary auto-exit extension. This looks like the known Node.js bug nodejs/node#56645, fixed by nodejs/node#61999 ("Ignore PostDelayedTask after Stop"): the fix is not in Node v24.19.0 but is in v24.20.0+ (v24.20.0 changelog lists PR #61999). pi's RPC host shutdown calls process.exit(exitCode) right after runtimeHost.dispose(); on Node v24.19.0 that can hit the assertion. Same class as the #5805 workaround for pi update --self (return from main() and let Node drain instead of immediate process.exit(0)).

Environment: Windows 11 Pro, version 10.0.26200 (build 26200); Node v24.19.0 (libuv 1.52.1); pi 0.85.1 (npm global install); Git Bash, headless spawn.

Steps to reproduce

  1. Save autoexit.ts (all it does is shut the RPC process down after the turn):
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) {
  pi.on("agent_end", (_e, ctx) => { ctx.shutdown(); });
}
  1. Run pi --mode rpc --model <model> --session <existing-session.jsonl> -e autoexit.ts.
  2. Send {"id":"1","type":"prompt","message":"say hi"} on stdin and wait for agent_settled; the process exits on its own.

Expected behavior: exit code 0.

Actual: exit code 3221226505; assertion above on stderr, ~20–40 ms after agent_settled; the session file already contains the final assistant message at crash time.

Evidence

  • One raw run: agent_settled at t+2574 ms → assertion at t+2598 ms → exit 3221226505.
  • Node v24.19.0: 4/5 resume runs crashed with the minimal extension. Node v24.21.0: 0/8 crashes with the identical repro.
  • v24.21.0's src/node_platform.cc contains the #61999 guard (if (has_shut_down_) return; in PostDelayedTask); v24.19.0 does not.
  • Not extension-caused beyond triggering pi's own shutdown: the repro extension contains no third-party code, and both RPC exit paths reach the same shutdown() → process.exit() (the ctx.shutdown() flag is consumed on agent_settled; stdin end calls the same shutdown).
  • Without any extension I could not trigger it in 16 EOF runs today, but earlier runs on this machine (same pi/Node) crashed on EOF too; the timing window is narrow and an auto-exit hook hits it consistently.

Version: pi 0.85.1

Impact: on Node v24.19 (LTS at the time) a Windows RPC session that shuts down via auto-exit/EOF can be reported to orchestrators as a crashed child despite a completed turn; resume is the common path for sub-agent-style usage.

Related: #5805 (closed) · nodejs/node#56645 · nodejs/node#61999 (merged 2026-07-24, backported in Node v24.20.0)

AI disclosure: filed by an automated agent on behalf of a user; every measurement above comes from local runs with the repro shown.

Activity

  1. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    This issue was auto-closed. All issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues daily and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.

    If a maintainer replies lgtmi on one of your issues, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open. The command must be at the start of the reply (optionally after one or more @username mentions) or at the end.

    See CONTRIBUTING.md.

  2. added
    untriagedThis issue has been auto closed and has not been triaged
    on Sep 11, 2026
  3. added
    no-actionThis issue has been rejected after triage
    and removed
    untriagedThis issue has been auto closed and has not been triaged
    on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    no-actionThis issue has been rejected after triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions