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

Server still runs in the background #932

Closed
chaseWillden opened this issue Oct 19, 2016 · 30 comments
Closed

Server still runs in the background #932

chaseWillden opened this issue Oct 19, 2016 · 30 comments

Comments

@chaseWillden
Copy link

Description

When I run npm start, then I kill the app ctrl+c, the NodeJs server still runs as a task in the background.

Expected behavior

The process should be fully stopped.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
  2. node -v: 6.4.0
  3. npm -v: 3.10.3

Then, specify:

  1. Operating system: Windows 10
  2. Browser and version: Any
@thien-do
Copy link
Contributor

thien-do commented Nov 3, 2016

Hi @chaseWillden ,

  • Is this issue always happen, or just sometimes? (I do meet this issue a few times, but it is quite rarely and I can't reproduce)
  • When you kill the app, is it finished its compilation?
  • After you kill the app, do you able to access the app via browser? (or just the nodejs server still runs but you can't see the app in browser)
  • Can you reproduce this with a new CRA?

@chaseWillden
Copy link
Author

@dvkndn

  • For me, its every time I press Ctrl+C on command line.
  • Yes, it's finished it's compilation and started the developmental server. When I kill it, the server is still running.
  • Yes, I can access the app via browser.
  • What is CRA?

One important thing to note is I am using the Cygwin terminal.

@thien-do
Copy link
Contributor

thien-do commented Nov 4, 2016

oh for the last question, I mean do you able to reproduce the issue with a new create-react-app project? Just after generated?

Hm.. have you ever try to see if it works in any other terminal?

@chaseWillden
Copy link
Author

Yes, it happens with new projects. Even when I update the create-react-app on my computer.

I'll check other terminals.

@gaearon
Copy link
Contributor

gaearon commented Nov 20, 2016

Can you try debugging why this happens?

@Tev-work
Copy link

Tev-work commented Jan 9, 2017

Happens for me as well in the cygwin terminal (mintty 2.7.1) on windows 7. I created fresh project and only one more folder with component. Ctrl+C stops the script but nothing happens with the node server, I have to kill node through task manager (closing cygwin almost never works).

https://gyazo.com/5038db711e66a2eca13ccec0abef21c1

I don't know how to debug the script btw, any pointer to some tutorial or something would be helpful.

It seems to be running just fine in PowerShell though.

EDIT:
node -v: 6.3.0
npm -v: 3.10.3

@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

This might be a bug in cross-spawn.
We'd need somebody to create a minimal example with it and verify it's an issue on Cygwin.
Or maybe it's just a Node or Cygwin bug.

@Timer
Copy link
Contributor

Timer commented Feb 12, 2017

Just dropping a note, I've noticed runaway node processes on on macOS too. I'll try to keep an eye out for the cause in the future.

@gaearon
Copy link
Contributor

gaearon commented Mar 7, 2017

I also noticed this. We should fix it.

@gaearon gaearon added this to the 0.9.5 milestone Mar 7, 2017
@Timer
Copy link
Contributor

Timer commented Mar 7, 2017

Guessing #1753 solves this?

@gaearon
Copy link
Contributor

gaearon commented Mar 7, 2017

Maybe.

@gaearon gaearon modified the milestones: 0.9.5, 0.9.6 Mar 9, 2017
@ericjasonthomas
Copy link

I have the same issue mac OS node v7.6.0 npm 4.1.2

@Geczy
Copy link

Geczy commented Apr 7, 2017

Same issue as @ericjasonthomas

@gaearon
Copy link
Contributor

gaearon commented May 19, 2017

Hopefully this is fixed by #2246.
Let me know if you see this again with react-scripts >= 1.0.1.

@gaearon gaearon closed this as completed May 19, 2017
@gaearon
Copy link
Contributor

gaearon commented May 19, 2017

react-scripts@1.0.1 should be out with a fix.
Can you please verify it helps?

@scifutures
Copy link

scifutures commented May 23, 2017

This is concerning behavior -- I can't seem to stop it and it's taken over port 8888. Restarted twice now and it doesn't stop even after restart. I don't see any processes running node and there aren't any startup scripts that stand out that would be causing it.


Edit: It appears that its some form of progressive webapp enhancement that keeps the app in offline storage. I stopped the node process and then went into Inspector -> Applications -> Clear Storage, cleared everything, now the app goes away. It's not loading the offline app now, which is likely the source of the issue.

@gaearon
Copy link
Contributor

gaearon commented May 23, 2017

Yes, as noted both in migration notes for 1.0 and in User Guide, the default template now includes a service worker that ensures the app can be cached for offline use (and, importantly, near-instant recurrent visits). The User Guide also includes instructions to opt out (you can remove the service work registration call from src/index.js). Does this help?

@a19c97
Copy link

a19c97 commented Jan 31, 2018

@gaearon I tried removing registerServiceWorker() from index.js, but the process still persists after ctrl-c or ctrl-z. (I'm running npm 3.10.10 on Cygwin.) Any other ideas? It's really annoying to have to kill the process in task manager every time.

@mfish0005
Copy link

mfish0005 commented Feb 23, 2018

I can confirm this as happening for me on Windows 10. I've been working on several apps bootstrapped with CRA. Some ejected, some not. Some with registerServiceWorker, some not. I've become accustomed to pressing CTRL+SHIFT+ESC to open task manager and manually kill anything with the word node in it.

It might be worth noting that this only happens if I'm using Git Bash. If I run the process in my IDE's shell(VS Code) pressing CTRL+C kills the process as expected.

@armyofda12mnkeys
Copy link

This also occurs for me. Using Cygwin on Windows 10. Just killed via Task Manager like above user.

@joelwross
Copy link

This issue persists when using Git Bash on Windows 10 (multiple different machines). Can we please re-open?

@sheep-sheep
Copy link

As @joelwross said, I also observed same issue on Windows 10 with Git Bash, when Ctrl+C terminate the job, the port is still occupied and website is accessible. (I'm using the demo page).

CMD doesn't have the problem.

@divyanshu-rawat
Copy link

Observed same issue 👍

@Maxeh
Copy link

Maxeh commented Oct 1, 2018

I'm also having this problem.

@nathanhannig
Copy link

Having issue after updating to recent CRA

@HynekS
Copy link

HynekS commented Nov 18, 2018

Same issue, Windows 7, Git Bash.
Edit: Switching from Git Bash to Cmder or windows shell seems to fix this problem, which suggests that the underlying issue is related to Git Bash, rather than create-react-app.

@cormacrelf
Copy link

Possibly unrelated, but react-scripts build never terminates when it has a "cannot find file" error. It just prints out what's wrong, and hangs there, not consuming CPU, just stalled. (And it's impossible to cancel Netlify builds, so I'm just stuck. Great.)

./src/App.tsx
Cannot find file './results-csl.json' in './src'.

@charlesritchea
Copy link

@gaearon I'm using react-scripts 2.1.1 and this issue is still present on Windows 10 using vscode terminal.

@benparkinson
Copy link

@gaearon still seeing this in cygwin, Windows 10, react-scripts 2.1.1.

@sunnyYanan
Copy link

still having this problem

@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests