Skip to content

Slow start script #302

Closed
Closed

Description

@sdn90

Node: v5.4.1
OS: OS X 10.11.5 / Darwin Stevens-MBP 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

I've narrowed it down to the detect-port library used. I tested out the library's CLI and got similar results.

Added a timer to the start script:

console.time('detect')

detect(DEFAULT_PORT).then(port => {
  console.timeEnd('detect')
  ...
})

Result of running npm run start

/Users/steven/my_projects/autocomplete steven@Stevens-MBP% npm run start

> autocomplete@0.0.1 start /Users/steven/my_projects/autocomplete
> react-scripts start

detect: 75279.878ms

Activity

  1. gaearon commented on Jul 30, 2016

    @gaearon
    Contributor

    Wow, a minute? 😮

    Is there anything unusual about your setup? Could you put some logs in its source and check where it’s spending the time? Could it be that a lot of ports after 3000 are busy on your computer for some reason?

  2. sdn90 commented on Jul 31, 2016

    @sdn90
    Author

    I'm pretty sure I have a vanilla setup.

    The problem is on this line:
    https://github.com/xudafeng/detect-port/blob/master/lib/index.js#L64

    My understanding is that the ipv4 library returns my local IP assigned by DHCP.

    If I change this to 'host': '127.0.0.1', start time is almost instant. I get the Something else is running at port 3000 prompt if I run it while port 3000 is assigned.

    The network stuff is out the scope of my knowledge.. Not sure what the implications are if this was just hardcoded to something like 127.0.0.1 and why using the local IP has any effect on it.

    If anyone else is having this problem on OS X, easy fix is disconnect from your network and run start.

  3. wolfie82 commented on Jul 31, 2016

    @wolfie82

    To note, I have the same experience.

    ❯ create-react-app --version
    create-react-app version: 0.2.0

    ❯ npm -v
    3.10.3

    ❯ node -v
    v6.3.1

    ❯ uname -ra
    Darwin bonk.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64

  4. wolfie82 commented on Jul 31, 2016

    @wolfie82

    Just a little diagnostic.

    ❯ npm i detect-port -g
    ❯ detect --port 3000

    This takes about 1 minute to execute. It looks like if you have the OSX firewall enabled it will cause the long lag. I disabled the OSX firewall and it returns instantly.

  5. gaearon commented on Jul 31, 2016

    @gaearon
    Contributor

    It looks like if you have the OSX firewall enabled it will cause the long lag

    Thanks, this is very valuable info!

    Can you check if the fix in #302 (comment) also works for you?

  6. philstrong commented on Aug 1, 2016

    @philstrong

    Yea also long startup and I also have firewall enabled.

    real    1m21.762s
    
  7. gaearon commented on Aug 1, 2016

    @gaearon
    Contributor

    @philstrong Does the fix in #302 (comment) work for you?

  8. added this to the 0.3.0 milestone on Aug 1, 2016
  9. gaearon commented on Aug 1, 2016

    @gaearon
    Contributor

    I can reproduce this by turning on the firewall and enabling “block all incoming connections”.

  10. philstrong commented on Aug 1, 2016

    @philstrong

    Yes it does fix the issue @gaearon

  11. gaearon commented on Aug 1, 2016

    @gaearon
    Contributor

    OK, I’ll test this on Windows and release a patch today if it works cross platform.

  12. added a commit that references this issue on Aug 1, 2016
    ead7032
  13. added a commit that references this issue on Aug 1, 2016
    f7011e0
  14. gaearon commented on Aug 1, 2016

    @gaearon
    Contributor

    This should be fixed in the new version. Can you please verify?
    Please find the upgrade instructions here.

  15. modified the milestones: 0.2.1, 0.3.0 on Aug 1, 2016
  16. xudafeng commented on Aug 1, 2016

    @xudafeng
  17. gaearon commented on Aug 1, 2016

    @gaearon
    Contributor

    Thank you so much! I will revert my commit and bump the version so we use detect-port again in 0.3.0.

  18. sdn90 commented on Aug 1, 2016

    @sdn90
    Author

    Working for me 👍

  19. added a commit that references this issue on Apr 28, 2018
  20. locked and limited conversation to collaborators on Jan 23, 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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions