Skip to content

Commit 6a4d64b

Browse files
committedSep 23, 2019
track thrown error when timeout/throws happen during promise waiting
1 parent 5b977e1 commit 6a4d64b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎lib/test.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class Test extends Base {
346346
timeout (options) {
347347
options = options || {}
348348
options.expired = options.expired || this.name
349-
if (this.occupied)
349+
if (this.occupied && this.occupied.timeout)
350350
this.occupied.timeout(options)
351351
else
352352
Base.prototype.timeout.call(this, options)
@@ -867,7 +867,10 @@ class Test extends Base {
867867
// threw while waiting for a promise to resolve.
868868
// probably it's not ever gonna.
869869
if (this.occupied && this.occupied instanceof Waiter)
870-
this.occupied.abort(new Error('error thrown while awaiting Promise'))
870+
this.occupied.abort(Object.assign(
871+
new Error('error thrown while awaiting Promise'),
872+
{ thrown: er }
873+
))
871874

872875
this.process()
873876
}

‎tap-snapshots/test-test.js-TAP.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,12 @@ TAP version 13
32033203
message: error thrown while awaiting Promise
32043204
stack: |
32053205
{STACK}
3206+
thrown:
3207+
!error
3208+
name: Error
3209+
message: poop
3210+
stack: |
3211+
{STACK}
32063212
source: |2
32073213
setTimeout(() => t.threw(new Error('poop')))
32083214
return t.resolveMatch(() => new Promise(() => {}), 'never resolves')

0 commit comments

Comments
 (0)
Please sign in to comment.