Closed
Description
Version
v18.19.0, v20.11.0, v21.7.0
Platform
Darwin Artems-Air.home 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:59:33 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8112 arm64
Subsystem
No response
What steps will reproduce the bug?
// index.js
const data = new FormData()
data.set('foo', 'bar')
const request = new Request('http://localhost', { method: 'POST', body: data })
request.clone()
console.log('cloned')
node ./index.js
How often does it reproduce? Is there a required condition?
This reproduces reliably 100% of the time.
What is the expected behavior? Why is that the expected behavior?
The process exits with 0. If you replace the request body with any other supported value, the process does exit.
What do you see instead?
The process hangs forever, failing to execute request.clone()
when a Request
instance has FormData
as its body. Seems to be sensitive to FormData
with values. Removing the data.set(...)
call makes the issue go away (nothing to copy while cloning the request, I presume).
Additional information
Originally reported in MSW: mswjs/msw#2078
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
kettanaito commentedon Mar 20, 2024
This is also very likely an issue with Undici since that's what implements
FormData
(nodejs/undici#2413). Reporting it here for posterity mostly.mcollina commentedon Mar 21, 2024
This is fixed in undici v6.7.0. The fix for this will likely come to Node.js v21 very soon. Then we need to think what we want to do for Node.js v18 and v20 (which ships undici v5).
cc @nodejs/undici
kettanaito commentedon Mar 21, 2024
@mcollina, incredible! Is the backport viable for the fix?
mcollina commentedon Mar 21, 2024
I actually have no idea what fixed it, and if we should backport to v5 or just update v18 and v20 to latest undici.
kettanaito commentedon Mar 21, 2024
If possible, updating Undici to the latest sounds like a good strategy 👍
mcollina commentedon Apr 19, 2024
@nodejs/releasers any objections to update to Undici v6 in the next v20 release?
richardlau commentedon Apr 19, 2024
No objections, on the basis that the change is not breaking for users of Node.js, but it may have to be done in a backport pull request as I'm not sure the commits will land cleanly as there were separate updates on Node.js 20 for Undici 5.x.
mcollina commentedon May 2, 2024
@marco-ippolito the updates are already in #52793. Closing as this will come out in the next few days.
https://github.com/nodejs/node/issues/52167