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

feat: add Request context to this #43

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = fp(
function race (opts = globalOpts) {
const { raw, id: reqId } = this
const handleError = typeof opts === 'function' ? true : opts.handleOnError
const cb = typeof opts === 'function' ? opts : opts.onRequestClosed
const cb = (typeof opts === 'function' ? opts : opts.onRequestClosed).bind(this)

if (controllers.has(this)) {
const { controller: ctrl, cbs } = controllers.get(this)
Expand Down
11 changes: 5 additions & 6 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ tap.test('fastify-racing#decoration', subtest => {
)
})

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

subtest.test('Should handle a request aborted', t => {
t.plan(3)
t.plan(2)

const app = fastify()
// eslint-disable-next-line no-undef
Expand Down Expand Up @@ -118,11 +118,10 @@ tap.test('fastify-racing#promise', { only: true }, subtest => {
{
method: 'GET',
path: '/',
signal: abtCtlr.signal
signal: abtCtlr.signal,
pipelining: 0,
},
err => {
t.ok(err)
}
() => {}
)

// Allow a full event loop cycle
Expand Down
Loading