Skip to content

Commit

Permalink
fix: handle missing route options (#236)
Browse files Browse the repository at this point in the history
* fix: handle missing route options

* fix: support 4.0 version without routeOptions at all

* chore: return fastify version back

* refactor: get req config w/o function

* refactor: use optional chaining to get config

* refactor: remove extra ?. operator
  • Loading branch information
c0sx authored Sep 24, 2024
1 parent 5dc63c2 commit 96830fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96830fd

Please sign in to comment.