Repository navigation
agentHost: stop the Copilot runtime before deleting quick chat test homes - #342267
Merged
Alexandru Dima (alexdima) merged 2 commits intoOct 17, 2026
Merged
Conversation
…omes The quick chat scratch directory tests run a real CopilotAgent whose Copilot runtime uses <tmp userHome>/.copilot as COPILOT_HOME. Since the Copilot SDK bump to 1.0.23-preview.5 (#342210) the runtime writes into .copilot/logs while the test's finally block removes the temp home, so fs.rm fails with ENOTEMPTY. The throw also skipped disposeAgent, leaking the model refresh retry timer into the leak checks of later, unrelated tests. Dispose the agent first so the runtime is stopped, then remove the temp home with retries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Temporary workflow overrides disable normal coverage, and the diagnostic runner ignores the intended suite filter.
2 open issues
What changed in this PR
Fixes quick chat test cleanup races by stopping the Copilot runtime before deleting temporary homes.
Changes:
- Reorders cleanup and adds removal retries in four tests.
- Temporarily replaces Linux and macOS test coverage with repeated diagnostic runs.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Disposes agents before removing temporary homes, with retries. |
.github/workflows/pr-linux-test.yml |
Adds a diagnostic loop and disables normal Linux test steps. |
.github/workflows/pr-darwin-test.yml |
Adds a diagnostic loop and disables normal macOS test steps. |
Review effort: Balanced
Alexandru Dima (alexdima)
force-pushed
the
alexdima/fix-quick-chat-scratch-enotempty
branch
from
October 17, 2026 12:31
a8bedcf to
1947bdb
Compare
Alexandru Dima (alexdima)
marked this pull request as ready for review
October 17, 2026 12:31
… test home Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Base:
|
Ladislau Szomoru (lszomoru)
approved these changes
Oct 17, 2026
Alexandru Dima (alexdima)
enabled auto-merge (squash)
October 17, 2026 13:01
Alexandru Dima (alexdima)
deleted the
alexdima/fix-quick-chat-scratch-enotempty
branch
October 17, 2026 13:18
Alexandru Dima (alexdima)
added a commit
that referenced
this pull request
Oct 17, 2026
… Host tmpfs (#342277) * agentHost: kill the Codex app-server's process tree on Linux The Linux / Electron job of #342267 passed every Agent Host E2E suite but failed to unmount the test tmpfs. The holder was an orphaned Codex filesystem helper (`bwrap --die-with-parent ... --codex-run-as-fs-helper`, PPID 1, still in its launcher's process group with its pre-exec argv) from the Codex server-tools artifact test. Codex spawns that helper without a parent-death signal or kill-on-drop, and the Agent Host stopped the app-server by SIGKILLing only its PID. The bubblewrap launcher then dies with its parent, but a sandbox child it has just cloned waits on an eventfd that never reports the launcher's death and only installs its own PR_SET_PDEATHSIG after that wait, so it blocks forever. On Linux, freeze the app-server with SIGSTOP (so it can neither exit on the stdin EOF that client.dispose() just queued nor launch another helper), then kill its tree depth-first with killTree, which stops each helper while its parent chain is still intact. Other platforms keep the plain SIGKILL. Also skip fuser's "kernel" token when describing tmpfs holders, and document the failure mode in KNOWN_ISSUES.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: freeze and kill the Codex app-server tree synchronously Addresses review feedback on the async killTree approach: - SIGSTOP froze only the app-server. terminateProcess.sh lists a process's children before killing it, so a running bubblewrap launcher could still clone a sandbox child after that listing and strand it. - The walk was asynchronous, so the client's two-second grace-period SIGKILL could kill the app-server, and with it the parent-bound launchers, before their children were found. - The client was disposed (stdin closed) before the app-server was frozen. killLinuxProcessTree now stops each process and waits, with a shared 100 ms cap, until /proc reports it stopped (SIGSTOP is delivered asynchronously, so a process inside clone() finishes it first) before enumerating its children. It then kills every stopped process deepest first. The walk is synchronous, so nothing else can interleave and an exiting Agent Host cannot cut it short after freezing processes. CodexAgent runs it before disposing the client on both teardown paths, and falls back to a PID-only SIGKILL elsewhere or when /proc is unreadable. Tests cover the stop-before-enumerate order, a child cloned while its parent is still stopping, the stop deadline, an unreadable process table, stat parsing, and (on Linux) a real three-level process tree. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * base: move the freezing tree kill next to killTree as freezeAndKillTree Moves the Linux tree kill from agentHost/node/codex/linuxProcessTree.ts into base/node/processes.ts as freezeAndKillTree, next to killTree, and documents how the two differ: killTree signals an asynchronous snapshot of the tree on every platform and is best-effort, while freezeAndKillTree freezes the tree before killing it so no descendant can be created unseen or outlive its parent. It now reads the parent and state from the labelled `PPid:` and `State:` lines of /proc/<pid>/status rather than positional /proc/<pid>/stat fields after the parenthesized command name. Tests move to base/test/node/processes/processes.test.ts. A process-group kill would avoid walking /proc, but does not reach the leaked process: Codex's Linux sandbox launcher places bubblewrap in its own process group (setpgid(0, 0) in linux_run_main.rs). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: link the upstream bubblewrap issue for orphaned sandbox children Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: return to killTree for the Codex app-server Reverts the freezing /proc walk (freezeAndKillTree) in favour of the original SIGSTOP + killTree approach: it adds a large Linux-only utility next to killTree rather than improving the one the product already uses everywhere. Keeps the link to the upstream bubblewrap issue. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: reap orphaned Codex sandbox helpers before unmounting the Agent Host tmpfs The orphaned Codex filesystem helper that keeps the Agent Host test tmpfs busy is stranded mid-session, while its Agent Host server and app-server are still running: the holder's age dates its clone several seconds before that server's shutdown. It is reparented to PID 1 before any teardown, so killing the app-server's process tree cannot reach it. This PR's own run on the SIGSTOP + killTree change still hit the failure. Drop that product change. In tmpfs.sh, when the unmount fails and every holder is an orphaned Codex filesystem helper (parent PID 1 and --codex-run-as-fs-helper on its command line), describe and kill each one, report a GitHub Actions warning, and retry the unmount. Any other holder, or an unmount that still fails, remains fatal with the existing diagnostics. Document the mid-session mechanism, its impact (13 failed PR runs between 2026-10-07 and 2026-10-17), and the upstream issues (openai/codex#54877, containers/bubblewrap#633). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: cover reaping orphaned Codex sandbox helpers in the storage wrapper tests The storage wrapper test snapshots the commands tmpfs.sh runs after a failed unmount; it now also expects the orphaned Codex helper probe, which stops at the first holder that is not one. Make the stub ps answer per field, and add a test in which the only holder is an orphaned Codex filesystem helper: it is described and killed, a warning is emitted, and the retried unmount succeeds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes the
Electron-Unitfailures on many unrelated PRs since 2026-10-17 00:16 UTC (e.g. #342262, #342256, #342220, #341230, #342229, #342246, #342249).Failure
Failures 2–4 are a cascade into whichever suite runs next (
CopilotAgentSession,claudeSessionCustomizationDiscovery, ...).Cause
These tests create a
CopilotAgentwith a tempuserHome. In the ones that callauthenticatewithout a fake client, the real Copilot runtime starts withCOPILOT_HOME=<tmp userHome>/.copilotand keeps writing there (.copilot/logsin the failing logs). Eachfinallycalledfs.rm(userHome)beforedisposeAgent(agent). The rm raced those writes and threwENOTEMPTY, sodisposeAgentnever ran, and the agent's model refresh retry timer leaked into the next test's leak check.It started with the Copilot SDK bump to 1.0.23-preview.5 (#342210, merged 00:14:57 UTC; first failing run created 00:16:48 UTC). I didn't confirm which SDK change introduced the writes. Seen 9 times in about 12 hours on Linux, macOS, and Windows.
Fix
In
copilotAgent.test.ts, swap the cleanup order to dispose the agent (stopping the runtime) before removing the temp home, and remove it withmaxRetries: 5. Five call sites:createChat infers workspace-less from an omitted workingDirectory and uses a stable scratch dirquick chat scratch directory›does not discover workspace customizations from scratchquick chat scratch directory›session teardown cleans up the quick chat scratch dirquick chat scratch directory›resume recreates a reaped quick chat scratch dir(uses a fake client; changed for consistency)scratchReclaimAfterPeerDisposalhelper used by the scratch reclaim testsOther tests in the file with the same order never call
authenticate, so no runtime starts and they are left alone.Validation
A temporary commit (dropped before review) ran
npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --grep "quick chat scratch directory"in a 100x fail-fast loop.--grepdid not narrow the run, so each attempt ran the wholecopilotAgent.test.tsfile.ENOTEMPTY+ leak.npm run test-node(full suite) passed.session teardowntest) was added afterwards and is covered only by this PR's regular CI.Not run locally (no
node_modulesin the worktree).