app/entry.server.tsx
31 lines and 2 functions in DrDustinEdwards/carrel, at commit d5d5e82 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| handleRequest | 8 to 35 | 3 | 0% | WatchCRAP 12 | No data: mutation testing has not run on this repo yet |
| onError | 23 to 26 | 2 | 0% | WatchCRAP 6 | No data: mutation testing has not run on this repo yet |
Imports
It imports app/lib/context.ts. No module of this repo imports it.
Source
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";
import type { EntryContext, RouterContextProvider } from "react-router";
import { ServerRouter } from "react-router";
import { getNonce } from "~/lib/context";
export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
routerContext: EntryContext,
loadContext: RouterContextProvider,
) {
// The ServerRouter prop nonces React Router's streaming scripts; react-dom's own inline scripts
// take it only from the render option. Without both, the policy blocks hydration.
const nonce = getNonce(loadContext);
let shellRendered = false;
const body = await renderToReadableStream(
<ServerRouter context={routerContext} url={request.url} nonce={nonce} />,
{
nonce,
onError(error: unknown) {
responseStatusCode = 500;
if (shellRendered) console.error(error);
},
},
);
shellRendered = true;
if (isbot(request.headers.get("user-agent") || "")) await body.allReady;
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
return new Response(body, { headers: responseHeaders, status: responseStatusCode });
}