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

How to specify onClose hooks execution order among plugins #1018

Closed
giovanni-bertoncelli opened this issue Mar 27, 2024 · 10 comments
Closed
Labels
help wanted Extra attention is needed

Comments

@giovanni-bertoncelli
Copy link

💬 Question here

Is there any way to specify which onClose (or preClose) hooks from each plugin should be executed before the others? I have some plugins that rely on other main plugins in order to execute correctly their onClose hooks.

E.G.: Some plugins need the database plugin in order to perform some cleaning operations on the database before closing the server. If the database plugin gets torn down before the plugin, the database client results disconnected.

Your Environment

  • node version: 20
  • fastify version: >=4.23.2
  • os: Mac
@giovanni-bertoncelli giovanni-bertoncelli added the help wanted Extra attention is needed label Mar 27, 2024
@climba03003
Copy link
Member

Currently, no.
But I see the needs of this feature.

@giovanni-bertoncelli
Copy link
Author

Thank you @climba03003

If when wrapping the plugin with fastify-plugin I specify some dependencies, these are respected only on server bootstrap or also on teardown? Or it does not change anything in the latter case?

@metcoder95
Copy link
Member

It works on startup, not on teardown; the feature seems quite interesting, but it will require to creation of a graph of plugins for its dependency mapping.
I believe this can be implemented within fastify but its something that avvio might get some benefit from

@giovanni-bertoncelli
Copy link
Author

Thank you @metcoder95. If this feature can be interesting, what would be the next steps?

@metcoder95
Copy link
Member

A PR drafting the idea will be very welcomed

@giovanni-bertoncelli
Copy link
Author

A PR drafting the idea will be very welcomed

Fastify or avvio?

@metcoder95
Copy link
Member

I'd suggest fastify first but we can re-take it from there and evaluate where it might have more sense

@giovanni-bertoncelli
Copy link
Author

Ok, maybe first I can file an issue in fastify? I have no idea where to start with the PR

@metcoder95
Copy link
Member

Oh, good call; I thought we were in fastify, now I see we are on help, sorry. Let me transfer refer an issue there

@metcoder95
Copy link
Member

Closing in favor of fastify/fastify#5375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants