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
When running Vite as a dev watcher inside a Phoenix project, the Vite server remains running in the background after exiting the Phoenix server with ctrl+c.
A workaround is to call process.stdin.resume() in vite.config.ts when the dev server is to be started:
constresumeStdinPlugin: PluginOption={name: "resume-stdin",configureServer: ()=>{// runs when the dev server is triggered, but not on other commands:process.stdin.resume();// an 'end' listener is already added in `setupSIGTERMListener` here: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#L1537},};exportdefaultdefineConfig({plugins: [resumeStdinPlugin(),react()],server: {open: false,port: 3000,},clearScreen: false,})
Running the Elixir script with elixir watcher.exs and stopping with ctrl+c (twice) leaves the Vite server running. Tested with Elixir 1.17.3 and 1.18.0, but I suspect it will behave the same in any Elixir version.
The issue can also be reproduced with this javascript:
# watcher.jsimport{spawn}from'child_process'constchildProcess=spawn('pnpm',['run','dev'],{// make child process stdin non-tty (pipe), like it is with elixir's System.cmd/3stdio: ['pipe','inherit','inherit'],detached: true,})childProcess.on('error',(err)=>{console.error('Failed to start process:',err)})childProcess.on('exit',(code)=>{console.log(`Process exited with code ${code}`)})process.on('SIGINT',()=>{console.log('\nReceived SIGINT in parent. Child process will continue running.',)})process.on('SIGTERM',()=>{childProcess.unref()console.log('\nReceived SIGTERM in parent. Child process will continue running.',)})
Stackblitz note: ctrl+c seems to behave differently there, so had to trigger an interrupt with kill -SIGINT $pid to reproduce.
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 vuejs/core instead.
Describe the bug
When running Vite as a dev watcher inside a Phoenix project, the Vite server remains running in the background after exiting the Phoenix server with ctrl+c.
A workaround is to call
process.stdin.resume()
in vite.config.ts when the dev server is to be started:Related issues:
Reproduction
https://stackblitz.com/edit/vitejs-vite-shkjhvut?file=watcher.js
Steps to reproduce
The issue can be reproduced by running this Elixir script at the root of a new vite app (
pnpm create vite@latest
):Running the Elixir script with
elixir watcher.exs
and stopping withctrl+c
(twice) leaves the Vite server running. Tested with Elixir 1.17.3 and 1.18.0, but I suspect it will behave the same in any Elixir version.The issue can also be reproduced with this javascript:
Stackblitz note:
ctrl+c
seems to behave differently there, so had to trigger an interrupt withkill -SIGINT $pid
to reproduce.System Info
Used Package Manager
pnpm
Logs
elixir watcher.exs (Click to expand)
pnpm exec node watcher.js (Click to expand)
Validations
The text was updated successfully, but these errors were encountered: