Error handling bugfix: pass #1

This commit is contained in:
2026-10-02 07:04:22 +01:00
parent 39a5e91eeb
commit d8ea4f8e02
53 changed files with 1179 additions and 410 deletions
+7 -4
View File
@@ -2,7 +2,7 @@ import _ from "lodash";
import { log } from "../../utils/log";
import serverParamsGen from "./server-params-gen";
import isDevelopment from "../../utils/is-development";
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
import { restartWatcher, watcherRestartAvailable, } from "./watcher-esbuild-ctx";
export default async function startServer() {
const serverParams = await serverParamsGen();
const server = Bun.serve(serverParams);
@@ -10,10 +10,13 @@ export default async function startServer() {
global.BUNEXT_SERVER = server;
log.server(`http://${server.hostname}:${server.port}`);
if (is_dev) {
// Watchdog: periodically re-create the FS watcher in case it went
// stale and stopped receiving events. Skipped while a recent restart
// (e.g. by fullRebuild) is still fresh so the watcher isn't churned
// twice in a row.
setInterval(() => {
if (global.BUNEXT_PAGES_SRC_WATCHER) {
global.BUNEXT_PAGES_SRC_WATCHER.close();
watcherEsbuildCTX();
if (watcherRestartAvailable()) {
restartWatcher();
}
}, 5000);
}