Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wrangler] fix: prevent zombie workerd processes #4635

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Dec 20, 2023

Fixes #4612.
Fixes #4131.
Fixes cloudflare/workers-rs#425.

What this PR solves / how to test:

Previously, running wrangler dev would leave behind "zombie" workerd processes. These processes prevented the same port being bound if wrangler dev was restarted and sometimes consumed lots of CPU time. This PR ensures all workerd processes are killed when wrangler dev is shutdown.

Massive thank you to @ezg27 for identifying that commenting out await closeSentry() fixes the issue. I'm still not quite sure why this is happening. This is what I've observed:

  • This issue only occurs in production builds (when the SENTRY_DSN environment variable is set during the build)
  • Starting wrangler-dist/cli.js directly rather than through the bin/wrangler.js bootstrapper fixes the issue
  • Removing , "ipc" from...
    stdio: ["inherit", "inherit", "inherit", "ipc"],
    ...fixes the issue
  • Swapping the order of the await closeSentry() and process.disconnect?.() fixes the issue

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because: this fix doesn't appear to work when spawning wrangler via shellac (likely not a shellac problem), so we can't use our existing E2E testing framework to write tests for this. Given this is affecting lots of users, I'd prefer we get a fix out now, then investigate/test this later.
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because: fixing a regression

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@mrbbot mrbbot requested a review from a team as a code owner December 20, 2023 12:15
Copy link

changeset-bot bot commented Dec 20, 2023

🦋 Changeset detected

Latest commit: 74bdc1d

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

This PR includes changesets to release 1 package
Name Type
wrangler 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
Contributor

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7275199171/npm-package-wrangler-4635

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7275199171/npm-package-wrangler-4635

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7275199171/npm-package-wrangler-4635 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7275199171/npm-package-miniflare-4635
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7275199171/npm-package-cloudflare-pages-shared-4635
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7275199171/npm-package-create-cloudflare-4635 --no-auto-update

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.22.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20231030.4
workerd 1.20231030.0 1.20231030.0
workerd --version 1.20231030.0 2023-10-30

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (35e8a5d) 75.19% compared to head (74bdc1d) 75.22%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4635      +/-   ##
==========================================
+ Coverage   75.19%   75.22%   +0.03%     
==========================================
  Files         242      242              
  Lines       13014    13014              
  Branches     3346     3346              
==========================================
+ Hits         9786     9790       +4     
+ Misses       3228     3224       -4     
Files Coverage Δ
packages/wrangler/src/index.ts 89.04% <100.00%> (ø)

... and 6 files with indirect coverage changes

@mrbbot mrbbot changed the title fix: prevent zombie workerd processes [wrangler] fix: prevent zombie workerd processes Dec 20, 2023
@mrbbot mrbbot merged commit 5bc2699 into main Dec 20, 2023
17 checks passed
@mrbbot mrbbot deleted the bcoll/we-dont-want-zombies-on-the-lawn branch December 20, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
2 participants