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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/metal-houses-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"wrangler": patch
---

fix: prevent zombie `workerd` processes

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 change ensures all `workerd` processes are killed when `wrangler dev` is shutdown.

To clean-up existing zombie processes, run `pkill -KILL workerd` on macOS/Linux or `taskkill /f /im workerd.exe` on Windows.
mrbbot marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 5 additions & 1 deletion packages/wrangler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,17 @@ export async function main(argv: string[]): Promise<void> {
}
throw e;
} finally {
await closeSentry();
// In the bootstrapper script `bin/wrangler.js`, we open an IPC channel, so
// IPC messages from this process are propagated through the bootstrapper.
// Make sure this channel is closed once it's no longer needed, so we can
// cleanly exit. Note, we don't want to disconnect if this file was imported
// in Jest, as that would stop communication with the test runner.
if (typeof jest === "undefined") process.disconnect?.();

// Close Sentry after disconnecting the IPC channel. Doing this before leads
// to hanging `workerd` processes.
// TODO(soon): work out why
mrbbot marked this conversation as resolved.
Show resolved Hide resolved
await closeSentry();
}
}

Expand Down