| 16 | // `'error'` emit is unhandled and tears down the whole dev server. Log |
| 17 | // enough to identify the offender and keep the server alive. |
| 18 | const devCrashGuard = (): Plugin => { |
| 19 | let installed = false; |
| 20 | const install = () => { |
| 21 | if (installed) return; |
| 22 | installed = true; |
| 23 | process.on("uncaughtException", (err, origin) => { |
| 24 | console.error(`[dev-crash-guard] uncaughtException (origin=${origin}):`, err); |
| 25 | }); |
| 26 | process.on("unhandledRejection", (reason, promise) => { |
| 27 | console.error("[dev-crash-guard] unhandledRejection:", reason, promise); |
| 28 | }); |
| 29 | }; |
| 30 | return { |
| 31 | name: "dev-crash-guard", |
| 32 | apply: "serve", |
| 33 | configureServer: install, |
| 34 | }; |
| 35 | }; |
| 36 | |
| 37 | const loadWranglerPublicVars = () => { |
| 38 | const wranglerConfig = unstable_readConfig( |