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

fix: run podium processes earlier in Fastify lifecycle #258

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

digitalsadhu
Copy link
Member

Why?

When an error occurs in the Fastify lifecycle, subsequent hooks won't be run and so if an error occurs quite early, the preHandler is not run. This means that pretty much any time an error occurs and the error handler kicks in, reply.app.podium will be an empty object and Podium won't have had a chance to run parsers etc. I suspect this is not what we want and that we would be better off running Podium stuff as early as possible. This PR does this by moving Podium setup into an earlier onRequest hook.

Thoughts @trygve-lie ?

Copy link
Contributor

@trygve-lie trygve-lie left a comment

Choose a reason for hiding this comment

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

Good catch. I agree this is a good thing to do 💯

@digitalsadhu digitalsadhu merged commit 9ba4f45 into master Jun 3, 2024
9 checks passed
@digitalsadhu digitalsadhu deleted the run_layout_process_earlier branch June 3, 2024 22:16
Copy link

github-actions bot commented Jun 3, 2024

🎉 This PR is included in version 3.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@wkillerud
Copy link
Contributor

I ended up reverting this in #278 because of a plugin in our ecosystem that ran on preHandler and placed things on the context, but since the layout handler ran earlier its values didn't get processed and forwarded to podlets.

If this ends up causing problems again we'll have to work with our ecosystem of plugins to agree on when in the lifecycle they should run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants