From 860076a2428da97388024d7de27964184ca1e2bc Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Thu, 7 Mar 2024 18:54:24 +0200 Subject: [PATCH] fix(remix): Fix issue of creating multiple branches of a single stream on Cloudflare Workers --- .changeset/shiny-ties-complain.md | 5 +++++ packages/remix/src/ssr/utils.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/shiny-ties-complain.md diff --git a/.changeset/shiny-ties-complain.md b/.changeset/shiny-ties-complain.md new file mode 100644 index 00000000000..3ed10df4c1a --- /dev/null +++ b/.changeset/shiny-ties-complain.md @@ -0,0 +1,5 @@ +--- +'@clerk/remix': patch +--- + +Replace `response.clone()` with `new Response(response.body, response)` to avoid creating multiple branches of a single stream on Cloudflare workers ([issue reference](https://github.com/cloudflare/workers-sdk/issues/3259)). diff --git a/packages/remix/src/ssr/utils.ts b/packages/remix/src/ssr/utils.ts index 96eab702ba1..ef8355168d4 100644 --- a/packages/remix/src/ssr/utils.ts +++ b/packages/remix/src/ssr/utils.ts @@ -64,7 +64,7 @@ export const injectRequestStateIntoResponse = async ( requestState: RequestState, context: AppLoadContext, ) => { - const clone = response.clone(); + const clone = new Response(response.body, response); const data = await clone.json(); const { clerkState, headers } = getResponseClerkState(requestState, context);