Create-react-app: Quitting react dev server closes browser and any open tabs

Created on 12 Sep 2017  路  14Comments  路  Source: facebook/create-react-app

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鈥檛 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.

up for grabs! medium bug

Most helpful comment

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.

All 14 comments

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?

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.

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鈥檛 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) 馃憤

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.

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?

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.

I bumped opn to the latest which includes your fix so this should be solved in the next release.
https://github.com/facebookincubator/create-react-app/pull/3784

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

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

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

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

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stopachka picture stopachka  路  3Comments

Evan-GK picture Evan-GK  路  3Comments

adrice727 picture adrice727  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

dualcnhq picture dualcnhq  路  3Comments