-
Notifications
You must be signed in to change notification settings - Fork 60
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
fix: add duplex
option when sending a body
#571
Conversation
What is the node version where it starts failing? We should add it to the test matrix to avoid regressions |
src/fetch-wrapper.ts
Outdated
@@ -39,6 +39,7 @@ export default function fetchWrapper( | |||
body: requestOptions.body, | |||
headers: requestOptions.headers as HeadersInit, | |||
redirect: requestOptions.redirect, | |||
...(requestOptions.body && { duplex: 'half' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add a comment about why the duplex
option is added here, with a URL that holds more information. Will half
always work, or are there different values that need to be set based on different types of request body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my understanding, based on the spec, half
should be appropriate to set for all cases in Node.js (it is the also only option available at the moment)
Oops, I thought i added that to the PR body but i missed it! It was Node.js |
48cd8a5
to
163a558
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much Shelley!
And thanks a lot for all your great work in Electron and Beyond!
In that case our current CI should cover it. Node 18 currently loads |
Hmm do you have a test script that fails for you in Node 18.14? I tried this code on the await request("POST /repos/{owner}/{repo}/issues/{issue_number}/comments", {
owner: "gr2m",
repo: "sandbox",
issue_number: 240,
body: "Hello World",
headers: {
authorization: `token ${process.env.GITHUB_TOKEN}`,
},
}); And it worked |
@nickfloyd @gr2m do you know when we can expect a new version? We're having to patch around this locally: electron/electron#38250 |
hey sorry we have automated releases, but this pull request was merged with an incorrect commit message. It was before we set commit messages to default to the pull request title. I'll have that sorted out in a moment |
🎉 This PR is included in version 6.2.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
all set, very sorry for the delay 😞 |
@gr2m no worries - thank you so much! |
Resolves #570
Refs nodejs/node#46221.
As of Node.js
v18.13.0
, via an update toundici
,request.duplex
must be set ifrequest.body
isReadableStream
orAsync Iterables
. This PR therefore adds missingduplex
option tofetch-wrapper
as per specI'm not sure if it's possible to test for this since responses are mocked.
Behavior
Before the change?
fetch
calls fail with the following type of error:After the change?
fetch
calls should no longer fail.Other information
I'm not sure if it's possible to test for this since responses are mocked.
Additional info
Pull request checklist
Does this introduce a breaking change?
Type: Breaking change
label)Pull request type
Please add the corresponding label for change this PR introduces:
Type: Bug
Type: Feature
Type: Documentation
Type: Maintenance