From 4b94bf5f1b256205bcc49c1ff7ced816aaacba07 Mon Sep 17 00:00:00 2001 From: Jacob M-G Evans Date: Tue, 29 Mar 2022 14:21:53 -0500 Subject: [PATCH] bugfix: proxyServer was conducting async behavior in useEffect without cleaning up the SIGINT didnt allow for graceful shutdown for subsequent startups of proxyServer --- .changeset/flat-ladybugs-care.md | 7 +++++++ packages/wrangler/src/proxy.ts | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 .changeset/flat-ladybugs-care.md diff --git a/.changeset/flat-ladybugs-care.md b/.changeset/flat-ladybugs-care.md new file mode 100644 index 000000000000..54e6ca3758a0 --- /dev/null +++ b/.changeset/flat-ladybugs-care.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +bugfix: The proxyServer was conducting async behavior in useEffect without cleaning up the SIGINT didn't allow for graceful shutdown for subsequent startups of proxyServer. + +fixes #375 diff --git a/packages/wrangler/src/proxy.ts b/packages/wrangler/src/proxy.ts index c72633f46b56..05ac05c4b02d 100644 --- a/packages/wrangler/src/proxy.ts +++ b/packages/wrangler/src/proxy.ts @@ -96,6 +96,12 @@ export function usePreviewServer({ await reportError(err); }); } + return () => { + if (proxyServer !== undefined) { + proxyServer.close(); + setProxyServer(undefined); + } + }; }, [proxyServer, localProtocol]); /**