question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of null` (5.47.0)

See original GitHub issue

Bug 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.

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Superorycocommented, Jul 30, 2021

Electron Forge with Webpack + Typescript

Actually, I’m also using Electron Forge with Webpack + Typescript, and electron-store, never tried ‘npm run make’ before.

One note, I noticed that I can reproduce the error from streamChunksOfCombinedSourceMap.js when I run npm run make and there’s no problems when I run npm start

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.

1reaction
modestfakecommented, Jul 29, 2021

Alright, I was able to reproduce it.

Steps to reproduce:

# https://www.electronforge.io/templates/typescript-+-webpack-template
npx create-electron-app reproduce-webpack-source-error --template=typescript-webpack

cd reproduce-webpack-source-error

npm ls webpack-sources
# repro-webpack-sources-bug@1.0.0 /Users/dev/repro-webpack-sources-bug
# └─┬ @electron-forge/plugin-webpack@6.0.0-beta.59
#   └─┬ webpack@5.47.1
#     └── webpack-sources@3.1.1

# This one works fine after the latest fix
npm start

# This one work for now
npm run make

# But let's install electron-store and init it (https://github.com/sindresorhus/electron-store)
npm i electron-store

Open /reproduce-webpack-source-error/src/index.ts Add

import Store from 'electron-store'

const store = new Store()
# Then run this one more time
npm run make

This 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found