Skip to content

Commit a497944

Browse files
committed
feat: add Request context to this
1 parent b505283 commit a497944

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = fp(
5656
function race (opts = globalOpts) {
5757
const { raw, id: reqId } = this
5858
const handleError = typeof opts === 'function' ? true : opts.handleOnError
59-
const cb = typeof opts === 'function' ? opts : opts.onRequestClosed
59+
const cb = (typeof opts === 'function' ? opts : opts.onRequestClosed).bind(this)
6060

6161
if (controllers.has(this)) {
6262
const { controller: ctrl, cbs } = controllers.get(this)

test/index.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ tap.test('fastify-racing#decoration', subtest => {
8585
)
8686
})
8787

88-
tap.test('fastify-racing#promise', { only: true }, subtest => {
88+
tap.test('fastify-racing#promise', subtest => {
8989
subtest.plan(4)
9090

9191
subtest.test('Should handle a request aborted', t => {
92-
t.plan(3)
92+
t.plan(2)
9393

9494
const app = fastify()
9595
// eslint-disable-next-line no-undef
@@ -118,11 +118,10 @@ tap.test('fastify-racing#promise', { only: true }, subtest => {
118118
{
119119
method: 'GET',
120120
path: '/',
121-
signal: abtCtlr.signal
121+
signal: abtCtlr.signal,
122+
pipelining: 0,
122123
},
123-
err => {
124-
t.ok(err)
125-
}
124+
() => {}
126125
)
127126

128127
// Allow a full event loop cycle

0 commit comments

Comments
 (0)