Skip to content

fix: support array hooks in setNotFoundHandler - #175

Merged
metcoder95 merged 1 commit into
fastify:mainfrom
0XFF-96:codex/fix-not-found-hook-arrays
Jul 16, 2026
Merged

fix: support array hooks in setNotFoundHandler#175
metcoder95 merged 1 commit into
fastify:mainfrom
0XFF-96:codex/fix-not-found-hook-arrays

Conversation

@0XFF-96

@0XFF-96 0XFF-96 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

LInk: #174

  • Support array values for setNotFoundHandler preValidation and preHandler hooks.
  • Wrap each hook individually so Fastify receives callable handlers.
  • Preserve callback names for each generated hook span.
  • Add regression coverage for custom 404 handlers using hook arrays.

Root cause

The not-found handler patch passed the entire hook array to handlerWrapper(). The wrapper later called handler.call(...), causing handler.call is not a function and a 500 response.

Verification

  • npm test
  • npm run lint

Signed-off-by: Jimmy li <jli449668@gmail.com>
@0XFF-96
0XFF-96 force-pushed the codex/fix-not-found-hook-arrays branch from 56b06bb to 11090cc Compare July 11, 2026 02:28
@Fdawgs Fdawgs linked an issue Jul 11, 2026 that may be closed by this pull request
2 tasks
@0XFF-96 0XFF-96 closed this Jul 12, 2026
@0XFF-96
0XFF-96 deleted the codex/fix-not-found-hook-arrays branch July 12, 2026 12:21
@0XFF-96
0XFF-96 restored the codex/fix-not-found-hook-arrays branch July 12, 2026 12:25
@0XFF-96 0XFF-96 reopened this Jul 12, 2026
@Tony133
Tony133 requested a review from metcoder95 July 13, 2026 07:45
@metcoder95
metcoder95 merged commit 90f9379 into fastify:main Jul 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: setNotFoundHandler crashes when preValidation or preHandler is an array

2 participants