chore(next): upgrade preview and isolate dev services

This commit is contained in:
ajnart committed 2026-07-29 06:47:07 +02:00
1 parent ac73b9d891
commit 4ca0b747bb
9 files changed
+1651 -1437

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
// Development runs background services as separate processes. The aliases in
// next.config.ts keep production-only instrumentation imports out of the graph.
export const instrumentationNoop = true;
+55
View File
@@ -0,0 +1,55 @@
// @vitest-environment node
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
const registerAsync = async (nodeEnv: string, nextRuntime: string) => {
const tasksStarted = vi.fn();
const websocketStarted = vi.fn();
vi.stubEnv("NODE_ENV", nodeEnv);
vi.stubEnv("NEXT_RUNTIME", nextRuntime);
vi.doMock("@homarr/tasks", () => {
tasksStarted();
return {};
});
vi.doMock("@homarr/websocket", () => {
websocketStarted();
return {};
});
const { register } = await import("./instrumentation");
await register();
return { tasksStarted, websocketStarted };
};
describe("Next instrumentation", () => {
beforeEach(() => {
vi.resetModules();
});
afterEach(() => {
vi.doUnmock("@homarr/tasks");
vi.doUnmock("@homarr/websocket");
vi.unstubAllEnvs();
});
test("embeds background services in the production Node runtime", async () => {
const { tasksStarted, websocketStarted } = await registerAsync("production", "nodejs");
expect(tasksStarted).toHaveBeenCalledOnce();
expect(websocketStarted).toHaveBeenCalledOnce();
});
test("does not embed background services in the development server", async () => {
const { tasksStarted, websocketStarted } = await registerAsync("development", "nodejs");
expect(tasksStarted).not.toHaveBeenCalled();
expect(websocketStarted).not.toHaveBeenCalled();
});
test("does not embed Node services in the edge runtime", async () => {
const { tasksStarted, websocketStarted } = await registerAsync("production", "edge");
expect(tasksStarted).not.toHaveBeenCalled();
expect(websocketStarted).not.toHaveBeenCalled();
});
});
+5 -4
View File
@@ -1,6 +1,7 @@
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("@homarr/tasks");
await import("@homarr/websocket");
}
if (process.env.NEXT_RUNTIME !== "nodejs") return;
if (process.env.NODE_ENV !== "production") return;
await import("@homarr/tasks");
await import("@homarr/websocket");
}