Skip to content

Fix error handling in compiler watch() and run() #157

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

Merged
merged 1 commit into from
Dec 12, 2016

Conversation

SpaceK33z
Copy link
Member

What kind of change does this PR introduce?

Bugfix

Did you add tests for your changes?

Yes.

Summary

See #156. When the compiler wanted to report an error in the bundle (e.g. because of a plugin), it would throw the error and quit the process.

I've changed this to work more like the webpack watch mode; it shows the error with console.error but it keeps running (because the error can be fixed with a new compilation).

Optionally, it's possible to hide / customize this error by using options.error.

Does this PR introduce a breaking change?

Not really; previously the process would quit and now it doesn't.

Other information

Fixes #156

This changes it to be more like how webpack's watch mode handles it;
if the compiler throws an error in `watch()` or `run()`, the middleware
should continu to run instead of quitting.
@hansl
Copy link

hansl commented Dec 11, 2016

Never mind my last message.

This PR works, partially. The error message shows up in the console properly, but the compilation still hangs. In this example I throw new Error('hello world'):

🏠  ng serve
** NG Live Development Server is running on http://localhost:4200. **
 10% building modules 2/2 modules 0 activeError: hello world
    at /Users/hans/Sources/angular-cli/packages/@ngtools/webpack/src/plugin.ts:235:19
    at process._tickCallback (internal/process/next_tick.js:103:7)
 69% building modules 678/679 modules 1 active ...ns/Sources/_Temp/my-project/src asyncwebpack: wait until bundle finished: /worker.js

@hansl
Copy link

hansl commented Dec 11, 2016

LGTM.

@SpaceK33z SpaceK33z merged commit 07064f0 into master Dec 12, 2016
@SpaceK33z SpaceK33z deleted the proper-err-reporting branch December 12, 2016 21:04
@SpaceK33z
Copy link
Member Author

Thanks for verifying @hansl.

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

Successfully merging this pull request may close these issues.

Errors in async tasks cause webpack to hang
2 participants