-
Notifications
You must be signed in to change notification settings - Fork 176
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
Uncaught exceptions thrown from promise chains don't fail tests #708
Comments
Looks like an issue with domains. const Domain = require('domain');
const d = Domain.create();
d.on('error', (err) => console.log(err));
d.run(() => { Promise.resolve().then(() => { setImmediate(() => { throw new Error('test error'); }) }) .catch((err) => { console.log('handled promise rejection!', err) }); });
vs const Domain = require('domain');
const d = Domain.create();
d.on('error', (err) => console.log(err));
d.run(() => { setImmediate(() => { throw new Error('test error'); }); });
|
My understanding is that promises + domains were broken until nodejs/node#12489. Care to give it a shot with latest Node master? |
@cjihrig works!
@Wenzil the solution will be to update to the latest node release when the fix ships. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
I stumbled on a problem with how lab treats errors thrown in the context of a promise chain, but that aren't promise rejections due to being thrown from a separate function stack because of asynchronicity.
It's easier to explain with an example. Here's a failing test:
The error is simply not handled by lab and the process crashes in the first test.
If we add an 'uncaughtException' handler at the process level, the crash is prevented and the first test will eventually timeout, and then the second test will be executed. However, having to wait for the timeout is not desirable.
Lab should handle uncaught exceptions regardless of where they are thrown from.
The text was updated successfully, but these errors were encountered: