Error handling bugfix: pass #1
This commit is contained in:
Vendored
+9
-2
@@ -3,7 +3,7 @@ import path from "path";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import writeErrorFile from "../../functions/write-error-file";
|
||||
import { existsSync, rmSync } from "fs";
|
||||
const { BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON } = grabDirNames();
|
||||
const { BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON, BUNX_BUNDLER_ERROR_EXIT_FILE, } = grabDirNames();
|
||||
let retries = 0;
|
||||
let timeout;
|
||||
const MAX_RETRIES = 5;
|
||||
@@ -14,6 +14,10 @@ export default function () {
|
||||
try {
|
||||
rmSync(SSR_BUNDLER_CTX_MAP_JSON, { recursive: true });
|
||||
rmSync(BUNDLER_CTX_MAP_JSON, { recursive: true });
|
||||
// A stale error file from a previous session makes the bundler
|
||||
// run in "silent" mode and pages fail with misleading
|
||||
// "Application Error" messages until the first rebuild.
|
||||
rmSync(BUNX_BUNDLER_ERROR_EXIT_FILE, { force: true });
|
||||
}
|
||||
catch (error) { }
|
||||
await dev();
|
||||
@@ -54,7 +58,10 @@ async function dev() {
|
||||
return await dev();
|
||||
}
|
||||
const exited = await dev_process.exited;
|
||||
if (exited) {
|
||||
// Restart on any numeric exit (0 included: the server should never exit
|
||||
// cleanly). A null exit means the child was killed by a signal (e.g.
|
||||
// Ctrl+C in the shared terminal), which we must not restart.
|
||||
if (exited != null) {
|
||||
retries++;
|
||||
timeout = setTimeout(() => {
|
||||
retries = 0;
|
||||
|
||||
Reference in New Issue
Block a user