Skip to content

Commit

Permalink
track thrown error when timeout/throws happen during promise waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 23, 2019
1 parent 5b977e1 commit 6a4d64b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class Test extends Base {
timeout (options) {
options = options || {}
options.expired = options.expired || this.name
if (this.occupied)
if (this.occupied && this.occupied.timeout)
this.occupied.timeout(options)
else
Base.prototype.timeout.call(this, options)
Expand Down Expand Up @@ -867,7 +867,10 @@ class Test extends Base {
// threw while waiting for a promise to resolve.
// probably it's not ever gonna.
if (this.occupied && this.occupied instanceof Waiter)
this.occupied.abort(new Error('error thrown while awaiting Promise'))
this.occupied.abort(Object.assign(
new Error('error thrown while awaiting Promise'),
{ thrown: er }
))

this.process()
}
Expand Down
6 changes: 6 additions & 0 deletions tap-snapshots/test-test.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,12 @@ TAP version 13
message: error thrown while awaiting Promise
stack: |
{STACK}
thrown:
!error
name: Error
message: poop
stack: |
{STACK}
source: |2
setTimeout(() => t.threw(new Error('poop')))
return t.resolveMatch(() => new Promise(() => {}), 'never resolves')
Expand Down

0 comments on commit 6a4d64b

Please sign in to comment.