Skip to content

test(windows): await proxy teardown before cleanup - #1414

Open
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/harden-isolated-codex-home-cleanup
Open

test(windows): await proxy teardown before cleanup#1414
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/harden-isolated-codex-home-cleanup

Conversation

@luvs01

@luvs01 luvs01 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • await all six composite proxy shutdowns in the same-target 429 E2E file before test environment cleanup begins
  • retry recursive test-tree removal only for transient Windows EPERM, EBUSY, and ENOTEMPTY release races
  • preserve non-transient and exhausted cleanup failures, with deterministic coverage for every retry class

This is a test-harness-only Windows burn-down slice. It does not change production shutdown, retry, provider, or filesystem behavior.

Refs #1059.

Verification

  • Bun 1.4.0-canary.1: bun test --isolate tests/remove-tree-helper.test.ts tests/server-rate-limit-retry-e2e.test.ts tests/storage-mutation-race.test.ts — 18 passed, 0 failed
  • Bun 1.3.14: bun test --isolate tests/server-rate-limit-retry-e2e.test.ts — 6 passed, 0 failed
  • Bun 1.3.14: bun test --isolate tests/remove-tree-helper.test.ts — 5 passed, 0 failed
  • Bun 1.4.0-canary.1: bun x --package typescript@7.0.2 tsc --noEmit — passed
  • Bun 1.3.14: bun x --package typescript@7.0.2 tsc --noEmit — passed
  • Bun 1.4.0-canary.1: bun run privacy:scan — passed
  • git diff HEAD^ --check — passed
  • two independent focused reviews found no actionable P0–P2 findings
  • the earlier Bun 1.4 full-suite run exposed this EBUSY cleanup cascade but remained non-green across other known Windows/setup/runtime families; the full suite was not rerun and this PR does not claim Windows test suite remains dispatch-only until full suite is green #1059 complete

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. This changes test teardown only and needs no user-facing documentation.
  • Security-sensitive changes were reviewed for swallowed errors, leaked handles, and unsafe cleanup scope.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.
  • I pushed my PR to the latest dev commit.
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes

    • Improved temporary-directory cleanup by retrying transient filesystem errors.
    • Ensured test servers shut down cleanly before restoring network behavior, even when shutdown encounters an error.
  • Tests

    • Added coverage for retryable and non-retryable cleanup failures, including final-attempt behavior.
    • Updated end-to-end tests to use more reliable cleanup and shutdown handling.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The test helpers now retry transient directory-removal errors. Isolated Codex home cleanup and rate-limit end-to-end tests use the helper. End-to-end teardown awaits server shutdown before restoring mocked fetch.

Changes

Test cleanup reliability

Layer / File(s) Summary
Retrying tree-removal helper
tests/helpers/remove-tree.ts, tests/remove-tree-helper.test.ts
Adds configurable removal and sleep operations, retries EPERM, EBUSY, and ENOTEMPTY up to 50 times, and tests failure propagation and retry counts.
Isolated home cleanup integration
tests/helpers/isolated-codex-home.ts
Replaces direct recursive removal with removeTreeWithRetry during restoration.
End-to-end teardown integration
tests/server-rate-limit-retry-e2e.test.ts
Uses removeTreeWithRetry for temporary-directory cleanup and awaits server shutdown before restoring mocked fetch in each test teardown path.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested labels: bug

Suggested reviewers: lidge-j, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary test teardown change: awaiting proxy shutdown before cleanup on Windows.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

@luvs01

luvs01 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@luvs01
luvs01 marked this pull request as ready for review August 10, 2026 08:38
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] Acknowledged. Pull request #1414 is marked ready for review, and the readiness checklist is complete.

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] Acknowledged. Pull request #1414 is ready for review. The readiness checklist is complete.

You are interacting with an AI system.

@flyingsquirrel0419 flyingsquirrel0419 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved on exact head b5466fec4a9b13c4e8a35767177abaf422f45fc7.

The change remains test-harness-only: all six proxy shutdown promises are awaited before the global fetch restoration, and recursive removal retries only EPERM, EBUSY, and ENOTEMPTY with a hard attempt limit while preserving non-transient and final failures.

Validation on this exact head:

  • bun run typecheck: pass
  • focused isolate run: 18/18 pass
  • full suite: 10,651 pass, 10 skip, 1 fail

The sole full-suite failure was Codex autostart shim > Unix shim exports persisted service API token before running Codex. I reproduced the identical failure independently on the unchanged base dev commit 0de4fd2d7a9d45d95a30d2cb0708070c34fbd6ef; it reads this host's persisted token path instead of the test-local token and is not introduced by this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants