Skip to content

devtool=eval interferes with window.onerror, on Chrome. #5681

@savv

Description

@savv

Do you want to request a feature or report a bug?
Report a Bug.

What is the current behavior?
Bundling JS with webpack, using the option devtool: 'eval', adds //@ sourceURL tags that are prepended with webpack:/// ; this, in turn, seems to confuse Chrome, which only sends a "Script Error" to window.error, because it thinks that the error was triggered by a script from a different origin.

If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/savvopoulos/webpack-on-error
Note that you need an HTTP in order to properly repro the issue; file:/// seems to come with its own rules; http server included, needs python3.

  • Build:
    ./build.sh
  • Run:
    ./serve.py

Go to:
http://localhost:8000/index.html - error looks good
Now go to:
http://localhost:8000/dist/index.html - Script Error. :-(
Then: remove devtool: eval from the webpack.config.js - and rerun ./build.sh.
Then, once again, go to:
http://localhost:8000/dist/index.html - error looks good again!

What is the expected behavior?
I was able to get proper error reporting, even with devtool=eval, by manually removing the webpack:/// bit (e.g. open with vim and run :%s/webpack:\/\/\///g).

If this is a feature request, what is motivation or use case for changing the behavior?
(not a feature req)

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
This only happens in Chrome. Safari + Firefox are fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions