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