fix: log and exit on unhandled promise rejection #670
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.
Description
Log the unhandled promise rejection and exit 1 on unhandled promise rejection.
Motivation and Context
This fixes the issue of pods not restarting on database connection errors. It will also provide
much better visibility into a variety of other unhandled promise rejections we get in Spoke.
Ref: nodejs/node#9523 (comment)
The current node warning suggests
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)
The added behavior will have the same effect.
How Has This Been Tested?
Locally:
brew services stop postgresql
git checkout master
yarn build:server
node --no-deprecation ./build/src/server
UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:5432
log and node process remains alivegit checkout fix/log-and-exit-on-unhandled-rejection
yarn build:server
node --no-deprecation ./build/src/server
Screenshots (if appropriate):
N/A
Types of changes
Documentation Changes
N/A
Checklist: