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.

`eval-source-map` issue with Hot Module Replacement

See original GitHub issue

Bug report

What is the current behavior?

source-map does not work correctly with devtool: eval-source-map when app hot updating. If the hot-updated code causes runtime error, we will get something like:

VM3252 utils.ts:6 Uncaught TypeError: Cannot read property 'b' of undefined
    at echo (VM3252 utils.ts:6)
    at eval (index.ts?a959:5)

in which the stack info is not source-mapped correctly.

If the current behavior is a bug, please provide the steps to reproduce.

I created a demo here: https://github.com/nighca/webpack-eval-source-map. Follow the README and we can reproduce the bug.

What is the expected behavior?

The hot-updated code should be source-mapped correctly, and the stack info of runtime error should be like:

utils.ts?8813:2 Uncaught TypeError: Cannot read property 'b' of undefined
    at echo (utils.ts?8813:2)
    at eval (index.ts?a959:5)

Other relevant information: webpack version: 5.46.0 Node.js version: v14.16.1 Operating System: macOS Additional tools:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

0reactions
AhmedBHameedcommented, Aug 23, 2021

I’m getting the same issue with node server script. I’m using class and trying to call private method using this keyword, but getting undefined context.

So the question, is it chrome issue?

UPDATE: I solved my issues by binding the context with the method inside contstuctor which is a bit off to me but it works!

[...]
constructor() {
	this.method = this.method.bind(this);
}
[...]

Not sure if this is bable issue or webpack honestly! But we hopefully get some explaination.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack hot module replacement (HMR) sourcemaps not ...
There is an issue with HMR and updating the source maps in the DevTools. Typically, the source maps are cached by the browsers...
Read more >
Webpack Hot Module Replacement (HMR) doesn't update ...
I tried different sourcemap types and checked it in Chrome and Firefox with no success. But I think it's a browser level bug....
Read more >
Webpack dev server, Hot reload and source maps - Medium
For development we will be using eval-source-map which provide the original source. To do this we just add this line to our webpack...
Read more >
EvalSourceMapDevToolPlugin - webpack
You can use the following code to replace the configuration option devtool: eval-source-map with an equivalent custom plugin configuration: module.exports ...
Read more >
Hot Module Replacement - SurviveJS
Hot Module Replacement (HMR) builds on top of the WDS. It enables an interface that makes it possible to swap modules live. For...
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