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

Start script not listening to stdin #11255

Open
razwanizmi opened this issue Jul 29, 2021 · 3 comments
Open

Start script not listening to stdin #11255

razwanizmi opened this issue Jul 29, 2021 · 3 comments

Comments

@razwanizmi
Copy link

Describe the bug

I use Create React App as part of an asset pipeline in a web framework (in my case Phoenix). As part of the development pipeline, I've set up a watcher to run react-scripts start whenever my web server starts.

This works fine, but whenever I terminate my web server, Webpack dev server remains running in the background. I want Webpack dev server to listen on stdin for SIGINT and SIGTERM so it can terminate itself.

I noticed in start.js that there is an event listener set up for SIGINT and SIGTERM, but this didn't work for me.

Referring to this documentation, I can fix the issue on my machine by adding this line;

process.stdin.resume()

before any of the process event handlers are added. I think process will exit prematurely and not listen to stdin without that.

If this works for everyone, I'd be happy to put in a PR.

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

Start, listen, stdin, sigint, and sigterm.

Environment

  System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
  Binaries:
    Node: 15.8.0 - ~/.asdf/installs/nodejs/15.8.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 7.5.4 - ~/.asdf/installs/nodejs/15.8.0/.npm/bin/npm
  Browsers:
    Chrome: 92.0.4515.107
    Edge: Not Found
    Firefox: 83.0
    Safari: 14.1.1
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: 4.0.3 => 4.0.3
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

Described above.

Expected behavior

react-scripts start should listen to stdin for SIGINT and SIGTERM and terminate itself.

Actual behavior

Webpack dev server keeps running in the background after its spawning process gets terminated.

screenshot

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 9, 2022
@jonatanklosko
Copy link

Hey, the original fix from #7203 did work, however process.stdin.resume() has been reverted in #8700, and consequently broke it again.

The simplest way to reproduce the issue is to create a new CRA app and run:

node_modules/react-scripts/bin/react-scripts.js start <&-

Note: <&- immediately closes stdin of the script.

@jonatanklosko
Copy link

A similar story happened in rollup. It watched stdin, then process.stdin.resume() was removed in rollup/rollup#2410, but then added back in rollup/rollup#3493.

See the commit description in rollup/rollup@57bb54e for more details.

I think we should bring process.stdin.resume() back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants