-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Ensure test run failures crash worker #1265
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
Conversation
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.
7e37f44 to
539c741
Compare
|
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', |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)')); |
There was a problem hiding this comment.
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.
The first commit is there to catch more errors. The second commit ensures errors like #1263 are surfaced without the test hanging.