Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !10419

fix: create-react-app slow behind corporate proxies

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/AriPerkkio/pr/fix-slow-app-creation into main Jan 22, 2021
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: AriPerkkio

Fixes #10403. This PR speeds up npx create-react-app by six minutes when run behind a corporate proxy.

What:

NPM has a bug where it acts really slow when run via child_process in an environment behind corporate proxy. Similar issues:

  • https://github.com/prettier/prettier-vscode/issues/1143
  • https://github.com/microsoft/vscode-languageserver-node/issues/551

Likely caused by https://github.com/sindresorhus/got/issues/79.

With current version of CRA it takes 6 minutes additional time when npx create-react-app is run.

Use this to test whether your environment is affected:

node -e "console.log(require('child_process').execSync('npm --version', { env: { ...process.env, NO_UPDATE_NOTIFIER: undefined }}).toString())"

This command takes 3 minutes to run in such environments.

How:

There is a work-around . If NO_UPDATE_NOTIFIER is available as environment variable npm internally skips some checks and moves on. Setting this variable "true" is something I always do to my work machines - but CRA cannot expect all developers to do this manually.

https://github.com/yeoman/update-notifier/blob/master/index.js#L43

This PR adds NO_UPDATE_NOTIFIER to those require('child_process').execSync('npm ...') calls. Link to child_process docs for busy people

Test Plan:

As this can only be reproduced when in environment behind corporate proxy this cannot be tested easily. I tested this manually in such environment. Debug logs are wrapped around these lines:

https://github.com/facebook/create-react-app/blob/0f6fc2bc71d78f0dcae67f3f08ce98a42fc0a57c/packages/create-react-app/createReactApp.js#L198

https://github.com/facebook/create-react-app/blob/0f6fc2bc71d78f0dcae67f3f08ce98a42fc0a57c/packages/create-react-app/createReactApp.js#L1012

Without the fix:

$ node index.js repro-app
Checking version [15:16:21]
> execSync('npm view create-react-app version');
Version 4.0.1 Time [15:19:29]

Creating a new React app in <removed>

Installing packages. This might take a couple of minutes.
Getting proxy [15:19:30]
> execSync('npm config get https-proxy');
Got proxy true Time [15:22:39]

With the fix:

$ node index.js fixed-app
Checking version [15:50:52]
> execSync('npm view create-react-app version', { env: { NO_UPDATE_NOTIFIER: 'true' }});
Version 4.0.1 Time [15:50:54]

Creating a new React app in <removed>

Installing packages. This might take a couple of minutes.

Getting proxy [15:50:54]
> execSync('npm config get https-proxy', { env: { NO_UPDATE_NOTIFIER: 'true' }});
Got proxy true Time [15:50:55]

All comments are welcome. 👍

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/AriPerkkio/pr/fix-slow-app-creation