diff --git a/.changeset/tame-timers-brake.md b/.changeset/tame-timers-brake.md new file mode 100644 index 000000000000..990ee0137f4d --- /dev/null +++ b/.changeset/tame-timers-brake.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +fix: don't exit on initial Pages Functions compilation failure + +Previously, we'd exit the `wrangler pages dev` process if we couldn't immediately compile a Worker from the `functions` directory. We now log the error, but don't exit the process. This means that proxy processes can be cleaned up cleanly on SIGINT and SIGTERM, and it matches the behavior of if a compilation error is introduced once already running (we don't exit then either). diff --git a/packages/wrangler/src/pages.tsx b/packages/wrangler/src/pages.tsx index 602de9ac293b..609b2cb29d97 100644 --- a/packages/wrangler/src/pages.tsx +++ b/packages/wrangler/src/pages.tsx @@ -805,13 +805,15 @@ export const pages: BuilderCallback = (yargs) => { console.log(`Compiling worker to "${scriptPath}"...`); - await buildFunctions({ - scriptPath, - functionsDirectory, - sourcemap: true, - watch: true, - onEnd: () => scriptReadyResolve(), - }); + try { + await buildFunctions({ + scriptPath, + functionsDirectory, + sourcemap: true, + watch: true, + onEnd: () => scriptReadyResolve(), + }); + } catch {} watch([functionsDirectory], { persistent: true,