You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running vite in middleware mode, nested inside another server. When the process receives a SIGTERM signal, e.g. through a restart on a code-change by node-dev, vite kills the process immediately and does not give my server the time to take care of cleanups. I believe vite should not handle the SIGTERM at all when in middleware mode and leave it to the outside code to manually call await vite.close(). This may be a breaking change for many, so the least it should do is not call process.exit(0) in middleware mode. If this is the solution to this issue, then it would be nice if it was possible to still call vite.close() from the outside, and it would not throw but bail out silently on a second call, if it was already called before by the SIGTERM handler.
This behavior is caused by the following lines of code in vite:
> vite-testcase-middleware-mode-process-exit@1.0.0 start
> node-dev index.js
Server running at: http://localhost:3000. Use text-editor to change ./index.js, which will trigger node-dev to send SIGTERM and restart the server.
[INFO] 13:17:34 Restarting: /.../vite-testcase-middleware-mode-process-exit/index.js has been modified
#1: received SIGTERM, sleeping for 1s. After sleep, a 2nd console message should appear, starting with '#2:'
Server running at: http://localhost:3000. Use text-editor to change ./index.js, which will trigger node-dev to send SIGTERM and restart the server.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
@bluwy thanks for the reply. I'm not familiar enough with the internals to know the right path forward, so not really comfortable with the idea of addressing this by myself. I just wanted to raise the issue so it's on the radar.
Describe the bug
I am running vite in middleware mode, nested inside another server. When the process receives a
SIGTERM
signal, e.g. through a restart on a code-change bynode-dev
, vite kills the process immediately and does not give my server the time to take care of cleanups. I believe vite should not handle the SIGTERM at all when in middleware mode and leave it to the outside code to manually callawait vite.close()
. This may be a breaking change for many, so the least it should do is not callprocess.exit(0)
in middleware mode. If this is the solution to this issue, then it would be nice if it was possible to still callvite.close()
from the outside, and it would not throw but bail out silently on a second call, if it was already called before by theSIGTERM
handler.This behavior is caused by the following lines of code in vite:
vite/packages/vite/src/node/server/index.ts
Lines 438 to 446 in cf59005
Reproduction
https://github.com/lehni/vite-testcase-middleware-mode-process-exit
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: