vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

CLI Suggests Taobao Registry but It Is a Lot Slower #6003

Open KevSlashNull opened 3 years ago

KevSlashNull commented 3 years ago

Version

4.5.8

Environment info

Environment Info:

  System:
    OS: macOS Mojave 10.14.4
    CPU: (4) x64 Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
  Binaries:
    Node: 15.0.0 - ~/.nvm/versions/node/v15.0.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 7.0.2 - ~/.nvm/versions/node/v15.0.0/bin/npm
  Browsers:
    Chrome: 86.0.4240.111
    Edge: Not Found
    Firefox: 78.0.1
    Safari: 12.1
  npmGlobalPackages:
    @vue/cli: Not Found

---

Current registry: https://registry.yarnpkg.com

Steps to reproduce

I don’t know how to reproduce this exactly, unfortunately.

What is expected?

The CLI only suggests another registry if it’s significantly better than the current registry.

What is actually happening?

The CLI suggests https://registry.npm.taobao.org which has a response time of 15-45-times the current registry’s response time.


Example output of testing the response time with curl. I reproduced this multiple times.

kev@KevsMacBook ~ $ curl -w "@curl-format.txt" -o /dev/null -s https://registry.npm.taobao.org/siegegg-api
    time_namelookup:  0.266313
       time_connect:  0.313511
    time_appconnect:  0.411322
   time_pretransfer:  0.411606
      time_redirect:  0.000000
 time_starttransfer:  15.695086
                    ----------
         time_total:  15.695307
kev@KevsMacBook ~ $ curl -w "@curl-format.txt" -o /dev/null -s https://registry.npmjs.org/siegegg-api
    time_namelookup:  0.029874
       time_connect:  0.073676
    time_appconnect:  0.200626
   time_pretransfer:  0.200845
      time_redirect:  0.000000
 time_starttransfer:  1.160862
                    ----------
         time_total:  1.162009
kev@KevsMacBook ~ $ curl -w "@curl-format.txt" -o /dev/null -s https://registry.yarnpkg.com/siegegg-api
    time_namelookup:  0.004120
       time_connect:  0.065280
    time_appconnect:  0.243338
   time_pretransfer:  0.243497
      time_redirect:  0.000000
 time_starttransfer:  0.351197
                    ----------
         time_total:  0.356865
fangbinwei commented 3 years ago

Could you test this code which is used by CLI? Does it always return taobao registry?

KevSlashNull commented 3 years ago

@fangbinwei, it doesn't always return the taobao registry. Looks like the 15s yesterday were pretty random. :thinking:

image

I've modified the script to show the time for both requests. It also checks more than one package because I think this might not be a bug inside vue cli.

First time `node main.js`
Using vue-cli-version-marker
https://registry.yarnpkg.com: 541.241ms
https://registry.npm.taobao.org: 558.983ms
Using siegegg-api
https://registry.yarnpkg.com: 418.443ms
https://registry.npm.taobao.org: 1851.088ms
Using express
https://registry.yarnpkg.com: 408.303ms
https://registry.npm.taobao.org: 1738.040ms
Using request
https://registry.yarnpkg.com: 406.914ms
https://registry.npm.taobao.org: 1123.147ms
Using ts-node
https://registry.yarnpkg.com: 409.492ms
https://registry.npm.taobao.org: 430.789ms
Using axios
https://registry.yarnpkg.com: 385.833ms
https://registry.npm.taobao.org: 1614.157ms
Using bootstrap
https://registry.yarnpkg.com: 411.516ms
https://registry.npm.taobao.org: 1024.958ms
Using jquery
https://registry.yarnpkg.com: 406.809ms
https://registry.npm.taobao.org: 1967.655ms
Second time `node main.js`
Using vue-cli-version-marker
https://registry.npm.taobao.org: 256.945ms
https://registry.yarnpkg.com: 468.953ms
Using siegegg-api
https://registry.npm.taobao.org: 156.621ms
https://registry.yarnpkg.com: 399.340ms
Using express
https://registry.npm.taobao.org: 227.382ms
https://registry.yarnpkg.com: 366.645ms
Using request
https://registry.npm.taobao.org: 159.970ms
https://registry.yarnpkg.com: 357.367ms
Using ts-node
https://registry.npm.taobao.org: 102.781ms
https://registry.yarnpkg.com: 404.320ms
Using axios
https://registry.npm.taobao.org: 130.075ms
https://registry.yarnpkg.com: 406.246ms
Using bootstrap
https://registry.npm.taobao.org: 307.449ms
https://registry.yarnpkg.com: 351.657ms
Using jquery
https://registry.npm.taobao.org: 215.520ms
https://registry.yarnpkg.com: 342.015ms

It appears that Taobao's registry is slower for initial requests but faster for subsequent requests (caching?). So that's why I think it's not a bug in Vue CLI, as the Taobao registry is faster after the first initial much slower request. From my side, I'd close the issue, it's probably just weird behavior by the registries and the Taobao one appears to be actually faster except for the first request which confused me. :sweat_smile:

fangbinwei commented 3 years ago

This feature is friendly to Chinese users, sine taobao registry is always faster than other registries. For other areas with fast internet, it’s hard to say which registry is faster 😢

KevSlashNull commented 3 years ago

Yeah, that's great for Chinese users to have a faster option. I'm wondering how reliable it would be to test via ping instead of requests?

Ping for Yarn Registry (from Germany) IPv4
PING yarn.npmjs.org (104.16.23.35) 56(84) bytes of data.
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=1 ttl=58 time=28.6 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=2 ttl=58 time=33.1 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=3 ttl=58 time=29.3 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=4 ttl=58 time=65.4 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=5 ttl=58 time=28.8 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=6 ttl=58 time=29.6 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=7 ttl=58 time=28.5 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=8 ttl=58 time=30.3 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=9 ttl=58 time=29.6 ms
64 bytes from 104.16.23.35 (104.16.23.35): icmp_seq=10 ttl=58 time=32.3 ms

--- yarn.npmjs.org ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9015ms
rtt min/avg/max/mdev = 28.575/33.604/65.499/10.732 ms
Ping for Taobao Registry (from Germany) IPv4
PING registry.npm.taobao.org.w.cdngslb.com (47.246.43.230) 56(84) bytes of data.
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=1 ttl=55 time=72.7 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=2 ttl=55 time=76.1 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=3 ttl=55 time=76.5 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=4 ttl=55 time=82.2 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=5 ttl=55 time=67.0 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=6 ttl=55 time=76.0 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=7 ttl=55 time=70.8 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=8 ttl=55 time=75.7 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=9 ttl=55 time=80.6 ms
64 bytes from 47.246.43.230 (47.246.43.230): icmp_seq=10 ttl=55 time=71.2 ms

--- registry.npm.taobao.org.w.cdngslb.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9013ms
rtt min/avg/max/mdev = 67.054/74.936/82.266/4.362 ms

IPv6 is even faster than IPv4 for yarn, so I forced IPv4 so it's the same version.

gopinav commented 3 years ago

Hello,

I opted for the switch but I don't know if that is the cause. But when I run vue create command, it always times out for me. I can't even get started with a project. Below is the screenshot of the timeout. Can you please tell me how to switch out of taobao registry?

image

fangbinwei commented 3 years ago

First you can check yarn config get registry

then, you can check useTaobaoRegistry in the config .vuerc, maybe is located on C:/User/your_name/

.vuerc

{
  "packageManager": "yarn",
  "useTaobaoRegistry": false
}

@gopinav

gopinav commented 3 years ago

Yeah deleted the .vuerc file from %USERPROFILE% and FINALLY after half a day, I have a project running. I really don't think the suggestion should be made to use taobao registry. Thanks for your help.

haoqunjiang commented 3 years ago

See also https://github.com/vuejs/vue-cli/issues/5261 Yeah, the test implementation is not that reliable.

Clem-D commented 3 years ago

First you can check yarn config get registry

then, you can check useTaobaoRegistry in the config .vuerc, maybe is located on C:/User/your_name/

.vuerc

{
  "packageManager": "yarn",
  "useTaobaoRegistry": false
}

@gopinav

Thanks it helps me ! It was exactly that I was looking for :)

jlarmstrongiv commented 3 years ago

Wow, this surprised me—first time using the vue cli. The solution provided by fangbinwei worked for me. Thank you!