Skip to content

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

Description

@nikolas

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): react-scripts@1.0.12

  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.

Activity

  1. added this to the 1.0.x milestone on Sep 12, 2017
  2. Timer commented on Sep 12, 2017

    @Timer
    Contributor

    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?

  3. GAumala commented on Sep 13, 2017

    @GAumala
    Contributor

    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.

  4. evalexpr commented on Sep 14, 2017

    @evalexpr
    Contributor

    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): react-scripts@1.0.11

    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, & react-scripts@1.0.13 and can confirm this behaviour (have also confirmed on opn repo) 👍

  5. GAumala commented on Sep 14, 2017

    @GAumala
    Contributor

    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.

  6. chrifox commented on Oct 3, 2017

    @chrifox

    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?

  7. GAumala commented on Oct 3, 2017

    @GAumala
    Contributor

    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.

  8. modified the milestones: 1.0.x, on Jan 14, 2018
  9. gaearon commented on Jan 14, 2018

    @gaearon
    Contributor

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

  10. gaearon commented on Jan 15, 2018

    @gaearon
    Contributor

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

  11. kish0x commented on Jun 23, 2018

    @kish0x

    this issue occurring again. I'm using react-scripts@1.1.4

  12. acammies commented on Sep 12, 2018

    @acammies

    Happening for me too, using react-scripts@1.1.4 on Fedora 28 in a Virtual Box on windows.
    Also using npm v5.6.0 and node v8.11.4

  13. timburgess commented on Oct 23, 2018

    @timburgess

    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

  14. kitwestneat commented on Nov 13, 2018

    @kitwestneat

    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.

  15. sreetamdas commented on Nov 14, 2018

    @sreetamdas

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

  16. reopened this on Nov 15, 2018
  17. modified the milestones: 1.1.0, 2.1.x on Nov 15, 2018
  18. tomByrer commented on Feb 26, 2019

    @tomByrer

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

  19. modified the milestones: 2.1.x, 3.x on Mar 10, 2019
  20. locked and limited conversation to collaborators on Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions