/** * Process-scoped startup work. * * Next calls `register` once per server instance, before it serves a request. * That makes it the only place in this app where a background schedule can * live: a route module has no such guarantee — it can be instantiated more than * once and gets no shutdown hook — so anything periodic started from one is * really started per instantiation. * * `register` must return before the server is ready, so nothing here may block * on I/O. Starting a timer does not. */ export async function register(): Promise { // Also invoked for the Edge runtime, which has neither `pg` nor timers we // want; the persistence stack is Node-only. if (process.env.NEXT_RUNTIME !== 'nodejs') return; // Imported dynamically so the Edge bundle never pulls in `pg`. const { startAssetCollectorSchedule } = await import('@/lib/persistence/asset-collector-schedule'); startAssetCollectorSchedule(); }