Skip to content

Commit

Permalink
Refactor entry.server.tsx to remove unused ABORT_DELAY constant and s…
Browse files Browse the repository at this point in the history
…treamline ServerRouter usage
  • Loading branch information
sergiodxa committed Dec 24, 2024
1 parent 41e7ec0 commit 57aef04
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { renderToReadableStream } from "react-dom/server";
import type { AppLoadContext, EntryContext } from "react-router";
import { ServerRouter } from "react-router";

const ABORT_DELAY = 5_000;

export default async function handleRequest(
request: Request,
status: number,
Expand All @@ -15,11 +13,7 @@ export default async function handleRequest(
let userAgent = request.headers.get("user-agent");

let stream = await renderToReadableStream(
<ServerRouter
context={routerContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
<ServerRouter context={routerContext} url={request.url} />,
{
signal: request.signal,
onError(error) {
Expand All @@ -31,9 +25,9 @@ export default async function handleRequest(
);

if (userAgent && isbot(userAgent)) await stream.allReady;
else headers.set("Transfer-Encoding", "chunked");

headers.set("Content-Type", "text/html; charset=utf-8");
headers.set("Transfer-Encoding", "chunked");

return new Response(stream, { status, headers });
}

0 comments on commit 57aef04

Please sign in to comment.