`UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of null` (5.47.0)
See original GitHub issueBug report
The latest version of webpack (5.47.0
) causes our build pipeline to fail due to some missed null
check. Our project has both the backend and frontend built and deployed as a single unit and no frontend changes were made between a backend-exclusive code change successfully merged and deployed yesterday evening and our builds (now failing) this morning.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Cannot read property 'length' of null (javascript)
When you are trying to read the property length, the system cant as it is trying to deference a null variable. You need...
Read more >[Solved] TypeError: Cannot read property 'length' of null
This error indicates that the code is trying to compute the length property on a null variable. A null variable holds no or...
Read more >Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >Cannot read properties of undefined (reading 'length')
This message indicates that our code expects to have an object with a length property, but that object was not present.
Read more >Typeerror: Cannot Read Property 'length' of Undefined
This error can be triggered with .length if the code is trying to access the property before it has been defined, so there...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually, I’m also using Electron Forge with Webpack + Typescript, and electron-store, never tried ‘npm run make’ before.
Confirm: For 5.47.1, it did fix the ‘length of null’ error from ‘ReplaceSource.js’, with ‘npm run make’, still throw same error from ‘streamChunksOfCombinedSourceMap.js’,
Also, to fix this bug, I think we can just apply this, after I digg into the code:
originalSourceLines = originalSource? originalSource.match(SPLIT_LINES_REGEX): null;
originalSourceLines
is a nullable variable but we missed the null check, that’s it, I think.Alright, I was able to reproduce it.
Steps to reproduce:
Open
/reproduce-webpack-source-error/src/index.ts
AddThis time it should fail. I guess it might be related to
native_modules
but I don’t know how it works. Maybe this part of the Electron Forge Webpack config.