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

nodemon called as a subprocess within a subprocess breaks stdin after SIGINT #2154

Closed
rtpg opened this issue Dec 21, 2023 · 5 comments
Closed
Labels
stale no activity for 2 weeks

Comments

@rtpg
Copy link

rtpg commented Dec 21, 2023

I have the following environment:

// package.json
{
  "dependencies": {
    "nodemon": "^3.0.2"
  },
  "scripts": {
    "dev1": "./call_nodemon.js dev_busted",
    "dev2": "./call_nodemon.js dev_fine",
    "dev_busted": "(nodemon --exec 'echo hi') || echo 'no'",
    "dev_fine": "(nodemon --exec 'echo hi')"
  }
}
//call_nodemon.js
#!/usr/bin/env node
const cp = require("child_process");
cp.spawn("npm", ["run", process.argv[2]], {
  stdio :[process.stdin, "pipe", process.stderr]
})

If I call npm run dev1, then SIGINT with Ctrl-C, my shell ends up stuck in (I believe) raw mode (maybe echo-only mode, having trouble telling). I believe this is happening during teardown of some child processes due to my shell sometimes working for a second before breaking (i.e. the prompt prints, and I have a half second window where the up or down arrow properly lets me search history, then I get the telltale ^[0A^[0B `stuff)

If I run npm run dev2 this does not happen (the difference being the extra echo call or no)

If I run npm run dev_busted directly, the issue does not happen.

If, I comment out process.once('SIGINT' , () => bus.emit('quit', 130) in lib/monitor/run.js, the issue no longer happens (though there are obviously probably consequences to that on nodemon overall)

If I replace that line with process.once('SIGINT', () => {}), the issue does happen. I have reported an issue upstream to nodejs that seems to indicate something weird going on in that front.

(some context: the original place where I had the issue was an npm-run-all script calling into nodemon. I stripped everything down to the cp.spawn call I have in call_nodemon.js, but that's how I ended up with this setup)

Versions

Expected behaviour

After I terminate nodemon with SIGINT, my shell should recover

@rtpg rtpg changed the title nodemon called as a subprocess breaks stdin after SIGINT nodemon called as a subprocess within a subprocess breaks stdin after SIGINT Dec 21, 2023
@rtpg
Copy link
Author

rtpg commented Dec 21, 2023

sample execution

rtpg@HOSTNAME ‹ main ●● › : ~/proj/break
[1] % npm run dev1      

> dev1
> ./call_nodemon.js dev_busted

^C

rtpg@HOSTNAME ‹ main ●● › : ~/proj/break
[130] % npm ERR! path /home/rtpg/proj/break
npm ERR! command failed
npm ERR! signal SIGPIPE
npm ERR! command /usr/bin/bash -c (nodemon --exec 'echo hi') || echo 'no'

npm ERR! A complete log of this run can be found in: /home/rtpg/.npm/_logs/2023-12-21T05_31_20_117Z-debug-0.log
^[OA^[OB^[OA^[OB^[OA

session example, notice how the npm error shows up after my prompt appears, and then a bunch of "raw" up and down arrow keypressees (SIGINT'ing again with Ctrl-C does fix my shell though)

Copy link

github-actions bot commented Jan 4, 2024

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@github-actions github-actions bot added the stale no activity for 2 weeks label Jan 4, 2024
@rtpg
Copy link
Author

rtpg commented Jan 4, 2024

I believe this to still be an issue, though I personally have a workaround of passing in /dev/null as stdin to nodemon as a workaround

@github-actions github-actions bot removed the stale no activity for 2 weeks label Jan 5, 2024
Copy link

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@github-actions github-actions bot added the stale no activity for 2 weeks label Jan 19, 2024
Copy link

Automatically closing this issue due to lack of activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale no activity for 2 weeks
Projects
None yet
Development

No branches or pull requests

1 participant