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

Slow start script #302

Closed
sdn90 opened this issue Jul 30, 2016 · 14 comments · Fixed by #319
Closed

Slow start script #302

sdn90 opened this issue Jul 30, 2016 · 14 comments · Fixed by #319

Comments

@sdn90
Copy link

sdn90 commented Jul 30, 2016

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
@gaearon
Copy link
Contributor

gaearon commented Jul 30, 2016

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?

@sdn90
Copy link
Author

sdn90 commented Jul 31, 2016

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.

@wolfie82
Copy link

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

@wolfie82
Copy link

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.

@gaearon
Copy link
Contributor

gaearon commented Jul 31, 2016

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?

@philstrong
Copy link

Yea also long startup and I also have firewall enabled.

real    1m21.762s

@gaearon
Copy link
Contributor

gaearon commented Aug 1, 2016

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

@gaearon gaearon added this to the 0.3.0 milestone Aug 1, 2016
@gaearon
Copy link
Contributor

gaearon commented Aug 1, 2016

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

@philstrong
Copy link

Yes it does fix the issue @gaearon

@gaearon
Copy link
Contributor

gaearon commented Aug 1, 2016

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

gaearon added a commit that referenced this issue Aug 1, 2016
This fixes #302 by temporarily forking `detect-port`.
Hopefully this fix will be merged into the original project, and we can refer to it again.
gaearon added a commit that referenced this issue Aug 1, 2016
This fixes #302 by temporarily forking `detect-port`.
Hopefully this fix will be merged into the original project, and we can refer to it again.
@gaearon
Copy link
Contributor

gaearon commented Aug 1, 2016

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

@gaearon gaearon modified the milestones: 0.2.1, 0.3.0 Aug 1, 2016
@xudafeng
Copy link

xudafeng commented Aug 1, 2016

@gaearon
Copy link
Contributor

gaearon commented Aug 1, 2016

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

@sdn90
Copy link
Author

sdn90 commented Aug 1, 2016

Working for me 👍

cszatmary pushed a commit to cszatmary/create-react-app that referenced this issue Apr 28, 2018
@lock lock bot locked and limited conversation to collaborators Jan 23, 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.

5 participants