Catch unhandled promise rejections #196
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
(If you have not already please refer to the contributing guideline as described
here)
When use transaction hooks, if a transaction failed in either establishing or execution phase, an unhandled rejection error happens. The reason is that knex.transaction returns a promise and no error handler is attached to the promise within a turn of the event loop. Unhandled promise rejections are deprecated and it will terminate Node.js process with a non-zero exit code, better to catch them and throw a customized error instead.
Here is a simplified example for your reference:
No.
No.
If so, please mention them to keep the conversations linked together.
Other Information
If there's anything else that's important and relevant to your pull
request, mention that information here. This could include
benchmarks, or other information.
Your PR will be reviewed by a core team member and they will work with you to get your changes merged in a timely manner. If merged your PR will automatically be added to the changelog in the next release.
If your changes involve documentation updates please mention that and link the appropriate PR in feathers-docs.
Thanks for contributing to Feathers! ❤️