KEMBAR78
cleanup containers directly instead of using process.exit hook by emily-shen · Pull Request #10986 · cloudflare/workers-sdk · GitHub
Skip to content

Conversation

emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Oct 15, 2025

Wrangler dev regressed a bit and stopped removing containers on exit after #10862.

This PR also adds a direct call to cleanupContainers in the teardown hook.
I think removing and re adding event listeners in onBundleStart should still stop the tests flaking still.

We can't remove the process.exit hooks entirely, since if we don't manage to call teardown (e.g. when something like concurrently is killing wrangler), we won't cleanup containers.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: containers

@emily-shen emily-shen requested a review from a team as a code owner October 15, 2025 12:32
@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

🦋 Changeset detected

Latest commit: 13e2816

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

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-actions
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/fix-container-exit might be a good starting point.

Notes:

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 15, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 13e2816

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Does this, therefore, rely upon the teardown being called on (effectively) process exit?

@emily-shen emily-shen marked this pull request as draft October 15, 2025 12:41
@emily-shen emily-shen force-pushed the emily/fix-container-exit branch from 2df5f63 to b59adfb Compare October 15, 2025 12:50
#teardown = async (): Promise<void> => {
logger.debug("MultiworkerRuntimeController teardown beginning...");

this.cleanupContainers();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed since the public teardown() method calls super, which will run the cleanup already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}, WAITFOR_OPTIONS);

wrangler.pty.kill("SIGINT");
// ctrl + c
Copy link
Contributor Author

Choose a reason for hiding this comment

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

weirdly sending a sigint to the wrangler process in interactive-dev-tests was always cleaning up wrangler containers (so we didn't catch the regression), but writing ctrl+c does fail without the changes in this pr

@emily-shen emily-shen marked this pull request as ready for review October 15, 2025 14:03
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Oct 15, 2025
@emily-shen emily-shen added the skip-v3-pr Skip validation of presence of a v3 backport PR label Oct 15, 2025
@petebacondarwin petebacondarwin merged commit 43503c7 into main Oct 15, 2025
44 of 47 checks passed
@petebacondarwin petebacondarwin deleted the emily/fix-container-exit branch October 15, 2025 14:41
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Oct 15, 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