Skip to content

fix(vitest-plugin): dispose shared remote proxy sessions only after the last pool worker stops - #15293

Merged
edmundhung merged 1 commit into
cloudflare:mainfrom
thatsKevinJain:kevin/fix-shared-pool-session-bug
Aug 25, 2026
Merged

fix(vitest-plugin): dispose shared remote proxy sessions only after the last pool worker stops#15293
edmundhung merged 1 commit into
cloudflare:mainfrom
thatsKevinJain:kevin/fix-shared-pool-session-bug

Conversation

@thatsKevinJain

@thatsKevinJain thatsKevinJain commented Aug 20, 2026

Copy link
Copy Markdown
Contributor
Fix "Network connection lost" when multiple test files use remote bindings

Remote proxy sessions are shared across pool workers by Wrangler config path,
but were disposed during each test file's teardown. Because Vitest starts the
next file's worker before the previous one finishes stopping, later files
reused an already-disposed session and failed with "Network connection lost".
Sessions are now disposed only once the last pool worker stops.

This fixes issue: #13306


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This fixes a bug.

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e1bf01

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vitest-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 20, 2026
@workers-devprod
workers-devprod requested review from a team and removed request for a team August 20, 2026 22:56
@workers-devprod

workers-devprod commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15293

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15293

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15293

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15293

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15293

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15293

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15293

miniflare

npm i https://pkg.pr.new/miniflare@15293

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15293

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15293

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15293

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15293

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15293

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15293

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15293

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15293

wrangler

npm i https://pkg.pr.new/wrangler@15293

commit: 8e1bf01

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me overall. Just a couple of minor questions. Please rebase latest main to resolve the conflicts 🙏🏼

Comment thread packages/vitest-plugin/test/remote-proxy-sessions.test.ts Outdated
Comment thread packages/vitest-plugin/src/pool/config.ts Outdated
…he last pool worker stops

```
Fix "Network connection lost" when multiple test files use remote bindings

Remote proxy sessions are shared across pool workers by Wrangler config path,
but were disposed during each test file's teardown. Because Vitest starts the
next file's worker before the previous one finishes stopping, later files
reused an already-disposed session and failed with "Network connection lost".
Sessions are now disposed only once the last pool worker stops.
```

This fixes issue: cloudflare#13306
@thatsKevinJain
thatsKevinJain force-pushed the kevin/fix-shared-pool-session-bug branch from b962611 to 8e1bf01 Compare August 24, 2026 22:02

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@edmundhung
edmundhung merged commit 7a9b8a7 into cloudflare:main Aug 25, 2026
73 of 75 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Aug 25, 2026
This was referenced Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants