Skip to content

Avoid Windows in-process test teardown deadlock#1997

Merged
stephentoub merged 9 commits into
mainfrom
stephentoub-fix-flaky-node-tests
Jul 16, 2026
Merged

Avoid Windows in-process test teardown deadlock#1997
stephentoub merged 9 commits into
mainfrom
stephentoub-fix-flaky-node-tests

Conversation

@stephentoub

Copy link
Copy Markdown
Collaborator

Windows in-process E2E workers can retain the runtime's session.db lock until the Vitest worker exits. The existing 30-second cleanup retry runs from that worker's afterAll hook, so it prevents the exit needed to release the lock and eventually hits the hook timeout.

Limit the COPILOT_HOME deletion to one attempt specifically for Windows in-process tests. If the database is still locked, the existing warning and OS-cleanup path handles it, while other platforms and subprocess transports retain their retries because those locks can be released independently.

Validation:

  • Full Node.js test matrix passed across all platforms and transports.
  • Windows in-process test job passed three consecutive runs.

Generated by Copilot

stephentoub and others added 9 commits July 15, 2026 17:04
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Do not retry removal of the in-process runtime's session home while its Vitest worker still owns a locked session database. Retrying until the hook timeout prevents the worker from exiting and releasing the lock.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6e902b9a-5527-4a32-a5a3-e0bf5bfef3f7
@stephentoub
stephentoub requested a review from a team as a code owner July 16, 2026 00:58
Copilot AI review requested due to automatic review settings July 16, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts Node.js E2E harness teardown behavior to avoid a Windows-specific deadlock in Vitest workers when using the in-process (FFI) transport and the runtime keeps session.db locked until worker exit.

Changes:

  • Limit COPILOT_HOME temp directory deletion to a single attempt for Windows + in-process tests to avoid afterAll retry deadlock.
  • Extend the rmDir helper to accept a configurable maxTries, preserving existing retry behavior for other platforms/transports.
Show a summary per file
File Description
nodejs/test/e2e/harness/sdkTestContext.ts Make teardown cleanup retries configurable and cap retries for Windows in-process COPILOT_HOME deletion to avoid Vitest afterAll deadlock.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines 332 to 336
// Use longer retries to tolerate Windows holding SQLite session-store.db
// open briefly after the CLI subprocess exits. If the temp dir still can't
// be removed (e.g. CLI background writer racing with cleanup), warn and
// continue rather than failing the whole test run — the OS / CI runner
// will reclaim the temp dir on shutdown.
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR modifies only nodejs/test/e2e/harness/sdkTestContext.ts — a Node.js test harness internal utility. The change is a Windows-specific fix for a test teardown deadlock in the rmDir retry helper.

No cross-SDK consistency issues found. This is test infrastructure specific to the Node.js test runner (Vitest) and doesn't affect any public SDK API surface. No equivalent changes are needed in other language SDKs.

Generated by SDK Consistency Review Agent for issue #1997 · sonnet46 397.8K ·

@stephentoub
stephentoub merged commit a023934 into main Jul 16, 2026
23 checks passed
@stephentoub
stephentoub deleted the stephentoub-fix-flaky-node-tests branch July 16, 2026 02:14
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