-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix startup problems (fix for #1417) #1419
Conversation
…ack handler. Reference: issue: #1417
@Borewit thanks :] appreciate you fixing it. I thought I must be doing something stupid. I'll edit my code manually until it gets merged. |
No problem @dbrowne24 Alternatively you can checkout the fixed branch directly:
|
- use forEach instead of map (because return value was ignored) - use Promise.all instead of parallel, because tasks are already Promise based. Fewer callbacks.
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.
Great, we also get rid of a dep using promise all
@feross please review with priority. |
Able to reproduce on
|
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.
Thanks for reviewing guys. |
}) | ||
Promise.all(tasks) | ||
.then(() => cb(null, saved)) | ||
.catch(err => cb(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.
This is not the correct way to call an error callback with a promise. It's an easy mistake to make.
The .catch
will catch more than just the promise rejections from the tasks
array. It will also catch any exceptions thrown from the handler in .then()
which means that if the cb
function throws an exception, then we'll catch it here.
Instead we should use .then(success, fail)
. I'll send a PR.
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.
PR here: #1679
Reference: issue: #1417
A promise resolve result ended up as an err argument in the callback, causing initialization of application data to fail.