estrella icon indicating copy to clipboard operation
estrella copied to clipboard

Terminating subprocess on Windows when "running" is flaky

Open MaxmaxmaximusAWS opened this issue 3 years ago • 5 comments

"estrella": "^1.4.0",

This config:

estrella.build({
  watch: true,
  run: "node build/index.js" // this process not killing
})

Temporary solution:

let childProcess = null

estrella.build({
  onEnd: () => {
    if (childProcess) { 
      childProcess.kill('SIGINT')
    }

    childProcess = spawn('node', ['build/index.js'], {
      stdio: [process.stdin, process.stdout, process.stderr],
    })
  },
})

MaxmaxmaximusAWS avatar Apr 28 '21 09:04 MaxmaxmaximusAWS

What OS are you using? (Estrella uses Nodejs's child_process module and process groups on POSIX systems to allow for process tree control)

rsms avatar May 12 '21 02:05 rsms

Also can you please provide a complete repro? (ideally as a gist or a zip or tar archive)

FTR, the signalling code is here:

https://github.com/rsms/estrella/blob/7294055202b0ea6004ed4cac2fd22e8079497f17/src/exec.ts#L272-L320

rsms avatar May 12 '21 02:05 rsms

What OS are you using? (Estrella uses Nodejs's child_process module and process groups on POSIX systems to allow for process tree control)

windows 10 of course

MaxmaxmaximusAWS avatar May 12 '21 16:05 MaxmaxmaximusAWS

Ah, yeah you're going to have some issues if the process is not responding to hangup or int signals. You could try WSL or run your build manually (either in a BAT script or from js in onEnd, but you'll likely run into similar issues as with estrella using nodejs.)

rsms avatar May 13 '21 19:05 rsms

Why you not use this code in windows platforms? =) This fix works on me:

let childProcess = null

estrella.build({
  onEnd: () => {
    if (childProcess) { 
      childProcess.kill('SIGINT')
    }

    childProcess = spawn('node', ['build/index.js'], {
      stdio: [process.stdin, process.stdout, process.stderr],
    })
  },
})

i can use WSL or WSL2 or docker or my macbook, but we need fix the bug, not hide the bug)

MaxmaxmaximusAWS avatar May 13 '21 23:05 MaxmaxmaximusAWS