Skip to content

Commit

Permalink
templates: adjust entry.server for single fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleuck committed Nov 18, 2024
1 parent 39d50b1 commit 646048d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions templates/cloudflare-workers/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";

const ABORT_DELAY = 5000;
export const streamTimeout = 5000;

export default async function handleRequest(
request: Request,
Expand All @@ -22,13 +22,13 @@ export default async function handleRequest(
loadContext: AppLoadContext
) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY);
const timeoutId = setTimeout(() => controller.abort(), streamTimeout + 1000);

const body = await renderToReadableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
signal: controller.signal,
Expand Down
6 changes: 3 additions & 3 deletions templates/cloudflare/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";

const ABORT_DELAY = 5000;
export const streamTimeout = 5000;

export default async function handleRequest(
request: Request,
Expand All @@ -22,13 +22,13 @@ export default async function handleRequest(
loadContext: AppLoadContext
) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY);
const timeoutId = setTimeout(() => controller.abort(), streamTimeout + 1000);

const body = await renderToReadableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
signal: controller.signal,
Expand Down
10 changes: 5 additions & 5 deletions templates/express/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5_000;
export const streamTimeout = 5_000;

export default function handleRequest(
request: Request,
Expand Down Expand Up @@ -51,7 +51,7 @@ function handleBotRequest(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
onAllReady() {
Expand Down Expand Up @@ -85,7 +85,7 @@ function handleBotRequest(
}
);

setTimeout(abort, ABORT_DELAY);
setTimeout(abort, streamTimeout);
});
}

Expand All @@ -101,7 +101,7 @@ function handleBrowserRequest(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
onShellReady() {
Expand Down Expand Up @@ -135,6 +135,6 @@ function handleBrowserRequest(
}
);

setTimeout(abort, ABORT_DELAY);
setTimeout(abort, streamTimeout + 1000);
});
}
10 changes: 5 additions & 5 deletions templates/remix-javascript/app/entry.server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5_000;
export const streamTimeout = 5_000;

export default function handleRequest(
request,
Expand Down Expand Up @@ -50,7 +50,7 @@ function handleBotRequest(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
onAllReady() {
Expand Down Expand Up @@ -84,7 +84,7 @@ function handleBotRequest(
}
);

setTimeout(abort, ABORT_DELAY);
setTimeout(abort, streamTimeout + 1000);
});
}

Expand All @@ -100,7 +100,7 @@ function handleBrowserRequest(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
onShellReady() {
Expand Down Expand Up @@ -134,6 +134,6 @@ function handleBrowserRequest(
}
);

setTimeout(abort, ABORT_DELAY);
setTimeout(abort, streamTimeout);
});
}
10 changes: 5 additions & 5 deletions templates/remix/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5_000;
export const streamTimeout = 5_000;

export default function handleRequest(
request: Request,
Expand Down Expand Up @@ -51,7 +51,7 @@ function handleBotRequest(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
onAllReady() {
Expand Down Expand Up @@ -85,7 +85,7 @@ function handleBotRequest(
}
);

setTimeout(abort, ABORT_DELAY);
setTimeout(abort, streamTimeout);
});
}

Expand All @@ -101,7 +101,7 @@ function handleBrowserRequest(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
abortDelay={streamTimeout}
/>,
{
onShellReady() {
Expand Down Expand Up @@ -135,6 +135,6 @@ function handleBrowserRequest(
}
);

setTimeout(abort, ABORT_DELAY);
setTimeout(abort, streamTimeout + 1000);
});
}

0 comments on commit 646048d

Please sign in to comment.