Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composedPlugin should have its own prefix context #368

Merged
merged 10 commits into from
May 2, 2024

Conversation

jean-michelet
Copy link
Contributor

@jean-michelet jean-michelet commented Mar 8, 2024

Fixes #326

Currently, when autohooks are involved, we observe unexpected behavior, such as setNotFoundHandler associated with the root / prefix even though it is defined in a child folder with its own prefix. This prevents custom configuration of setNotFoundHandler by child and sibling plugins.

It appears that plugins involving autohooks are composed in a parent plugin, I think that's when the prefix context is lost:

fastify.register(composedPlugin)

Not sure how setNotFoundHandler is associated with root prefix when defined in a child plugin but I guess it has something to do with skip-override configured for hookPlugins?

In this PR, I propose to pass the prefix option to the composed plugin, but I'm not sure this is the expected behavior, wdyt?

@jean-michelet jean-michelet changed the title Issue#326 composedPlugin should have its own prefix context Mar 8, 2024
@jean-michelet
Copy link
Contributor Author

Also fails on master: https://github.com/fastify/fastify-autoload/actions/runs/8201748436/job/22433147480?pr=368#step:5:770

@mcollina
Copy link
Member

mcollina commented May 2, 2024

Could you please merge from main? I think the tests will now pass.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

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.

setNotFoundHandler is not encapsulated when called inside autohooks.js
2 participants