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

Quitting react dev server closes browser and any open tabs #3113

Closed
nikolas opened this issue Sep 12, 2017 · 14 comments · Fixed by #3784 or #5821
Closed

Quitting react dev server closes browser and any open tabs #3113

nikolas opened this issue Sep 12, 2017 · 14 comments · Fixed by #3784 or #5821

Comments

@nikolas
Copy link
Contributor

nikolas commented Sep 12, 2017

This only occurs if create-react-app creates the browser process itself. See info below.

Environment

  1. node -v: v6.11.3

  2. npm -v:5.4.1

  3. yarn --version (if you use Yarn):

  4. npm ls react-scripts (if you haven’t ejected): [email protected]

  5. Operating system: Ubuntu 16.04

  6. Browser and version (if relevant): Chromium 60.0.3112.113

Steps to Reproduce

  1. Without a browser open, run npm run start in a repo created with create-react-app
  2. Open a few tabs in the browser created by that command.
  3. Ctrl-C the react server.

Expected Behavior

The browser remains open. Or maybe gives a confirm dialog, then closes.

Actual Behavior

The browser closes, losing my open tabs.

@Timer
Copy link
Contributor

Timer commented Sep 12, 2017

That's not desirable!
If possible, could you look into this and fix the spawning of the process so it's not killed when its parent dies?

@GAumala
Copy link
Contributor

GAumala commented Sep 13, 2017

I did notice this issue a couple months ago. The problem is that spawning the browser child process is handled by the opn module, which is very useful to abstract little details of different operative systems, but does not expose much options to detach the child process from the original process.

I tried sending a pull request with a possible solution, but I didn't got a response in time so I moved on to different matters.

@evalexpr
Copy link
Contributor

evalexpr commented Sep 14, 2017

This doesn't seem to happen for me:

node -v: v8.5.0

npm -v:5.4.1

yarn --version (if you use Yarn): 1.0.1

npm ls react-scripts (if you haven’t ejected): [email protected]

Operating system: macOS Sierra

Browser and version (if relevant): Chrome Version 63.0.3215.0

EDIT: I've since tried this on Arch Linux with Chromium 61.0.3163.79, node 8.5.0, npm 5.3.0, & [email protected] and can confirm this behaviour (have also confirmed on opn repo) 👍

@GAumala
Copy link
Contributor

GAumala commented Sep 14, 2017

Thanks @W1lkins for confirming the issue in the opn repo. The PR with the fix has been merged, so let's wait until they make a release and update the opn version in react-scripts.

@chrifox
Copy link

chrifox commented Oct 3, 2017

Hi I am having this same issue on Ubuntu 16.10 running node v6.11.1, is there a workaround until a fix is released?

@GAumala
Copy link
Contributor

GAumala commented Oct 3, 2017

I think the easiest workaround is to have your browser up and running well before starting the dev server.

If the browser is an independent process, it won't be closed when the dev server is interrupted.

@gaearon gaearon modified the milestones: 1.0.x, 1.0.18 Jan 14, 2018
@gaearon gaearon mentioned this issue Jan 14, 2018
@gaearon
Copy link
Contributor

gaearon commented Jan 14, 2018

I bumped opn to the latest which includes your fix so this should be solved in the next release.
#3784

@gaearon
Copy link
Contributor

gaearon commented Jan 15, 2018

The fix is out in [email protected]! Please let us know if something doesn’t quite work.
https://github.com/facebookincubator/create-react-app/releases/tag/v1.1.0

@kishansundar
Copy link

this issue occurring again. I'm using [email protected]

@acammies
Copy link

Happening for me too, using [email protected] on Fedora 28 in a Virtual Box on windows.
Also using npm v5.6.0 and node v8.11.4

@timburgess
Copy link

timburgess commented Oct 23, 2018

Unfortunately it happens for me too. I've gone from react-scripts 2.0.3 to react-scripts 2.0.5 without improvement. I'm using npm v5.6.0 and yarn v1.10.1 and project based on CRA 2.

This is a bear as I have a yarn linked copy of martial-ui in which I'm trying to debug Android weirdness in components and a build of material-ui hiccups the dev server. So I have to restart the dev server and all my Chrome remote debugging setup for mobile goes away :-|

On Ubuntu 18.04

@kitwestneat
Copy link

FWIW if you add wait: false to the opn options in startBrowserProcess, opn will detach the child process so it's not linked to the react scripts process.

@sreetamdas
Copy link

Still being affected by this, is there a workaround to this?

@tomByrer
Copy link

I do not see this in Win10, Firefox, & bash in VSCode.

@iansu iansu modified the milestones: 2.1.x, 3.x Mar 10, 2019
@lock lock bot locked and limited conversation to collaborators Mar 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.