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

Fixed error in queue when timeout is 0 #200

Merged
merged 1 commit into from
Feb 10, 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
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' })
})