Skip to content

Feat/hooks params positional - #6992

Open
mv-estrela wants to merge 3 commits into
fastify:mainfrom
mv-estrela:feat/hooks-params-positional
Open

Feat/hooks params positional#6992
mv-estrela wants to merge 3 commits into
fastify:mainfrom
mv-estrela:feat/hooks-params-positional

Conversation

@mv-estrela

Copy link
Copy Markdown

Replaces #6984 (moved from main to dedicated branch)

fix: standardize application hook parameters

All six application hooks now receive instance as the first parameter, consistent with this binding from #5675. onRegister receives newInstance as second parameter for parent/child disambiguation.

Closes #4967

Checklist

Marcos Vinicius Mesquita Estrela added 2 commits August 27, 2026 16:32
All fix application hooks now reveive  as the first parameter,
consistent with  bing from fastify#5675.
onRegister receives  as second parameter for
parent/child disambiguation

Closes fastify#4967
@github-actions github-actions Bot added documentation Improvements or additions to documentation typescript TypeScript related labels Aug 28, 2026
@Fdawgs
Fdawgs requested a balanced review from Copilot August 28, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Standardizes Fastify application hooks to receive the relevant instance as their first positional parameter.

Changes:

  • Updates hook runtime invocation and async arity validation.
  • Revises TypeScript signatures and runtime/type tests.
  • Updates hook documentation and examples.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
fastify.js Updates async hook arity validation.
lib/hooks.js Passes instances to lifecycle application hooks.
lib/plugin-override.js Passes parent and child instances to onRegister.
lib/route.js Passes the instance to onRoute.
types/hooks.d.ts Updates application hook signatures.
test/types/hooks.tst.ts Updates hook type assertions.
test/hooks.test.js Updates onRoute and onRegister tests.
test/hooks-async.test.js Adds onRegister arity tests.
test/hooks.on-ready.test.js Updates onReady callbacks.
test/hooks.on-listen.test.js Updates onListen callbacks.
test/close.test.js Updates preClose callbacks.
test/schema-feature.test.js Updates schema-related onReady hooks.
test/route.2.test.js Updates route hook signatures.
test/route.6.test.js Updates route hook signatures.
test/route.8.test.js Updates route hook signatures.
test/route-prefix.test.js Updates route-prefix hook signature.
examples/hooks.js Updates the hook example.
docs/Reference/Hooks.md Documents positional hook parameters.
docs/Reference/TypeScript.md Updates TypeScript hook documentation.
docs/Guides/Plugins-Guide.md Updates the plugin hook example.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/hooks-async.test.js Outdated
Prevents test from passing silently if the validation guard is removed

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marcos Vinicius Mesquita Estrela <85261540+mv-estrela@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApplicationHooks have inconsistent reference to instance

2 participants