Skip to content
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: log and exit on unhandled promise rejection #670

Merged
merged 1 commit into from
May 20, 2020

Conversation

bchrobot
Copy link
Member

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

To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict`

(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:

  1. brew services stop postgresql
  2. git checkout master
  3. yarn build:server
  4. node --no-deprecation ./build/src/server
  5. Observed that we get raw UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:5432 log and node process remains alive
  6. git checkout fix/log-and-exit-on-unhandled-rejection
  7. yarn build:server
  8. node --no-deprecation ./build/src/server
  9. Observed that we get properly formatted error log and process exits

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Documentation Changes

N/A

Checklist:

  • My code follows the code style of this project.
  • My commit messages follow the Conventional Commits specification.
  • My change requires a change to the documentation.
  • I have included updates for the documentation accordingly.

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)
@bchrobot bchrobot requested a review from ben-pr-p May 20, 2020 11:46
@bchrobot bchrobot merged commit 4eea58c into master May 20, 2020
@bchrobot bchrobot deleted the fix/log-and-exit-on-unhandled-rejection branch May 20, 2020 15:56
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.

2 participants