Skip to content

fix: handle unexpected errors - #2368

Merged
3 commits merged into
masterfrom
feat/handle-unexpected-errors
Nov 29, 2021
Merged

fix: handle unexpected errors#2368
3 commits merged into
masterfrom
feat/handle-unexpected-errors

Conversation

@ghost

@ghost ghost commented Nov 16, 2021

Copy link
Copy Markdown

Ensure unexpected errors are handled with Exit Code 2 rather than the NodeJS default 1. We use 1 for vulns found.

Node 16 now uses Exit Code 1 for unhandledRejections (rather than only logging), so this also makes us consistent across different Node versions.

https://nodejs.org/en/blog/release/v15.0.0/#throw-on-unhandled-rejections-33021

Note for Reviewers

When reviewing, it's best to review through each commit.

I've moved a file and placed a new file in its old place. To avoid losing history, these two steps are in separate commits.

If I didn't do this, git will squash the two changes to look like I deleted a bunch of code and created a new file with a bunch of new code. Obviously, that's not correct. This is what GitHub's PR interface also shows, but it's not how it looks in history with separate commits.

Notes

  • Add a test for it. Probably can't test via CLI acceptance tests or unit tests as it requires "unexpected" errors and the process needs to be exiting. Probably can write some sort of separate acceptance test which uses the same helper function.

@ghost
ghost marked this pull request as ready for review November 16, 2021 13:49
@ghost
ghost requested review from a team as code owners November 16, 2021 13:49
@ghost
ghost requested review from JCheung2004, Jdunsby and almog27 November 16, 2021 13:49

@maxjeffos maxjeffos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change

@ghost ghost mentioned this pull request Nov 16, 2021
@ghost
ghost force-pushed the feat/handle-unexpected-errors branch 6 times, most recently from 713d244 to 738efe5 Compare November 19, 2021 20:40
@ghost ghost mentioned this pull request Nov 25, 2021
4 tasks

@ghost ghost left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review based on in-person discussions.

* This function can only be used once in the same process. If you have multiple
* callables needing this, compose them into a single callable.
*/
export async function callHandlingUnexpectedErrors(

@ghost ghost Nov 25, 2021

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxjeffos how about "safelyCall". Seems like a more minimal solution (vs. inventing an understandable DSL). Might be too generic...

Comment thread src/lib/unexpected-error.ts
Jahed Ahmed added 3 commits November 25, 2021 20:54
Ensure unexpected errors are handled with Exit Code 2 rather than the NodeJS default 1. We use 1 for vulns found.

Node 16 now uses Exit Code 1 for unhandledRejections (rather than only logging), so this also makes us consistent across different Node versions.
Need to wrap index logic in an error
handler but doing so will lose file history. This commit will be followed by a new index.js
@ghost
ghost force-pushed the feat/handle-unexpected-errors branch from 738efe5 to a8835ab Compare November 25, 2021 20:55
@ghost

ghost commented Nov 25, 2021

Copy link
Copy Markdown

This PR modifies files linked to issues tracked in Stepsize.

You might want to review their status, priority, and scope.

 Mention [stepsize] in a comment if you'd like to report some technical debt. See examples here.

@ghost
ghost merged commit 9dafe39 into master Nov 29, 2021
@ghost
ghost deleted the feat/handle-unexpected-errors branch November 29, 2021 11:42
This pull request was closed.
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.

1 participant