Retry incomplete controller startup (Refs #65)

This commit is contained in:
2026-10-09 12:35:26 -04:00
parent 96d21d0514
commit 0abe5ba820
2 changed files with 54 additions and 8 deletions
+10 -7
View File
@@ -9,21 +9,24 @@ import { withOperationSource } from '$lib/server/hosts/operation-context.js';
import { withHostRequestContext } from '$lib/server/hosts/request-context.js';
let booted = false;
let rejectionLoggerRegistered = false;
function boot(): void {
if (booted) return;
booted = true;
process.on('unhandledRejection', reason => {
console.error('[process] unhandled rejection:', reason);
});
if (!rejectionLoggerRegistered) {
process.on('unhandledRejection', reason => {
console.error('[process] unhandled rejection:', reason);
});
rejectionLoggerRegistered = true;
}
migrate();
interruptDeployments();
startWorker();
startPerformanceMonitor();
booted = true;
}
// SvelteKit calls handle() for every request; using the first request as the
// boot trigger keeps the whole app single-process without needing an
// out-of-band init hook.
// Boot synchronously before serving requests. Failed startup stays unbooted so
// the next request retries migrations and worker startup before reaching the UI.
export const handle: Handle = async (input) => {
boot();
const started = performance.now();