Skip to content

Conversation

@novemberborn
Copy link
Member

@novemberborn novemberborn commented Feb 15, 2017

The first commit is there to catch more errors. The second commit ensures errors like #1263 are surfaced without the test hanging.

This allows errors from the exit logic to propagate to the runner.
Errors that occur inside the runner are treated as uncaught exceptions.
This prevents them from being swallowed in the promise chain, causing
the test to hang.
@novemberborn novemberborn force-pushed the ensure-test-run-failures-crash-worker branch from 7e37f44 to 539c741 Compare February 15, 2017 18:25
@novemberborn novemberborn changed the title wip! Ensure test run failures crash worker Ensure test run failures crash worker Feb 15, 2017
@novemberborn
Copy link
Member Author

Added tests to last commit. Let's hope they pass in CI 😄

lib/main.js Outdated
// Avoid using serializeError
const err = new Error('Runner failed with an unserializable exception');
exception = {
name: 'Error',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nitpick, but would prefer err.name here just for consistency with the other props and more future proof if we decide to change the error type or something.

lib/main.js Outdated
exception = serializeError(err);
} catch (_) {
// Avoid using serializeError
const err = new Error('Runner failed with an unserializable exception');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, should we put this logic in serializeError so it handles reporting about unserializable exceptions everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only called in three places. I'd prefer letting the error propagate correctly, and then treating it as an uncaught exception.

That said I've changed this code to process.emit('uncaughtException', err) and moved the fallback stuff to the uncaughtException handler in test-worker.js.

import test from '../../../';

test(() => {
return Promise.reject(new Error('Hi :)'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would look better to use async function here and throw instead. Same with the below fixture.

@sindresorhus sindresorhus merged commit 9cea60d into master Feb 18, 2017
@sindresorhus sindresorhus deleted the ensure-test-run-failures-crash-worker branch February 18, 2017 08:56
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

Successfully merging this pull request may close these issues.

3 participants