refactor(boot): register the offline-geo notice from its own helper

Keeps register() under the function-size cap; the test pins that register() still calls it.
This commit is contained in:
Marc-André Bombeck committed 2026-10-23 11:01:47 +02:00
1 parent 0139c22ae3
commit e84b80ee3c
2 files changed
+21 -10

No files matched your search

+16 -10
View File
@@ -1,5 +1,20 @@
import type { Instrumentation } from "next";
/**
* The admin notice for a host whose login-IP lookups leave it. The geo
* resolver evaluates it on its first public-IP lookup; it holds a slot
* rather than importing the notification layer (see the notice module).
*/
async function registerOfflineGeoNoticeAtBoot(): Promise<void> {
try {
const { registerOfflineGeoNotice } =
await import("@/lib/notifications/offline-geo-notice");
registerOfflineGeoNotice();
} catch {
// Without it the lookups still resolve; only the notice is missing.
}
}
export async function register() {
// Only start the worker on the Node.js server runtime (not Edge, not build)
if (process.env.NEXT_RUNTIME === "nodejs") {
@@ -35,16 +50,7 @@ export async function register() {
// A readiness summary must never break boot.
}
// The admin notice for a host whose login-IP lookups leave it. The geo
// resolver evaluates it on its first public-IP lookup; it holds a slot
// rather than importing the notification layer (see the notice module).
try {
const { registerOfflineGeoNotice } =
await import("@/lib/notifications/offline-geo-notice");
registerOfflineGeoNotice();
} catch {
// Without it the lookups still resolve; only the notice is missing.
}
await registerOfflineGeoNoticeAtBoot();
// Does the configured encryption key open this database? A process whose
// key does not refuses every API request with one clear 503 and starts
@@ -201,6 +201,11 @@ describe("offline-geo runtime detection", () => {
expect(boot).toMatch(
/import\("@\/lib\/notifications\/offline-geo-notice"\)[\s\S]*registerOfflineGeoNotice\(\)/,
);
// …and the helper that does it runs inside `register()`.
const registerBody = boot.slice(
boot.indexOf("export async function register()"),
);
expect(registerBody).toContain("await registerOfflineGeoNoticeAtBoot()");
});
it("offlineGeoReady() is false when the .empty marker is present", async () => {