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

Cleanup on vite restart. #13395

Closed
4 tasks done
olafurw opened this issue May 31, 2023 · 1 comment
Closed
4 tasks done

Cleanup on vite restart. #13395

olafurw opened this issue May 31, 2023 · 1 comment

Comments

@olafurw
Copy link

olafurw commented May 31, 2023

Description

There can be many situations when you need to clean up or release a resource when a vite instance restarts, like after a config edit. You might have to close a db connection, there might be files that need to be cleared or reset, etc.

But if you have something like vite dev running and you connect to a database and then change a file that causes a service restart, the connection stays open in the background.

Suggested solution

If there would be some signal sent that could be intercepted to tell us that a restart was going to happen, that would be enough.

A very rough idea is something like, there can be other ways, just something to help us react to this restart if we need.

process.on('vite-restart', () => {
  // ...
});

Alternative

No response

Additional context

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jun 1, 2023

You can use a Vite plugin and the buildEnd hook to cleanup on restart, or if it's in the SSR runtime, you can watch #7887

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants