Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates: adjust entry.server for single fetch #10240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,4 @@
- zayenz
- zhe
- zwhitchcox
- Aleuck
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);
});
}