Skip to content

Commit

Permalink
Don't immediately exit on Pages Functions compilation error (#671)
Browse files Browse the repository at this point in the history
* Don't immediately exit on Pages Functions compilation error

* Update .changeset/tame-timers-brake.md

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
  • Loading branch information
GregBrimble and petebacondarwin committed Mar 22, 2022
1 parent 456e1da commit ef0aaad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/tame-timers-brake.md
Original file line number Diff line number Diff line change
@@ -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).
16 changes: 9 additions & 7 deletions packages/wrangler/src/pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -805,13 +805,15 @@ export const pages: BuilderCallback<unknown, unknown> = (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,
Expand Down

0 comments on commit ef0aaad

Please sign in to comment.