-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
23.2 breaks a few packages that use json trough webpack (date-fns) #55826
Comments
Hi! Can you provide a minimal reproduction? "next build" runs a lot of different steps, so it can be hard to pinpoint the exact issue |
I managed to make a minimal reproduce it with just webpack and date-fns https://github.com/ThomasAunvik/node232-err-json
Error i then recieved:
|
Have you reported this to Webpack yet? |
No, but i can make one. I was unsure if it could be a node issue or a webpack, as I assume it would break compatability. |
I'm bisecting. |
@targos @ThomasAunvik Some kind of regression with buffers, we have:
And we run this very very very many times, and in some cases buffer is just |
|
😅 |
I'm trying to reproduce it in its pure form but without success, we have: static matchModuleReference(name) {
const match = MODULE_REFERENCE_REGEXP.exec(name);
if (!match) return null;
const index = Number(match[1]);
const asiSafe = match[5];
try {
JSON.parse(Buffer.from(match[2], "hex").toString("utf-8"))
} catch (e) {
console.log(`"${match[2]}"`);
console.log(`"${Buffer.from(match[2], "hex")}"`);
console.log(`"${Buffer.from(match[2], "hex").toString("utf-8")}"`);
}
return {
index,
ids:
match[2] === "ns"
? []
: JSON.parse(Buffer.from(match[2], "hex").toString("utf-8")),
call: Boolean(match[3]),
directImport: Boolean(match[4]),
asiSafe: asiSafe ? asiSafe === "1" : undefined
};
} and it failed with values :
|
I tried reconstructing the match, and it passed. Buffer.from(match[2].split("").join("").toString(),"hex").toString("utf-8")) Could it be a regex part that makes the issue? Doing the string directly doesn't do the same issue. const name = "__WEBPACK_MODULE_REFERENCE__10_5b2267657444656661756c744f7074696f6e73225d_call_directImport_asiSafe1__"
const MODULE_REFERENCE_REGEXP =
/^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_directImport)?(?:_asiSafe(\d))?__$/;
const match = MODULE_REFERENCE_REGEXP.exec(name);
JSON.parse(Buffer.from(match[2], "hex").toString("utf-8")); Tried running this, though I did not receive the similar result trough node. |
Honestly I don't think so, this code works since version 10 of Node.js |
Using We don't really do anything special, you can use the repository - https://github.com/ThomasAunvik/node232-err-json and see that the string being sent does not contain anything unusual |
👋 any update on this thread? Thanks! |
See #55828 |
This reverts commit 45c6a9e. PR-URL: #55828 Fixes: #55826 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
* chore: update aqua * chore: downgrade Node.js to 23.1.0 - nodejs/node#55826
This reverts commit 45c6a9e. PR-URL: #55828 Fixes: #55826 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
I just found this thread and ran into the issue last Friday. I was able to reproduce the issue with a simple react app. I created a repo for it to see if the same happens to anyone who wants to try it out please. The development build should succeed and production should fail with the "Unexpected..." error. If you comment out the line below from App.js, it will build fine in production mode. If you install Yup, you should get the same error building if you include |
…ck error Some kind of regression, not a lot of detail currently. See: - webpack/webpack#18963 - nodejs/node#55826
This reverts commit 45c6a9e. PR-URL: nodejs#55828 Fixes: nodejs#55826 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
This reverts commit 45c6a9e. PR-URL: nodejs#55828 Fixes: nodejs#55826 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Version
v23.2.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Use a package that includes for example date-fns on a NextJS project.
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior? Why is that the expected behavior?
To build
What do you see instead?
Additional information
Seems to be a newly arrived issue only for 23.2.
Tested with 23.1 and 23.0 with no issue.
The text was updated successfully, but these errors were encountered: