From 09987249f9263d27e99b70410b3439b0cb4989e7 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Tue, 18 Jun 2024 06:36:30 -0400 Subject: [PATCH] fix deprecation warning --- index.js | 2 +- test/pressurehandler.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 52828d4..8162dba 100644 --- a/index.js +++ b/index.js @@ -221,7 +221,7 @@ async function fastifyUnderPressure (fastify, opts) { } function onRequest (req, reply, next) { - const _pressureHandler = req.context.config.pressureHandler || pressureHandler + const _pressureHandler = req.routeOptions.config.pressureHandler || pressureHandler if (checkMaxEventLoopDelay && eventLoopDelay > maxEventLoopDelay) { handlePressure(_pressureHandler, req, reply, next, TYPE_EVENT_LOOP_DELAY, eventLoopDelay) return diff --git a/test/pressurehandler.test.js b/test/pressurehandler.test.js index 5fb1390..3956347 100644 --- a/test/pressurehandler.test.js +++ b/test/pressurehandler.test.js @@ -268,7 +268,7 @@ test('event loop utilization', { skip: !isSupportedVersion }, t => { test('event loop delay (NaN)', { skip: !isSupportedVersion }, t => { t.plan(5) - const mockedUnderPressure = t.mock('../index', { + const mockedUnderPressure = t.mockRequire('../index', { perf_hooks: { monitorEventLoopDelay: () => ({ enable: () => { },