Feat/hooks params positional - #6992
Open
mv-estrela wants to merge 3 commits into
Open
Conversation
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
2 tasks
Contributor
There was a problem hiding this comment.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
npm run test && npm run benchmark --if-presentand the Code of conduct