From c6249ac4dd48a761dc064e547db65efbf9d12b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81gata=20Leuck?= Date: Mon, 18 Nov 2024 15:53:42 -0300 Subject: [PATCH] templates: adjust `entry.server` for single fetch --- contributors.yml | 1 + templates/cloudflare-workers/app/entry.server.tsx | 6 +++--- templates/cloudflare/app/entry.server.tsx | 6 +++--- templates/express/app/entry.server.tsx | 10 +++++----- templates/remix-javascript/app/entry.server.jsx | 10 +++++----- templates/remix/app/entry.server.tsx | 10 +++++----- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/contributors.yml b/contributors.yml index c11fb3b3030..c694f3b8890 100644 --- a/contributors.yml +++ b/contributors.yml @@ -723,3 +723,4 @@ - zayenz - zhe - zwhitchcox +- Aleuck diff --git a/templates/cloudflare-workers/app/entry.server.tsx b/templates/cloudflare-workers/app/entry.server.tsx index 9bbdcfaa350..0a04453219f 100644 --- a/templates/cloudflare-workers/app/entry.server.tsx +++ b/templates/cloudflare-workers/app/entry.server.tsx @@ -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, @@ -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( , { signal: controller.signal, diff --git a/templates/cloudflare/app/entry.server.tsx b/templates/cloudflare/app/entry.server.tsx index 9bbdcfaa350..0a04453219f 100644 --- a/templates/cloudflare/app/entry.server.tsx +++ b/templates/cloudflare/app/entry.server.tsx @@ -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, @@ -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( , { signal: controller.signal, diff --git a/templates/express/app/entry.server.tsx b/templates/express/app/entry.server.tsx index 45db3229c68..c262be58c08 100644 --- a/templates/express/app/entry.server.tsx +++ b/templates/express/app/entry.server.tsx @@ -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, @@ -51,7 +51,7 @@ function handleBotRequest( , { onAllReady() { @@ -85,7 +85,7 @@ function handleBotRequest( } ); - setTimeout(abort, ABORT_DELAY); + setTimeout(abort, streamTimeout); }); } @@ -101,7 +101,7 @@ function handleBrowserRequest( , { onShellReady() { @@ -135,6 +135,6 @@ function handleBrowserRequest( } ); - setTimeout(abort, ABORT_DELAY); + setTimeout(abort, streamTimeout + 1000); }); } diff --git a/templates/remix-javascript/app/entry.server.jsx b/templates/remix-javascript/app/entry.server.jsx index aba88807a13..686919b4e3a 100644 --- a/templates/remix-javascript/app/entry.server.jsx +++ b/templates/remix-javascript/app/entry.server.jsx @@ -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, @@ -50,7 +50,7 @@ function handleBotRequest( , { onAllReady() { @@ -84,7 +84,7 @@ function handleBotRequest( } ); - setTimeout(abort, ABORT_DELAY); + setTimeout(abort, streamTimeout + 1000); }); } @@ -100,7 +100,7 @@ function handleBrowserRequest( , { onShellReady() { @@ -134,6 +134,6 @@ function handleBrowserRequest( } ); - setTimeout(abort, ABORT_DELAY); + setTimeout(abort, streamTimeout); }); } diff --git a/templates/remix/app/entry.server.tsx b/templates/remix/app/entry.server.tsx index 45db3229c68..c262be58c08 100644 --- a/templates/remix/app/entry.server.tsx +++ b/templates/remix/app/entry.server.tsx @@ -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, @@ -51,7 +51,7 @@ function handleBotRequest( , { onAllReady() { @@ -85,7 +85,7 @@ function handleBotRequest( } ); - setTimeout(abort, ABORT_DELAY); + setTimeout(abort, streamTimeout); }); } @@ -101,7 +101,7 @@ function handleBrowserRequest( , { onShellReady() { @@ -135,6 +135,6 @@ function handleBrowserRequest( } ); - setTimeout(abort, ABORT_DELAY); + setTimeout(abort, streamTimeout + 1000); }); }