| Server IP : 159.203.156.69 / Your IP : 216.73.216.37 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/vinext/dist/server/ |
Upload File : |
{"version":3,"file":"instrumentation-runtime.js","names":[],"sources":["../../src/server/instrumentation-runtime.ts"],"sourcesContent":["/**\n * Lazy, idempotent instrumentation initialisation.\n *\n * The generated App Router RSC entry calls this on the first request instead\n * of embedding the bookkeeping directly in codegen. This keeps the entry\n * module thin (it only describes the app shape) while the actual runtime\n * behaviour lives in a normal typed module that can be unit-tested.\n *\n * ## Why lazy?\n *\n * A top-level `await` at module evaluation time blocks the entire V8 isolate\n * startup phase. On Cloudflare Workers that latency is added to every cold\n * start. Moving the `register()` call into the first request handler keeps\n * module evaluation synchronous while still guaranteeing that instrumentation\n * runs before any request is handled.\n *\n * ## Why idempotent?\n *\n * The same handler may be invoked concurrently (e.g. on a warm Worker).\n * A module-level `initialized` flag + a shared promise ensure that\n * `register()` is called exactly once even when multiple requests race.\n *\n * ## Next.js semantics\n *\n * Next.js calls `register()` once when the server process starts, before any\n * request handling. Our lazy init preserves that guarantee because the first\n * request cannot proceed past this call until `register()` has resolved.\n *\n * References:\n * - https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation\n */\n\nimport type { OnRequestErrorHandler } from \"./instrumentation.js\";\n\nlet initialized = false;\nlet initPromise: Promise<void> | null = null;\n\nfunction isOnRequestErrorHandler(value: unknown): value is OnRequestErrorHandler {\n return typeof value === \"function\";\n}\n\n/**\n * Ensure the instrumentation module's `register()` and `onRequestError`\n * hooks have been applied exactly once.\n *\n * @param instrumentationModule - The imported `instrumentation.ts` module.\n * Passed as an argument so the generated entry can import it normally\n * without this helper needing to know the module path.\n */\nexport async function ensureInstrumentationRegistered(\n instrumentationModule: Record<string, unknown>,\n): Promise<void> {\n if (process.env.VINEXT_PRERENDER === \"1\") return;\n if (initialized) return;\n if (initPromise) return initPromise;\n\n initPromise = (async () => {\n if (typeof instrumentationModule.register === \"function\") {\n await instrumentationModule.register();\n }\n\n // Store the onRequestError handler on globalThis so it is visible to\n // reportRequestError() regardless of which Vite environment module graph\n // it is called from. With @vitejs/plugin-rsc the RSC and SSR environments\n // run in the same Node.js process and share globalThis. With\n // @cloudflare/vite-plugin everything runs inside the Worker so globalThis\n // is the Worker's global — also correct.\n if (isOnRequestErrorHandler(instrumentationModule.onRequestError)) {\n globalThis.__VINEXT_onRequestErrorHandler__ = instrumentationModule.onRequestError;\n }\n\n initialized = true;\n })();\n\n return initPromise;\n}\n"],"mappings":";AAkCA,IAAI,cAAc;AAClB,IAAI,cAAoC;AAExC,SAAS,wBAAwB,OAAgD;CAC/E,OAAO,OAAO,UAAU;;;;;;;;;;AAW1B,eAAsB,gCACpB,uBACe;CACf,IAAI,QAAQ,IAAI,qBAAqB,KAAK;CAC1C,IAAI,aAAa;CACjB,IAAI,aAAa,OAAO;CAExB,eAAe,YAAY;EACzB,IAAI,OAAO,sBAAsB,aAAa,YAC5C,MAAM,sBAAsB,UAAU;EASxC,IAAI,wBAAwB,sBAAsB,eAAe,EAC/D,WAAW,mCAAmC,sBAAsB;EAGtE,cAAc;KACZ;CAEJ,OAAO"}