Skip to content

Fix HttpServerRequest.toWeb missing duplex option for streaming bodies#5900

Closed
Copilot wants to merge 1 commit intofix-http-server-request-toWeb-duplexfrom
copilot/sub-pr-5899
Closed

Fix HttpServerRequest.toWeb missing duplex option for streaming bodies#5900
Copilot wants to merge 1 commit intofix-http-server-request-toWeb-duplexfrom
copilot/sub-pr-5899

Conversation

Copy link

Copilot AI commented Dec 12, 2025

Node.js 18+ requires duplex: "half" when constructing a Request with a streaming body. HttpServerRequest.toWeb() was missing this option, causing TypeError: RequestInit: duplex option is required when sending a body.

Changes

  • Added duplex: "half" to Request constructor when body is present
  • Added test coverage for POST request conversion with JSON body
export const toWeb = (self: HttpServerRequest): Request | undefined => {
  // ... early returns omitted
  const body = hasBody(self.method) ? Stream.toReadableStream(self.stream) : undefined
  return new Request(ourl.value, {
    method: self.method,
    body,
    headers: self.headers,
    // @ts-expect-error - duplex is required for streaming bodies in Node 18+
    duplex: body !== undefined ? "half" : undefined
  })
}

Impact
Only affects Node.js environments where we construct a new Request from IncomingMessage. Bun/Deno/web contexts return early with the native Request and are unaffected.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2025

⚠️ No Changeset found

Latest commit: d6a7fbf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Author

Copilot AI commented Dec 12, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pkg.pr.new
    • Triggering command: /usr/local/bin/node node /usr/local/bin/pnpm install ./packages/platform/test/HttpClient.test.ts ./packages/platform/test/HttpApiBuilder.test.ts ./packages/platform/test/Path.test.ts ./packages/platform/test/HttpTraceContext.test.ts ./packages/platform/test/Multipart.test.ts ./packages/platform/test/Template.test.ts ./packages/platform/test/Url.test.ts ./packages/platform/test/Headers.test.ts ./packages/platform/test/Transferable.test.ts (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix HttpServerRequest.toWeb missing duplex option for streaming bodies Fix HttpServerRequest.toWeb missing duplex option for streaming bodies Dec 12, 2025
Copilot AI requested a review from kitlangton December 12, 2025 23:00
@kitlangton kitlangton closed this Dec 12, 2025
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants