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

Server side HMR lifecycle hook/exposure #13359

Open
juansebastianl opened this issue Jan 21, 2025 · 2 comments
Open

Server side HMR lifecycle hook/exposure #13359

juansebastianl opened this issue Jan 21, 2025 · 2 comments

Comments

@juansebastianl
Copy link

juansebastianl commented Jan 21, 2025

Describe the problem

Whenever I have a function with side-effects in the init() hook inside of my +hooks.server.js, in my case starting up RabbitMQ consumers, if I'm using vite with hot module reloading, there is no way for to clean up the side effects before a reload. This means I end up spinning 10x+ the number of consumers just doing simple code changes.

Describe the proposed solution

It would be really nice to be able to having something like hot.dispose inside of +hooks.server.ts to be able to clean up the side effects (or even exported from the vite plugin).

Alternatives considered

The current workflow is just to turn off HMR and manually restart on changes, which is painful.

Importance

would make my life easier

Additional Information

No response

@elliott-with-the-longest-name-on-github
Copy link
Contributor

SvelteKit is just a Vite plugin; can you not just use hot.dispose?

@juansebastianl
Copy link
Author

SvelteKit is just a Vite plugin; can you not just use hot.dispose?

I don't think so - I tried import.meta.hot and it wasn't defined in the server. It seems that this is possible in the client (I didn't try but all the examples are client side) but in the +server.hooks.ts it's not defined.

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

No branches or pull requests

2 participants