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
23.2 breaks a few packages that use json trough webpack (date-fns) #55826
Linux arch 6.11.6-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Fri, 01 Nov 2024 03:30:35 +0000 x86_64 GNU/Linux
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?
npm run build
> next build
▲ Next.js 15.0.3
- Environments: .env
✓ Linting and checking validity of types
Creating an optimized production build ...
Failed to compile.
./node_modules/react-remove-scroll/dist/es2015/Combination.js + 22 modules
Unexpected end of JSON input
./node_modules/date-fns/format.js + 21 modules
Unexpected end of JSON input
./node_modules/date-fns/locale/fr.js + 5 modules
Unexpected end of JSON input
> Build failed because of webpack errors
> node23err@1.0.0 build
> webpack
assets by status 0 bytes [cached] 1 asset
orphan modules 1.53 MiB [orphan] 826 modules
./src/index.js + 42 modules 107 KiB [built] [code generated]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in ./src/index.js + 42 modules
Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at ConcatenationScope.matchModuleReference (/home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/ConcatenationScope.js:132:13)
at ConcatenatedModule.codeGeneration (/home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/optimize/ConcatenatedModule.js:1192:41)
at /home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/Compilation.js:3505:22
at /home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/Cache.js:97:5
at Hook.eval [as callAsync] (eval at create (/home/thaun/Documents/Projects/node23err/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Cache.get (/home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/Cache.js:79:18)
at ItemCacheFacade.get (/home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/CacheFacade.js:115:15)
at Compilation._codeGenerationModule (/home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/Compilation.js:3498:9)
at /home/thaun/Documents/Projects/node23err/node_modules/webpack/lib/Compilation.js:3403:11
webpack 5.96.1 compiled with 1 error and 1 warning in 1098 ms
And we run this very very very many times, and in some cases buffer is just <Buffer > using 5b2267657444656661756c744f7074696f6e73225d as a value, I can't reproduce it in its pure form, but the variable stack is like this
Using match[2].split("").join("").toString(), you recreate string, something is really wrong with the strings/buffers, we can rewrite it like this, but I think that the main problem lies in another aspect and soon there will be other reports, perhaps no less confusing...
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.
Activity
avivkeller commentedon Nov 12, 2024
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
ThomasAunvik commentedon Nov 12, 2024
@redyetidev
I managed to make a minimal reproduce it with just webpack and date-fns
https://github.com/ThomasAunvik/node232-err-json
npm run buildError i then recieved:
avivkeller commentedon Nov 12, 2024
Have you reported this to Webpack yet?
ThomasAunvik commentedon Nov 12, 2024
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.
targos commentedon Nov 12, 2024
I'm bisecting.
alexander-akait commentedon Nov 12, 2024
@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
<Buffer >using5b2267657444656661756c744f7074696f6e73225das a value, I can't reproduce it in its pure form, but the variable stack is like thistargos commentedon Nov 12, 2024
avivkeller commentedon Nov 12, 2024
😅
alexander-akait commentedon Nov 12, 2024
I'm trying to reproduce it in its pure form but without success, we have:
and it failed with values :
ThomasAunvik commentedon Nov 12, 2024
I tried reconstructing the match, and it passed.
@alexander-akait
Could it be a regex part that makes the issue? Doing the string directly doesn't do the same issue.
Tried running this, though I did not receive the similar result trough node.
alexander-akait commentedon Nov 12, 2024
@ThomasAunvik
Honestly I don't think so, this code works since version 10 of Node.js
alexander-akait commentedon Nov 12, 2024
Using
match[2].split("").join("").toString(), you recreate string, something is really wrong with the strings/buffers, we can rewrite it like this, but I think that the main problem lies in another aspect and soon there will be other reports, perhaps no less confusing...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
2 remaining items
chenrui333 commentedon Nov 16, 2024
👋 any update on this thread? Thanks!
avivkeller commentedon Nov 16, 2024
See #55828
Revert "src: migrate `String::Value` to `String::ValueView`"
chore: downgrade Node.js to 23.1.0
chore: update aqua (#49)
Revert "src: migrate `String::Value` to `String::ValueView`"
AYColumbia commentedon Nov 18, 2024
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.
react-test-app
If you comment out the line below from App.js, it will build fine in production mode.
import { Tooltip } from 'react-tooltip';
If you install Yup, you should get the same error building if you include
import * as Yup from 'yup';in App.js.Pin node docker version to avoid "Unexpected end of JSON input" webpa…
Bump Node version (fix for nodejs/node#55826)
Fix node v23.2.0 regression causing a build error
Revert node v23.2 workaround
ci: build with Node 24 so ncc's module concatenation does not hit the…