-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 |
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: