Error handling bugfix: pass #1
This commit is contained in:
@@ -2,7 +2,10 @@ import { Command } from "commander";
|
||||
import path from "path";
|
||||
import type { BunSpawnOptions } from "../../types";
|
||||
import writeErrorFile from "../../functions/write-error-file";
|
||||
import { existsSync } from "fs";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import { existsSync, rmSync } from "fs";
|
||||
|
||||
const { BUNX_BUNDLER_ERROR_EXIT_FILE } = grabDirNames();
|
||||
|
||||
let retries = 0;
|
||||
let timeout: any;
|
||||
@@ -12,6 +15,10 @@ export default function () {
|
||||
return new Command("start")
|
||||
.description("Start production server")
|
||||
.action(async () => {
|
||||
// A stale error file from a previous session makes the bundler
|
||||
// run in "silent" mode and pages fail with misleading messages.
|
||||
rmSync(BUNX_BUNDLER_ERROR_EXIT_FILE, { force: true });
|
||||
|
||||
await start();
|
||||
});
|
||||
}
|
||||
@@ -59,7 +66,9 @@ async function start() {
|
||||
|
||||
const exited = await dev_process.exited;
|
||||
|
||||
if (exited) {
|
||||
// Restart on any numeric exit (0 included). A null exit means the child
|
||||
// was killed by a signal, which we must not restart.
|
||||
if (exited != null) {
|
||||
retries++;
|
||||
timeout = setTimeout(() => {
|
||||
retries = 0;
|
||||
|
||||
Reference in New Issue
Block a user