Skip to content

Commit 9e58ee3

Browse files
authored
feat: add function name for hooks (#225)
Signed-off-by: Chiawen Chen <golopot@gmail.com>
1 parent 7424822 commit 9e58ee3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function fastifyRequestContext(fastify, opts, next) {
3131
const hook = opts.hook || 'onRequest'
3232
const hasDefaultStoreValuesFactory = typeof opts.defaultStoreValues === 'function'
3333

34-
fastify.addHook(hook, (req, _res, done) => {
34+
fastify.addHook(hook, function requestContextHook(req, _res, done) {
3535
const defaultStoreValues = hasDefaultStoreValuesFactory
3636
? opts.defaultStoreValues(req)
3737
: opts.defaultStoreValues
@@ -51,7 +51,7 @@ function fastifyRequestContext(fastify, opts, next) {
5151
// in a different async context, as req/res may emit events in a different context.
5252
// Related to https://github.com/nodejs/node/issues/34430 and https://github.com/nodejs/node/issues/33723
5353
if (hook === 'onRequest' || hook === 'preParsing') {
54-
fastify.addHook('preValidation', (req, _res, done) => {
54+
fastify.addHook('preValidation', function requestContextPreValidationHook(req, _res, done) {
5555
const asyncResource = req[asyncResourceSymbol]
5656
asyncResource.runInAsyncScope(done, req.raw)
5757
})

0 commit comments

Comments
 (0)