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

Figure out the best way to address unhandled promise rejections #390

Open
davewasmer opened this issue Sep 9, 2017 · 4 comments
Open

Figure out the best way to address unhandled promise rejections #390

davewasmer opened this issue Sep 9, 2017 · 4 comments
Milestone

Comments

@davewasmer
Copy link
Collaborator

Should we add our own unhandledRejection hook that prints out more useful debug info? How do we handle the change in Node 8 (I think) that throws on unhandledRejections

@seawatts
Copy link
Contributor

seawatts commented Oct 2, 2017

What are you thinking for this? I have run into this problem a lot already with my app.

@davewasmer
Copy link
Collaborator Author

Not sure yet, exactly.

Here's my gut reaction: unhandled rejections should throw and crash the server process, regardless of whether Node will do this for us[1]. Especially with the prevalence of async/await throughout Denali, which means lots of normally synchronous throws will end up wrapped as promise rejections, and the best thing to do with an uncaught exception is to crash the process and restart. Unhandled rejections are semantically equivalent[2] to a error thrown without a try/catch block to handle it, and those crash the process, so rejections should as well.

Now, what we actually do with the unhandled rejection before crashing - not entirely sure. Based on the linked thread above, it seems like basically all I/O operations might be unsafe once an unhandled exception occurs. But obviously crashing silently is useless. So my thought is we try to invoke the app's Logger.error method with the error, then crash?


  • [1] Seems like Node 8 does not implement this, it just continues to warn that future versions will.
  • [2] Most of the time. You could be using Promises for async control flow, with a rejection indicating something like break;, and it may be impossible for the wrapped code to actually throw an exception. In that scenario, you'd have to add a .catch(() => {}) to make Node happy, but that seems like a small price to pay vs. allowing applications to continue in an undefined state.

@seawatts
Copy link
Contributor

seawatts commented Oct 2, 2017 via email

@davewasmer
Copy link
Collaborator Author

Ah, sorry, should have clarified - the Denali runtime framework won't do anything to restart itself, it will just crash.

We haven't fleshed out the deployment story very well yet, so perhaps there will be a denali server --production that would include automatic restarts, but that would be the CLI running as an daemon and restarting child server processes.

@davewasmer davewasmer added this to the v0.2.0 milestone Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants