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

Errors appear duplicated in browser console #3008

Closed
gaearon opened this issue Sep 18, 2016 · 4 comments
Closed

Errors appear duplicated in browser console #3008

gaearon opened this issue Sep 18, 2016 · 4 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

I'm submitting a bug report

Webpack version:
1.13.2

Please tell us about your environment:
OSX

Current behavior:

Errors in the browser console appear duplicated, regardless of the loader:

screen shot 2016-09-18 at 12 04 43

screen shot 2016-09-18 at 12 09 33

Expected/desired behavior:

The error message should not be printed twice.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
npm i -g create-react-app
create-react-app mystuff --scripts-version 0.5.1
cd mystuff
npm start

Then make a syntax error in src/App.js or src/App.css and inspect browser output.
You can find the config here.

  • What is the expected behavior?

The error message should not be printed twice.

  • What is the motivation / use case for changing the behavior?

Seeing it printed twice is confusing and annoying.

  • Browser: all
  • Language: all

(I file this in Webpack repo because the error string is passed to WDS already in this form.)

@gaearon
Copy link
Contributor Author

gaearon commented Sep 25, 2016

@SpaceK33z
Copy link
Member

I'll take a look at this soon, so assigning to me so I don't forget. If anyone wants to work at this, feel free to do so.

@SpaceK33z
Copy link
Member

This took some debugging, but I finally found where the issue is :). webpack-dev-server uses stats.toJson() (without parameters), gets the errors property from the resulting object and then passes that to the WebSocket to display the error. This errors property is an array of errors.

However, if .toJson() is used without options, it defaults to adding "error details" in the errors items. These details cause the duplicated message.

To fix this, I see two options:

  1. Have webpack-dev-server use .toJson({ errorDetails: false })
  2. or let the .toJson() method default to errorDetails = false.

I think option 1 is the most safe one, so I'll fix this in WDS.

@SpaceK33z
Copy link
Member

Fixed! This will be released with webpack-dev-server v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants