Skip to content

Intermittent network failures with npx #740

@NullVoxPopuli

Description

@NullVoxPopuli

Describe the bug

I get this error:

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Link to the blitz that caused the error

https://stackblitz.com/edit/node-z4ukg2?file=index.js

Steps to reproduce

This is a mostly empty blitz, so run:

NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider

to create the error.

Note that this is related to: #354
And trying to get around some legacy behavior in a sub-dependency (which I try to somewhat modernize here: broccolijs/broccoli#499 )

Expected behavior

Command runs to completion with success.

Parity with Local

Screenshots

No response

Platform

  • OS: Ubuntu Linux
  • Browser: Firefox
  • Version: 102.0

Additional context

Here is the full log of my commands and CLI output

log
~/projects/node-z4ukg2
❯ npx ember-cli new my-app --embroider
success Install finished in 19.739s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 1m 6s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 23.061s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 26s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider

~/projects/node-z4ukg2
❯ npx ember-cli --help
success Install finished in 15.184s

Usage: ember <command (Default: help)>

Available commands in ember-cli:

ember addon <addon-name> <options...>
  Generates a new folder structure for building an addon, complete with test harness.
  --dry-run (Boolean) (Default: false)
    aliases: -d
  --verbose (Boolean) (Default: false)
    aliases: -v
  --blueprint (String) (Default: addon)
    aliases: -b <value>
  --skip-npm (Boolean) (Default: false)
    aliases: -sn
  --skip-bower (Boolean) (Default: false)
    aliases: -sb
  --skip-git (Boolean) (Default: false)
    aliases: -sg
  --yarn (Boolean)
  --directory (String)
    aliases: -dir <value>
  --lang (String) Sets the base human language of the addon's own test application via index.html
  --ci-provider (travis, github) (Default: github) Installs the default CI blueprint. Either Travis or Github Actions is supported.

ember asset-sizes <options...>
  Shows the sizes of your asset files.
  --output-path (Path) (Default: dist/)
    aliases: -o <value>
  --json (Boolean) (Default: false)

ember build <options...>
  Builds your app and places it into the output path (dist/ by default).
  aliases: b
  --environment (String) (Default: development) Possible values are "development", "production", and "test".
    aliases: -e <value>, -dev (--environment=development), -prod (--environment=production)
  --output-path (Path) (Default: dist/)
    aliases: -o <value>
  --watch (Boolean) (Default: false)
    aliases: -w
  --watcher (String)
  --suppress-sizes (Boolean) (Default: false)

ember destroy <blueprint> <options...>
  Destroys code generated by `generate` command.
  aliases: d
  --dry-run (Boolean) (Default: false)
    aliases: -d
  --verbose (Boolean) (Default: false)
    aliases: -v
  --pod (Boolean) (Default: false)
    aliases: -p, -pods
  --classic (Boolean) (Default: false)
    aliases: -c
  --dummy (Boolean) (Default: false)
    aliases: -dum, -id
  --in-repo-addon (String) (Default: null)
    aliases: --in-repo <value>, -ir <value>
  --in (String) (Default: null) Runs a blueprint against an in repo addon. A path is expected, relative to the root of the project.
  --typescript (Boolean) Specifically destroys the TypeScript output of the `generate` command. Run `--no-typescript` to instead target the JavaScript output.
    aliases: -ts

ember generate <blueprint> <options...>
  Generates new code from blueprints.
  aliases: g
  --dry-run (Boolean) (Default: false)
    aliases: -d
  --verbose (Boolean) (Default: false)
    aliases: -v
  --pod (Boolean) (Default: false)
    aliases: -p, -pods
  --classic (Boolean) (Default: false)
    aliases: -c
  --dummy (Boolean) (Default: false)
    aliases: -dum, -id
  --in-repo-addon (String) (Default: null)
    aliases: --in-repo <value>, -ir <value>
  --lint-fix (Boolean) (Default: true)
  --in (String) (Default: null) Runs a blueprint against an in repo addon. A path is expected, relative to the root of the project.
  --typescript (Boolean) Generates a version of the blueprint written in TypeScript (if available).
    aliases: -ts

ember help <command-name (Default: all)> <options...>
  Outputs the usage instructions for all commands or the provided command
  aliases: h, --help, -h
  --verbose (Boolean) (Default: false)
    aliases: -v
  --json (Boolean) (Default: false)

ember init <glob-pattern> <options...>
  Reinitializes a new ember-cli project in the current folder.
  --dry-run (Boolean) (Default: false)
    aliases: -d
  --verbose (Boolean) (Default: false)
    aliases: -v
  --blueprint (String)
    aliases: -b <value>
  --skip-npm (Boolean) (Default: false)
    aliases: -sn
  --skip-bower (Boolean) (Default: false)
    aliases: -sb
  --lint-fix (Boolean) (Default: true)
  --welcome (Boolean) (Default: true) Installs and uses {{ember-welcome-page}}. Use --no-welcome to skip it.
  --yarn (Boolean)
  --name (String) (Default: "")
    aliases: -n <value>
  --lang (String) Sets the base human language of the application via index.html
  --embroider (Boolean) (Default: false) Enables the build system to use Embroider
  --ci-provider (travis, github) (Default: github) Installs the default CI blueprint. Either Travis or Github Actions is supported.

ember install <addon-name> <options...>
  Installs an ember-cli addon from npm.
  aliases: i
  --save (Boolean) (Default: false)
    aliases: -S
  --save-dev (Boolean) (Default: true)
    aliases: -D
  --save-exact (Boolean) (Default: false)
    aliases: -E, --exact
  --package-manager (npm, pnpm, yarn) Use this option to force the usage of a specific package manager. By default, ember-cli will try to detect the right package manager from any lockfiles that exist in your project.
    aliases: -yarn (--package-manager=yarn), -pnpm (--package-manager=pnpm)

ember new <app-name> <options...>
  Creates a new directory and runs ember init in it.
  --dry-run (Boolean) (Default: false)
    aliases: -d
  --verbose (Boolean) (Default: false)
    aliases: -v
  --blueprint (String) (Default: app)
    aliases: -b <value>
  --skip-npm (Boolean) (Default: false)
    aliases: -sn
  --skip-bower (Boolean) (Default: false)
    aliases: -sb
  --skip-git (Boolean) (Default: false)
    aliases: -sg
  --welcome (Boolean) (Default: true) Installs and uses {{ember-welcome-page}}. Use --no-welcome to skip it.
  --yarn (Boolean)
  --directory (String)
    aliases: -dir <value>
  --lang (String) Sets the base human language of the application via index.html
  --embroider (Boolean) (Default: false) Enables the build system to use Embroider
  --ci-provider (travis, github) (Default: github) Installs the default CI blueprint. Either Travis or Github Actions is supported.

ember serve <options...>
  Builds and serves your app, rebuilding on file changes.
  aliases: server, s
  --port (Number) (Default: 4200) To use a port different than 4200. Pass 0 to automatically pick an available port.
    aliases: -p <value>
  --host (String) Listens on all interfaces by default
    aliases: -H <value>
  --proxy (String)
    aliases: -pr <value>, -pxy <value>
  --proxy-in-timeout (Number) (Default: 120000) When using --proxy: timeout (in ms) for incoming requests
    aliases: -pit <value>
  --proxy-out-timeout (Number) (Default: 0) When using --proxy: timeout (in ms) for outgoing requests
    aliases: -pot <value>
  --secure-proxy (Boolean) (Default: true) Set to false to proxy self-signed SSL certificates
    aliases: -spr
  --transparent-proxy (Boolean) (Default: true) Set to false to omit x-forwarded-* headers when proxying
    aliases: --transp
  --watcher (String) (Default: events)
    aliases: -w <value>
  --live-reload (Boolean) (Default: true)
    aliases: -lr
  --live-reload-host (String) Defaults to host
    aliases: -lrh <value>
  --live-reload-base-url (String) Defaults to baseURL
    aliases: -lrbu <value>
  --live-reload-port (Number) Defaults to same port as ember app
    aliases: -lrp <value>
  --live-reload-prefix (String) (Default: _lr) Default to _lr
    aliases: --lrprefix <value>
  --environment (String) (Default: development) Possible values are "development", "production", and "test".
    aliases: -e <value>, -dev (--environment=development), -prod (--environment=production)
  --output-path (Path) (Default: dist/)
    aliases: -op <value>, -out <value>
  --ssl (Boolean) (Default: false) Set to true to configure Ember CLI to serve using SSL.
  --ssl-key (String) (Default: ssl/server.key) Specify the private key to use for SSL.
  --ssl-cert (String) (Default: ssl/server.crt) Specify the certificate to use for SSL.
  --path (Path) Reuse an existing build at given path.

ember test <options...>
  Runs your app's test suite.
  aliases: t
  --environment (String) (Default: test) Possible values are "development", "production", and "test".
    aliases: -e <value>
  --config-file (String)
    aliases: -c <value>, -cf <value>
  --server (Boolean) (Default: false)
    aliases: -s
  --host (String)
    aliases: -H <value>
  --test-port (Number) (Default: 7357) The test port to use when running tests. Pass 0 to automatically pick an available port
    aliases: -tp <value>
  --filter (String) A string to filter tests to run
    aliases: -f <value>
  --module (String) The name of a test module to run
    aliases: -m <value>
  --watcher (String) (Default: events)
    aliases: -w <value>
  --launch (String) (Default: false) A comma separated list of browsers to launch for tests.
  --reporter (String) Test reporter to use [tap|dot|xunit] (default: tap)
    aliases: -r <value>
  --silent (Boolean) (Default: false) Suppress any output except for the test report
  --ssl (Boolean) (Default: false) Set to true to configure testem to run the test suite using SSL.
  --ssl-key (String) (Default: ssl/server.key) Specify the private key to use for SSL.
  --ssl-cert (String) (Default: ssl/server.crt) Specify the certificate to use for SSL.
  --testem-debug (String) File to write a debug log from testem
  --test-page (String) Test page to invoke
  --path (Path) Reuse an existing build at given path.
  --query (String) A query string to append to the test page URL.
  --output-path (Path)
    aliases: -o <value>

ember version <options...>
  outputs ember-cli version
  aliases: v, --version, -v
  --verbose (Boolean) (Default: false)


~/projects/node-z4ukg2 18s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 13.288s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 16s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 14.503s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
  create .editorconfig
  create .ember-cli
  create .eslintignore
  create .eslintrc.js
  create .github/workflows/ci.yml
  create .prettierignore
  create .prettierrc.js
  create .template-lintrc.js
  create .watchmanconfig
  create README.md
  create app/app.js
  create app/components/.gitkeep
  create app/controllers/.gitkeep
  create app/helpers/.gitkeep
  create app/index.html
  create app/models/.gitkeep
  create app/router.js
  create app/routes/.gitkeep
  create app/styles/app.css
  create app/templates/application.hbs
  create config/ember-cli-update.json
  create config/environment.js
  create config/optional-features.json
  create config/targets.js
  create ember-cli-build.js
  create .gitignore
  create package.json
  create public/robots.txt
  create testem.js
  create tests/helpers/index.js
  create tests/index.html
  create tests/integration/.gitkeep
  create tests/test-helper.js
  create tests/unit/.gitkeep
  create vendor/.gitkeep
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 18s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 13.863s

Directory 'my-app' already exists.


~/projects/node-z4ukg2 17s
❯ rm -rf my-app/

~/projects/node-z4ukg2
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 16.063s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 19s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 14.878s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 18s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 13.888s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 17s
❯ NODE_OPTIONS="--trace-warnings --unhandled-rejections=strict" npx ember-cli new my-app --embroider
success Install finished in 14.159s

installing app
Ember CLI v4.4.0

✨  Creating a new Ember app in /home/projects/node-z4ukg2/my-app:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: NetworkError when attempting to fetch resource.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

~/projects/node-z4ukg2 17s
❯ 

During one of these invocations, my app was generated. 🙃

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions