| Server IP : 159.203.156.69 / Your IP : 216.73.217.172 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 : |
import { workUnitAsyncStorage } from "../shims/internal/work-unit-async-storage.js";
//#region src/server/prerender-work-unit-setup.ts
/**
* Sets up the work unit async storage for prerendering.
*
* When VINEXT_PRERENDER=1, wraps execution in a workUnitAsyncStorage.run()
* with a PrerenderStore so that dynamic APIs (e.g., io()) can
* detect the prerender context and return hanging promises.
*
* Used by: app-rsc-entry.ts handler template.
*
* TODO: If future dynamic APIs need request-scoped stores for normal (non-prerender)
* requests, add a `{ type: "request" }` store during normal request handling.
*/
function runWithPrerenderWorkUnit(fn, options) {
if (process.env.VINEXT_PRERENDER === "1") {
const controller = new AbortController();
const route = typeof options?.route === "function" ? options.route() : options?.route;
return workUnitAsyncStorage.run({
type: "prerender",
renderSignal: controller.signal,
route
}, fn).finally(() => controller.abort());
}
return fn();
}
//#endregion
export { runWithPrerenderWorkUnit };
//# sourceMappingURL=prerender-work-unit-setup.js.map