fix: handle lazy startup failures

This commit is contained in:
ajnart committed 2026-07-29 07:23:09 +02:00
1 parent 84f87ce24e
commit c80e9878de
5 files changed
+85 -21

No files matched your search

+17 -2
View File
@@ -1,7 +1,22 @@
import { createLogger } from "@homarr/core/infrastructure/logs";
const logger = createLogger({ module: "instrumentation" });
export async function register() {
if (process.env.NEXT_RUNTIME !== "nodejs") return;
if (process.env.NODE_ENV !== "production") return;
await import("@homarr/tasks");
await import("@homarr/websocket");
const services = [
{ name: "tasks", start: () => import("@homarr/tasks") },
{ name: "websocket", start: () => import("@homarr/websocket") },
];
const results = await Promise.allSettled(services.map(({ start }) => start()));
for (const [index, result] of results.entries()) {
if (result.status === "rejected") {
logger.error(
new Error(`Failed to start embedded ${services[index]?.name ?? "unknown"} service`, { cause: result.reason }),
);
}
}
}