diff --git a/index.js b/index.js index 3e9b888..9fe80cd 100644 --- a/index.js +++ b/index.js @@ -221,7 +221,8 @@ async function fastifyUnderPressure (fastify, opts) { } function onRequest (req, reply, next) { - const _pressureHandler = req.routeOptions.config.pressureHandler || pressureHandler + const config = req.routeOptions?.config ?? req.context.config + const _pressureHandler = config.pressureHandler || pressureHandler if (checkMaxEventLoopDelay && eventLoopDelay > maxEventLoopDelay) { handlePressure(_pressureHandler, req, reply, next, TYPE_EVENT_LOOP_DELAY, eventLoopDelay) return