Skip to content

Avoid shell kill cwd cleanup flakes#1207

Merged
stephentoub merged 6 commits into
mainfrom
stephentoub/root-cause-ci
May 5, 2026
Merged

Avoid shell kill cwd cleanup flakes#1207
stephentoub merged 6 commits into
mainfrom
stephentoub/root-cause-ci

Conversation

@stephentoub
Copy link
Copy Markdown
Collaborator

The Windows .NET E2E failure was caused by a long-running shell-kill test command inheriting the disposable fixture workspace as its current directory. If the shell wrapper was killed but a child process briefly survived, Windows could keep copilot-test-work-* locked and fail cleanup.

This updates the shell-kill E2E tests across .NET, Node, Go, and Python to run the long-lived command from the system temp directory instead of the fixture workspace. The tests still exercise session.shell.kill, but a surviving child process can no longer block deletion of the per-test workspace.

Validation:

  • dotnet test dotnet\test\GitHub.Copilot.SDK.Test.csproj --filter FullyQualifiedName~RpcShellAndFleetE2ETests.Should_Kill_Shell_Process -v n
  • cd nodejs && npm test -- --run test/e2e/rpc_shell_and_fleet.e2e.test.ts -t "should kill shell process"
  • cd go && go test ./internal/e2e -run TestRpcShellAndFleetE2E/should_kill_shell_process -count=1
  • python -m pytest python\e2e\test_rpc_shell_and_fleet_e2e.py::TestRpcShellAndFleet::test_should_kill_shell_process
  • cd nodejs && npm exec prettier -- --check test/e2e/rpc_shell_and_fleet.e2e.test.ts
  • python -m ruff format python\e2e\test_rpc_shell_and_fleet_e2e.py --check

@stephentoub stephentoub requested a review from a team as a code owner May 5, 2026 18:49
Copilot AI review requested due to automatic review settings May 5, 2026 18:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the cross-SDK session.shell.kill E2E coverage by preventing long-lived shell commands from running inside disposable per-test workspaces. That fits the repo’s shared goal of keeping language SDK tests aligned while avoiding platform-specific flakiness in the common shell RPC surface.

Changes:

  • Updated the .NET, Node, Go, and Python shell-kill E2E tests to run the long-lived command from the system temp directory.
  • Preserved the existing session.shell.kill behavior under test while avoiding Windows cleanup failures caused by lingering cwd handles.
  • Added clarifying comments in each test explaining the Windows-specific cleanup rationale.
Show a summary per file
File Description
python/e2e/test_rpc_shell_and_fleet_e2e.py Uses tempfile.gettempdir() for the shell-kill test command cwd.
nodejs/test/e2e/rpc_shell_and_fleet.e2e.test.ts Uses os.tmpdir() for the shell-kill test command cwd.
go/internal/e2e/rpc_shell_and_fleet_e2e_test.go Uses os.TempDir() for the shell-kill test command cwd.
dotnet/test/E2E/RpcShellAndFleetE2ETests.cs Uses Path.GetTempPath() for the shell-kill test command cwd.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

stephentoub and others added 3 commits May 5, 2026 15:18
Run the long-lived shell kill command outside the fixture workspace so a surviving Windows child process cannot hold copilot-test-work-* open during cleanup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run mirrored long-lived shell kill E2E commands outside each fixture workspace so surviving Windows child processes cannot block temp workspace cleanup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When stdio startup fails quickly, wait briefly for the stderr reader before formatting the connection-lost exception so CLI argument errors are reported deterministically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@stephentoub stephentoub force-pushed the stephentoub/root-cause-ci branch from 72ac35f to 344b18f Compare May 5, 2026 19:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Cross-SDK Consistency Review ✅

This PR makes two types of changes and both are handled consistently across all four SDKs.

1. E2E Test Fix (all 4 SDKs — consistent ✅)

The shell-kill test fix (cwd: tempdir) is applied uniformly across all four SDKs:

SDK File Change
.NET dotnet/test/E2E/RpcShellAndFleetE2ETests.cs cwd: Path.GetTempPath()
Go go/internal/e2e/rpc_shell_and_fleet_e2e_test.go Cwd: &cwd (os.TempDir())
Node.js nodejs/test/e2e/rpc_shell_and_fleet.e2e.test.ts cwd: os.tmpdir()
Python python/e2e/test_rpc_shell_and_fleet_e2e.py cwd=tempfile.gettempdir()

2. .NET Client Stderr Race Fix (internal implementation — no cross-SDK gap ✅)

The dotnet/src/Client.cs change improves stderr capture when a ConnectionLostException occurs by waiting up to 250 ms for the stderr reader task to flush. This is an internal implementation detail, and the other SDKs already have equivalent mechanisms:

  • Node.js — uses a 50 ms setTimeout delay in processExitPromise (raced against RPC calls) before reading stderrBuffer
  • Python — has a background _stderr_thread that continuously reads stderr into _stderr_output; the loop already handles the read-after-exit case
  • Go — does not capture stderr in its client at all (uses a different error signaling model via a processDone channel), so this fix has no counterpart to add

The .NET change brings its stderr-race behavior in line with what Node.js already does via the setTimeout approach — both now give the subprocess a brief window to fully flush stderr before the error message is composed. No equivalent changes are needed in the other SDKs.

No consistency issues identified. 🎉

Generated by SDK Consistency Review Agent for issue #1207 · ● 669K ·

stephentoub and others added 3 commits May 5, 2026 15:41
@github-actions github-actions Bot mentioned this pull request May 5, 2026
@stephentoub stephentoub merged commit 1832d0a into main May 5, 2026
37 of 38 checks passed
@stephentoub stephentoub deleted the stephentoub/root-cause-ci branch May 5, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants