mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
- Use globalThis singleton guards for DB connection, HealthCheck timers, console interceptor, and graceful shutdown to survive Webpack HMR re-evaluation (fixes 485+ leaked DB connections per session) - Split instrumentation.ts into instrumentation-node.ts with computed import path to prevent Turbopack Edge bundler from tracing Node.js modules (eliminates 10+ spurious warnings per hot compile) - Parallelize startup imports in instrumentation-node.ts (3 batch Promise.all instead of 9 serial awaits) - Add OMNIROUTE_USE_TURBOPACK=1 env switch in run-next.mjs (default behavior unchanged) - Replace node:crypto with crypto in proxies.ts and errorResponse.ts to fix UnhandledSchemeError - Add unlinkFileWithRetry with EBUSY/EPERM retry for Windows file handle timing in backup restore - Fix pre-restore backup to await completion before closing DB - Fix bootstrap-env, domain-persistence, and fixes-p1 test stability on Windows Made-with: Cursor
21 lines
798 B
TypeScript
21 lines
798 B
TypeScript
/**
|
|
* Next.js Instrumentation Hook
|
|
*
|
|
* Called once when the server starts (both dev and production).
|
|
* All Node.js-specific logic lives in ./instrumentation-node.ts to prevent
|
|
* Turbopack's Edge bundler from tracing into native modules (fs, path, os, etc.)
|
|
*
|
|
* @see https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
|
|
*/
|
|
|
|
export async function register() {
|
|
if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
// Computed path prevents Turbopack from statically resolving the import
|
|
// for the Edge instrumentation bundle, avoiding spurious warnings about
|
|
// Node.js modules not being available in the Edge Runtime.
|
|
const nodeMod = "./instrumentation-" + "node";
|
|
const { registerNodejs } = await import(nodeMod);
|
|
await registerNodejs();
|
|
}
|
|
}
|