You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Node Version 18.18.2 Fails to Instantiate Fetch Request with Proper Options #50263
Darwin 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 arm64
Subsystem
n/a
What steps will reproduce the bug?
n/a
How often does it reproduce? Is there a required condition?
n/a
What is the expected behavior? Why is that the expected behavior?
n/a
What do you see instead?
Options are not preserved when instantiating a new Fetch Request object using a Request as the first parameter. This causes the options, that should have been copied, to be missing on the new Fetch Request object.
This behavior was fine on <= Node v18.18.1. It is broken on Node v18.18.2.
reproducible by the following code, but works properly in undici.
constrequest=newRequest('https://a',{headers: {'test': 'abc'},method: 'POST'})constrequest1=newRequest(request,{body: 'abc'})console.log(request1.headers.get('test'))// should be 'abc', is null
Same issue here right now with both Node 18.8.2 and 21.0.0⚠️
All request headers are absolutely empty 💀 all the time in test cases, when fetch is used 🥶
Seems like a catastrophic bug 🪲 and needs an emergency 🚑 hotfix, asap 😱
import{rest}from'msw';import{setupServer}from'msw/node';importassertfrom'node:assert/strict';consturl='https://somewhe.re/somewhat/endpoint';constserver=setupServer(rest.get(url,(req,res,ctx)=>{constheaders=[...req.headers];console.info(headers);// Will be empty []assert(headers.length,'Headers should not be empty');// Will throw herereturnres(ctx.status(200));}),);awaitserver.listen();awaitfetch(url,{headers: {'accept': 'application/json','authorization': 'Bearer <token>',},});awaitserver.close();
@KhafraDev could you send a PR with the regression test so we don't break this anymore?
It might be nice to run the entirety of the fetch tests on the bundle, rather than adding in a useless test. Or maybe we could figure out a way to not bundle undici, which would prevent all of these issues from happening (including the issue regarding names recently).
This issue shouldn't be closed as the problem still persists in the newly released 20.9.0 as well as the as-of-now current 18.18.2 listed in the issue title
Activity
justinbather commentedon Oct 18, 2023
Has anyone taken this issue?
BrettHoutz commentedon Oct 18, 2023
I am seeing the same behavior in Node v20.8.1 (the analogous security release for the v20 line).
KhafraDev commentedon Oct 19, 2023
reproducible by the following code, but works properly in undici.
KhafraDev commentedon Oct 19, 2023
this will be fixed by the next undici update (cc @nodejs/undici)
mcollina commentedon Oct 19, 2023
@KhafraDev what PR is this fixed in?
targos commentedon Oct 19, 2023
I believe it's nodejs/undici#2359
KhafraDev commentedon Oct 19, 2023
I have no idea, I only had time to test if the new bundle fixed the issue, which it did.
bricss commentedon Oct 19, 2023
Same issue here right now with both Node⚠️
18.8.2and21.0.0All request headers are absolutely empty 💀 all the time in test cases, when fetch is used 🥶
Seems like a catastrophic bug 🪲 and needs an emergency 🚑 hotfix, asap 😱
bricss commentedon Oct 19, 2023
Repro script:
mcollina commentedon Oct 19, 2023
Can you reproduce without msw?
KhafraDev commentedon Oct 19, 2023
I posted a reproduction above
mattcollier commentedon Oct 19, 2023
Is it true that once #50274 lands that this issue will be resolved?
I don't see anything in the release notes for
undici@5.26.4that seems directly related to this issue. Can anyone provide a status update?KhafraDev commentedon Oct 19, 2023
Nothing related to 5.26.3 should have broken this either, it's a strange issue.
10 remaining items
KhafraDev commentedon Oct 20, 2023
It might be nice to run the entirety of the fetch tests on the bundle, rather than adding in a useless test. Or maybe we could figure out a way to not bundle undici, which would prevent all of these issues from happening (including the issue regarding names recently).
MajorTanya commentedon Oct 24, 2023
This issue shouldn't be closed as the problem still persists in the newly released 20.9.0 as well as the as-of-now current 18.18.2 listed in the issue title
mcollina commentedon Oct 25, 2023
@KhafraDev can you send a PR with a regression test on Node.js for this?
add regression test
add regression test (#2376)
mattcollier commentedon Oct 26, 2023
Hello all, can someone provide a status update on this issue? As @MajorTanya stated, this issue is not resolved in the
20.9.0release.davidlehn commentedon Oct 26, 2023
@mattcollier #50274 has comments about the fix being cherry-picked into v18.x-staging and v20.x-staging.
johndalvik commentedon Nov 7, 2023
Hey all!
Any update on this, when can we expect a release containing the fixes?
MajorTanya commentedon Nov 24, 2023
Not a contributor, but this seems to be fully fixed with the 20.10.0 LTS release
Edit: due to the lack of a new release for 18.x at this point, this remains an issue for 18.18.2
MajorTanya commentedon Nov 29, 2023
With 18.19.0 landing in 8787acb, this issue should be resolved across v18, v20, and v21, which are all supported versions.
add regression test (nodejs#2376)