Handle async errors#4016
Conversation
|
I have added some basic cancelation handling into the queue_runner which makes the test in |
|
Hi there! Really looking for this feature in jest. Any hopes of getting this merged soon? Thank you! |
9280702 to
e70e6b8
Compare
|
This should be ready, I am not sure why the CI is failing |
|
hey @wtgtybhertgeghgtwtg! do you mind giving this a look? :) |
|
It looks like the issue is with resolving |
|
@wtgtybhertgeghgtwtg any pointers on how I can help debug this? |
|
Nothing particularly helpful.
|
ee483bf to
b8e30ff
Compare
|
c4dc4b5 to
cd872fa
Compare
|
@wtgtybhertgeghgtwtg circle is happy now :) appveyor fail seems unrelated |
|
@aaronabramov @wtgtybhertgeghgtwtg any more feedback? I would really like to see this merged soon as it is currently blocking me from migrating a bunch of projects over to jest. |
| } | ||
|
|
||
| // Make sure uncaught errors are logged before we exit. | ||
| process.on('uncaughtException', err => { |
There was a problem hiding this comment.
You cannot remove this, this is not related to tests.
| import type {RawModuleMap} from 'types/HasteMap'; | ||
|
|
||
| // Make sure uncaught errors are logged before we exit. | ||
| process.on('uncaughtException', err => { |
There was a problem hiding this comment.
We also need to keep this one. The workers don't exclusively run Jasmine, and uncaught errors outside of Jasmine (like when no test is run) need to keep working. Is there a concept of "bubbling" in node's exception handling? I'm fine if this handler is disabled while the other exception handler is active, but at least one of the two needs to always be active.
There was a problem hiding this comment.
I tried making it work with these handlers in place, but the issue was that as soon as they are here I am unable to capture the exceptions in Jasmine. (Same for the one in coverage_worker`). Is there an easy way to detect what is currently being run, so I can switch between those?
There was a problem hiding this comment.
I'm not sure, I would prefer some sort of nesting, where this handle here is the parent and the other handler you install is the child. Not sure how to make it work elegantly right now :(
There was a problem hiding this comment.
I have pushed a version that removes and restores the listeners from jasmine, which seems to work well.
| }; | ||
|
|
||
| return options.queueableFns.reduce( | ||
| const res = options.queueableFns.reduce( |
cd872fa to
885fdd8
Compare
|
I was quite heavily against this approach, but I like the solution we ended up with because it captures all uncaught exceptions without overwriting setTimeout etc. for every single test, and something we should do regardless. Good work. I'll spend some time testing this soon and giving it a thorough review, but we'll try to get this into Jest 21. |
|
This looks solid, so I'm went ahead and merged it, but I'm somewhat scared that this is going to mess everything up in some subtle way and we'll find out in a month or two ;) It's a scary change, but thank you @dignifiedquire for proposing it and making a PR. If you'd like to catch errors thrown in timer functions, we do have |
|
🎉 great to see this merged, I hope the subtle breakages are not too bad ;) Regarding the timers, thanks for the pointer I'll take a look in the next days and see if I can figure it out. |
|
Published |
|
@cpojer not sure that publish (or my install) works as expected. I am not getting any jest binary anymore after installing. If I run not even listing a |
|
@dignifiedquire not sure what you did, but you definitely didn't install Jest. |
|
I think I hit a bug/feature in yarn, running |
|
ohhh that's possible… |
|
Perhaps this is the wrong place to comment, but I'm fairly concerned about the change in semantics around the asynchronous If the pre-21 For example, the event argument received by the I realize that interpreting arguments to Sorry about the drive-by FUD. Just thought I'd mention it because this has become a subject of discussion internally. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |

The goal is to resolve the issues in #2059.
General ideas are
uncaughtExceptionandunhandledRejectionhandlers around the test suite executionI have gotten 2. working, but ran into an issue with 1. I am able to catch the exceptions and set the errors from
Env.js, but there is currently no way to cancel a spec run. To enable this I would need to changequeue_runner.jssuch that it allows for cancellation. Before I go on I would like to get some feedback on this.PS: This is the same approach that mocha currently takes to handle these: https://github.com/mochajs/mocha/blob/master/lib/runner.js#L681