Skip to content
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

Add null check to avoid TypeError: Cannot read properties of undefined (reading 'call') #18021

Open
fregante opened this issue Jan 29, 2024 · 2 comments

Comments

@fregante
Copy link

fregante commented Jan 29, 2024

Feature request

Note that this is not a bug report, this is a UX improvement ticket. It won't actually solve the underlying issue but it might help webpack users understand it better.

What is the expected behavior?

Occasionally webpack fails to properly load modules and it fails on this line, causing:

And others like it: https://github.com/webpack/webpack/issues?q=is:issue+sort%253Aupdated-desc+%2522Cannot+read+properties+of+undefined%2522+in%253Atitle+is%253Aclosed++call

What is motivation or use case for adding/changing the behavior?

The error is in webpack's own code and it's far removed from the cause.

How should this be implemented in your opinion?

Catching the error and rewording it will help people find a solution.

A better error would look like this, including as much information as possible regarding its context

"The module sugar/free.js could not be loaded from './wood-cake.js' etc"

Are you willing to work on this yourself?

If the fix looks like this yes:

+ if (typeof __webpack_modules__[moduleId] !== 'function') {
+ 	throw new Error(`The module xyz could not be loaded`)
+ }
  __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
@alexander-akait
Copy link
Member

Feel free to send a PR, but let's do it only for dev enviroment to avoid extra runtime

@aman8218
Copy link

can you provide more detail relating to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority - Low
Development

No branches or pull requests

4 participants