Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Jul 28, 2025

previously these methods were async so we could not call them from process.on('exit'). by using synchronous apis instead to run docker commands, we can actually do cleanup from that hook, which simplifies a lot of the vite plugin cleanup code and also ensures proper cleanup if you run and stop wrangler programmatically (e.g. using something like concurrently).

Vite manual testing:
I don't think we can test this with the vite plugin because we start and stop the vite server in vitest's global setup hook, which runs after test hooks like afterAll.
You can manually test this by:

  1. running vite dev in container-app in the vite playground
  2. hit /start
  3. verify a container is running with docker ps
  4. stop the vite dev session
  5. run docker ps again to verify no containers are still running

  • Tests
    • Tests included
    • Tests not necessary because: these should just pass existing tests in fixtures/interactive-dev-tests that check that containers are cleaned up after a dev session. fine.
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: new to v4

Copy link

changeset-bot bot commented Jul 28, 2025

🦋 Changeset detected

Latest commit: 7fd0fc1

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

This PR includes changesets to release 3 packages
Name Type
@cloudflare/vite-plugin Patch
wrangler Patch
@cloudflare/vitest-pool-workers 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

Copy link

pkg-pr-new bot commented Jul 28, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10099

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 7fd0fc1

@emily-shen emily-shen force-pushed the emily/container-cleanup-sync branch from b4808e4 to ee79aa5 Compare July 30, 2025 11:27
@emily-shen emily-shen force-pushed the emily/container-cleanup-sync branch from ee79aa5 to 262b2b7 Compare July 30, 2025 12:42
@emily-shen emily-shen marked this pull request as ready for review July 30, 2025 12:42
@emily-shen emily-shen requested review from a team as code owners July 30, 2025 12:42

onBundleStart(_: BundleStartEvent) {
// Ignored in local runtime
process.on("exit", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really sure if this is the right spot to register this

Copy link
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main emily/container-cleanup-sync might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-10099
  • add the skip-v3-pr label to the current PR to stop this workflow from failing

Copy link
Contributor

@jamesopstad jamesopstad left a comment

Choose a reason for hiding this comment

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

Various questions, mainly so I understand better. Looks good otherwise.

@emily-shen emily-shen added the skip-v3-pr Skip validation of presence of a v3 backport PR label Jul 31, 2025
@emily-shen emily-shen requested a review from jamesopstad July 31, 2025 12:28
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jul 31, 2025
@emily-shen emily-shen merged commit 360004d into main Jul 31, 2025
47 of 49 checks passed
@emily-shen emily-shen deleted the emily/container-cleanup-sync branch July 31, 2025 17:09
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-v3-pr Skip validation of presence of a v3 backport PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants