-
Notifications
You must be signed in to change notification settings - Fork 386
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
chore(build): properly handle worker errors #2434
Conversation
targets.forEach((config) => { | ||
workers(config, (err) => { | ||
if (err) { | ||
return reject(err); | ||
console.error(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this error be displayed 2 times? (here and in in the catch )
What happens when there are multiple errors? e.g. multiple targets generate errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think it would be displayed two times. I figured it was easiest to just log all the exceptions, since as you say there could be multiple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of multiple exceptions we print them all but then reject
with the last one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured. wouldn't be better to reject with an array of exceptions and print them all, only once in the catch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was bad practice to reject with anything but an Error
? But I guess if we're the only ones handling it, then it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I came up with a much simpler solution using Promise.all
and promisify
. No need to do any fancy error handling ourselves; just let Promise.all
handle it.
8caca57
to
cba1810
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Details
In the
lwc
package, in thebuild.js
script, if any of the worker processes throws an error, currently it will just hang forever with no output. This can be confusing. 🙂This PR fixes it so that if any worker throws an error, the process exits with a non-zero exit code and logs the error. I confirmed that this worked by throwing a deliberate
Error
in one of the build workers and confirming that it gave useful error output.Does this PR introduce breaking changes?
No, it does not introduce breaking changes.