-
Notifications
You must be signed in to change notification settings - Fork 540
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
isFormDataLike
fails with bundled code
#1952
Labels
bug
Something isn't working
Comments
6 tasks
Adding in the hardcoded class name is incorrect, however using Symbol.toStringTag over the constructor name is a valid fix. Would you like to send in a PR? |
@KhafraDev I believe our isFormData |
ronag
added a commit
that referenced
this issue
Feb 21, 2023
ronag
added a commit
that referenced
this issue
Feb 21, 2023
Amazing, thank you @ronag! Do you know when this might be in the next release? |
anonrig
pushed a commit
to anonrig/undici
that referenced
this issue
Apr 4, 2023
metcoder95
pushed a commit
to metcoder95/undici
that referenced
this issue
Jul 21, 2023
crysmags
pushed a commit
to crysmags/undici
that referenced
this issue
Feb 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Description
If you bundle
undici
withesbuild
(or other bundlers that mangle names), the check in https://github.com/nodejs/undici/blob/main/lib/core/util.js#L378 fails, since the name of theFormData
class is not necessarily equal to"FormData"
. Previously, the name of theFormData
class was hardcoded withbut this was removed in #1742 (https://github.com/nodejs/undici/pull/1742/files#diff-bf6d8875713a8e4d7917687069b9d3c16323b34155573b442c156d77765aa999).
For instance,
esbuild
bundles:to
(or some other number).
Reproducible By
Run
npx esbuild --bundle index.js --outfile=out.js --platform=node --format=cjs && node out.js
The file
body.bin
contains the content:[object FormData]
Expected Behavior
It should contain:
Environment
macOS Ventura arm64, node 18.7
Additional context
This is fixed by changing
isFormDataLike
to checkchunk[Symbol.toStringTag]
rather thanchunk.constructor.name
, or re-adding the hardcoded class name, but I'm not sure if that might break other stuff.The text was updated successfully, but these errors were encountered: