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

Unhandled promise rejections cause miniflare process termination (Windows, node v16.2.0) #115

Closed
evrys opened this issue Dec 9, 2021 · 3 comments
Labels
enhancement New feature or request fixed-in-next Fixed in next release

Comments

@evrys
Copy link

evrys commented Dec 9, 2021

e.g. if you forget to await a promise, an unhandled promise rejection is thrown causing process termination and requiring manual restart of the dev server. I think I can fix this by catching them in my own code, but it might be good for miniflare to catch them in general as it would better mirror the behavior of a cloudflare worker (which wouldn't die to an unhandled promise rejection-- at least I don't think they do?).

@evrys evrys changed the title Unhandled promise rejections cause miniflare process termination (Windows, node 16) Unhandled promise rejections cause miniflare process termination (Windows, node v16.2.0) Dec 9, 2021
@evrys
Copy link
Author

evrys commented Dec 9, 2021

Hmm actually, I'm not sure that Worker support for the unhandledrejection event is released yet, so this may indeed need to be handled at the miniflare level https://twitter.com/jasnell/status/1447935685319667722

mrbbot added a commit that referenced this issue Dec 16, 2021
...instead, log them. Adds a new `logUnhandledRejections` option.
If a user has an `unhandledrejection` event listener in their
worker, the rejection will only be logged if the user doesn't call
`preventDefault()` on the event.
@mrbbot mrbbot added enhancement New feature or request fixed-in-next Fixed in next release labels Dec 16, 2021
@mrbbot
Copy link
Contributor

mrbbot commented Dec 18, 2021

Hey! 👋 Miniflare 2.0.0-rc.4 has just been released, which no longer crashes on unhandled rejections, logging them instead. You can find the full changelog here and install it with npm i miniflare@next -D. Please let me know if you have any other issues, and feel free to ask questions in the #miniflare channel of the Cloudflare Workers Discord server.

@mrbbot mrbbot closed this as completed Dec 18, 2021
@evrys
Copy link
Author

evrys commented Dec 19, 2021

Great, I'll try it out!

mrbbot added a commit that referenced this issue Jan 7, 2022
...instead, log them. Adds a new `logUnhandledRejections` option.
If a user has an `unhandledrejection` event listener in their
worker, the rejection will only be logged if the user doesn't call
`preventDefault()` on the event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed-in-next Fixed in next release
Projects
None yet
Development

No branches or pull requests

2 participants