Skip to content

[Bug]: Linux: ACP process-tree teardown fails, and poisons the session, when a process exits during the /proc scan #36707

Closed

Description

@yaacovcorcos

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server (the ACP runtime in packages/provider-acp)

Steps to reproduce

  1. On Linux, run an ACP agent whose runtime uses the process-tree teardown (not a cgroup lease).
  2. Stop it while one of its processes is exiting.
  3. makeLinuxProcessTreeController().snapshot in packages/provider-acp/src/server/AcpSessionRuntime.ts calls readdirSync("/proc", { withFileTypes: true }). For an entry whose type is unknown, Node falls back to lstat. If that process has exited in the meantime, the ENOENT aborts the whole snapshot, before readLinuxProcessIdentity (which already skips a process that has gone) is reached.

It is intermittent, since a process has to exit inside that window. A unit test that makes the withFileTypes read throw, as Node does for a vanished entry, reproduces it deterministically.

Expected behavior

The snapshot returns the processes still running and ignores the one that exited, and Stop completes.

Actual behavior

Teardown fails with ProviderAdapterProtocolError: … ACP runtime process-group teardown failed; the session is poisoned, and the session cannot be used afterwards.

Impact

Minor bug or occasional failure

Version or commit

main @ ead133c (the code is unchanged there)

Environment

Seen in a downstream fork's CI: GitHub-hosted Ubuntu 24.04, Node 26.12.1, in a Stop test for an ACP agent the fork adds on this same runtime. This affects ACP runtimes that use the Linux process-tree fallback; cgroup teardown bypasses this snapshot. macOS and Windows use other controllers and are not affected.

Logs or stack traces

ProviderAdapterProtocolError: … ACP runtime process-group teardown failed; the session is poisoned
Caused by: Error: ENOENT: no such file or directory, lstat '/proc/4563'
    at Object.lstatSync (node:fs:2153:25)
    at getDirent (node:internal/fs/utils:325:32)
    at getDirents (node:internal/fs/utils:297:18)
    at Proxy.readdirSync (node:fs:1962:58)
    at Object.snapshot (packages/provider-acp/src/server/AcpSessionRuntime.ts)
    at snapshot (packages/provider-acp/src/server/AcpSessionRuntime.ts)
    at signalPhase (packages/provider-acp/src/server/AcpSessionRuntime.ts)

The same run also logged ENOENT … lstat '/proc/5457' from the same snapshot call in another case.

Workaround

None in the app; the session has to be restarted.

A fix (list /proc by name and keep numeric entries) is ready on yaacovcorcos:fix/acp-proc-snapshot-race and will follow as a PR when I have a free PR slot.

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 labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions