Skip to content

Commit

Permalink
fixup! Allow --experimental-local to cleanly exit on x/CTRL-C
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Dec 14, 2022
1 parent da086a2 commit 538a008
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/wrangler/src/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,19 @@ export async function startDev(args: StartDevOptions) {
// mode enables raw mode on stdin which disables the built-in handler. The
// following line disconnects from the IPC channel when we press `x` or
// CTRL-C in interactive mode, ensuring no open handles, and allowing for a
// clean exit.
devReactElement.waitUntilExit().then(() => process.disconnect?.());
// clean exit. Note, if we called `stop()` using the dev API, we don't want
// to disconnect here, as the user may still need IPC.
let apiStopped = false;
devReactElement.waitUntilExit().then(() => {
if (!apiStopped) process.disconnect?.();
});

rerender = devReactElement.rerender;
return {
devReactElement,
watcher,
stop: async () => {
apiStopped = true;
devReactElement.unmount();
await watcher?.close();
},
Expand Down

0 comments on commit 538a008

Please sign in to comment.