Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 950e256

Browse files
committed
Patch AVA to report causes of unhandled rejections
1 parent 47ecc14 commit 950e256

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

patches/ava+5.2.0.patch

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/node_modules/ava/lib/worker/base.js b/node_modules/ava/lib/worker/base.js
2+
index cdd3c4a..b03152b 100644
3+
--- a/node_modules/ava/lib/worker/base.js
4+
+++ b/node_modules/ava/lib/worker/base.js
5+
@@ -126,7 +126,11 @@ const run = async options => {
6+
7+
nowAndTimers.setImmediate(() => {
8+
for (const rejection of currentlyUnhandled()) {
9+
- channel.send({type: 'unhandled-rejection', err: serializeError('Unhandled rejection', true, rejection.reason, runner.file)});
10+
+ channel.send({type: 'unhandled-rejection', err: serializeError('Unhandled rejection', true, rejection.reason, runner.file)});
11+
+ // The `cause` is often much more useful than the error itself, especially for `TypeError: fetch failed`s from `undici`
12+
+ if (rejection.reason?.cause !== undefined) {
13+
+ channel.send({type: 'unhandled-rejection', err: serializeError('Unhandled rejection', true, rejection.reason.cause, runner.file)});
14+
+ }
15+
}
16+
17+
exit(0);

0 commit comments

Comments
 (0)