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

Add a unhandledrejection event handler #3159

Open
kainino0x opened this issue Nov 11, 2023 · 0 comments
Open

Add a unhandledrejection event handler #3159

kainino0x opened this issue Nov 11, 2023 · 0 comments

Comments

@kainino0x
Copy link
Collaborator

kainino0x commented Nov 11, 2023

The unhandledrejection event fires when a promise rejects without having a rejection handler attached yet. This indicates one of two scenarios:

  • We have some async bubble in between creation of the promise and awaiting it, where it can reject before we await. This is bad because it will (intentionally) crash node, but not awful because it can't cause a false positive.
  • There's a bug where the Promise is not awaited at all before the end of the test; this is a bigger problem as it can cause false positives.

We have a lint rule which ensures we don't drop promises on the floor, but it won't catch when we do something like const p = ... and then misuse it.

We should do something at runtime to at least try to catch these. I don't know what exactly, but maybe have it set a flag that's asserted to be false after the end of a "run". We'd probably want a short "sleep" between the end of the last test and the end of the run to give promises an opportunity to reject. There's no obvious place to put this right now, because different runtimes run things differently, but we should try to do something here.

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

No branches or pull requests

1 participant