Skip to content

Commit

Permalink
chore: construct requests with duplex option
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-ebey committed Aug 22, 2023
1 parent 84738f1 commit ef65468
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/use-fetch-duplex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/server-runtime": patch
---

construct request with duplex option
26 changes: 24 additions & 2 deletions packages/remix-server-runtime/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,33 @@ function stripIndexParam(request: Request) {
url.searchParams.append("index", toKeep);
}

return new Request(url.href, request);
let init: RequestInit = {
method: request.method,
body: request.body,
headers: request.headers,
signal: request.signal,
};

if (init.body) {
(init as { duplex: "half" }).duplex = "half";
}

return new Request(url.href, init);
}

function stripDataParam(request: Request) {
let url = new URL(request.url);
url.searchParams.delete("_data");
return new Request(url.href, request);
let init: RequestInit = {
method: request.method,
body: request.body,
headers: request.headers,
signal: request.signal,
};

if (init.body) {
(init as { duplex: "half" }).duplex = "half";
}

return new Request(url.href, init);
}

0 comments on commit ef65468

Please sign in to comment.