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

fix: log unhandled error even if its stack is empty #14619

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- `[jest-cli]` When specifying paths on the command line, only match against the relative paths of the test files ([#12519](https://github.com/facebook/jest/pull/12519))
- [**BREAKING**] Changes `testPathPattern` configuration option to `testPathPatterns`, which now takes a list of patterns instead of the regex.
- [**BREAKING**] `--testPathPattern` is now `--testPathPatterns`
- `[jest-reporters, jest-runner]` Unhandled errors without stack get correctly logged to console ([#14619](https://github.com/facebook/jest/pull/14619))

### Performance

Expand Down
6 changes: 5 additions & 1 deletion packages/jest-reporters/src/CoverageWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export type CoverageWorkerData = {

// Make sure uncaught errors are logged before we exit.
process.on('uncaughtException', err => {
console.error(err.stack);
if (err.stack) {
console.error(err.stack);
} else {
console.error(err);
}
exit(1);
});

Expand Down
6 changes: 5 additions & 1 deletion packages/jest-runner/src/testWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ type WorkerData = {

// Make sure uncaught errors are logged before we exit.
process.on('uncaughtException', err => {
console.error(err.stack);
if (err.stack) {
console.error(err.stack);
} else {
console.error(err);
}
exit(1);
});

Expand Down