Skip to content

Commit

Permalink
Fixed error in queue when timeout is 0 (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopiraccini authored Feb 10, 2023
1 parent 94f0782 commit 3e10bb8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,15 @@ function callWithCbOrNextTick (func, cb) {
}
} else {
if (this._timeout === 0) {
const wrapCb = (err) => {
this._error = err
cb(this._error)
}

if (func.length === 2) {
func(err, cb)
func(err, wrapCb)
} else {
func(err, context, cb)
func(err, context, wrapCb)
}
} else {
timeoutCall.call(this, func, err, context, cb)
Expand Down
14 changes: 14 additions & 0 deletions test/async-await.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,17 @@ test('skip override with promise', (t) => {
return fn
}
})

test('ready queue error', async (t) => {
const app = boot()
app.use(first)

async function first (s, opts) {}

app.ready(function (_, worker, done) {
const error = new Error('kaboom')
done(error)
})

await t.rejects(app.ready(), { message: 'kaboom' })
})

0 comments on commit 3e10bb8

Please sign in to comment.