cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI crash on loading of website

Open jonathan-wondereur opened this issue 1 year ago • 5 comments

Describe the bug

When loading the site after using the netlify dev command I get a crash.

Task Terminated with exit code 1
URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at rewriter (file:///usr/local/lib/node_modules/netlify-cli/dist/utils/rules-proxy.js:87:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at onRequest (file:///usr/local/lib/node_modules/netlify-cli/dist/utils/proxy.js:559:19)

  System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    npm: 10.5.0 - /usr/local/bin/npm
  Browsers:
    Safari: 17.4.1
  npmGlobalPackages:
    netlify-cli: 17.23.5

Steps to reproduce

  1. Run netlify dev
  2. Load website in browser

Configuration

# TOML lint: https://www.toml-lint.com/
[build]
  base = ""
  publish = "dist"
  command = "npm i --prefix functions && npm run build && cp ./headers/_stagingHeaders ./dist/_headers && cp -r ./public ./dist"
  functions = "functions"

[context.production]
  command = "npm i --prefix functions && npm run build && cp ./headers/_prodHeaders ./dist/_headers && cp -r ./public ./dist"

[build.environment]
  GO_VERSION = "1.22.0"

[functions]
  node_bundler = "esbuild"

[[redirects]]
  from = "/*"
  to = "/"
  status = 200

Environment

System: OS: macOS 14.4.1 CPU: (8) arm64 Apple M1 Memory: 90.88 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.11.1 - /usr/local/bin/node npm: 10.5.0 - /usr/local/bin/npm npmGlobalPackages: netlify-cli: 17.23.5

jonathan-wondereur avatar May 15 '24 15:05 jonathan-wondereur

Removing the redirect fixes the issues, but of course breaks my deploy.

[[redirects]]
  from = "/*"
  to = "/"
  status = 200

jonathan-wondereur avatar May 15 '24 15:05 jonathan-wondereur

I am experiencing this same issue. I also tried commenting out my redirects, and the app runs again just like @jonathan-wondereur found.

Adding this to netlify.toml also seems to work around the problem:

[dev]
  autoLaunch = false

so maybe there's some kind of race condition here.

Here's my cli error output:

URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at rewriter (file:///Users/xxxxx/.node/lib/node_modules/netlify-cli/dist/utils/rules-proxy.js:87:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async onRequest (file:///Users/xxxxx/.node/lib/node_modules/netlify-cli/dist/utils/proxy.js:594:19)

  System:
    OS: macOS 14.4
    CPU: (8) x64 Apple M1
  Binaries:
    Node: 20.17.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 127.0.6533.120
    Safari: 17.4
  npmGlobalPackages:
    netlify-cli: 17.34.2

bgmort avatar Aug 23 '24 05:08 bgmort

Hi folks. Can anyone in this thread provide a minimal reproduction of this bug?

I suspect base = "" might be the culprit here.

serhalp avatar Feb 24 '25 22:02 serhalp

So even witha minimal netlify.toml file, I get the crash.

[[redirects]]
  from = "/*"
  to = "/"
  status = 200
netlify dev
◈ Netlify Dev ◈
◈ Injecting environment variable values for all scopes
◈ Injected .env file env var: ***
◈ Setting up local development server
◈ Starting Netlify Dev with Vite

> [email protected] dev
> vite serve

[sentry-vite-plugin] Info: Using environment variables configured in ".env.sentry-build-plugin".
[sentry-vite-plugin] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.

  VITE v5.4.11  ready in 648 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
✔ Waiting for framework port 5173. This can be configured using the 'targetPort' property in the netlify.toml

   ┌──────────────────────────────────────────────────┐
   │                                                  │
   │   ◈ Server now ready on http://localhost:57569   │
   │                                                  │
   └──────────────────────────────────────────────────┘

 ›   Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:

npm install -g netlify-cli@VERSION

You can use any version from https://ntl.fyi/cli-versions.

Please report this problem at https://ntl.fyi/cli-error including the error details below.

 ›   Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:

npm install -g netlify-cli@VERSION

You can use any version from https://ntl.fyi/cli-versions.

Please report this problem at https://ntl.fyi/cli-error including the error details below.

 ›   Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:

npm install -g netlify-cli@VERSION

You can use any version from https://ntl.fyi/cli-versions.

Please report this problem at https://ntl.fyi/cli-error including the error details below.

 ›   Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:

npm install -g netlify-cli@VERSION

You can use any version from https://ntl.fyi/cli-versions.

Please report this problem at https://ntl.fyi/cli-error including the error details below.

URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at rewriter (file:///usr/local/lib/node_modules/netlify-cli/dist/utils/rules-proxy.js:86:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async onRequest (file:///usr/local/lib/node_modules/netlify-cli/dist/utils/proxy.js:606:19)

  System:
    OS: macOS 14.7.3
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    npm: 10.8.3 - /usr/local/bin/npm
  Browsers:
    Safari: 18.3
  npmGlobalPackages:
    netlify-cli: 19.0.0```

jonathan-wondereur avatar Feb 25 '25 12:02 jonathan-wondereur

I can also confirm that setting auto-launch to false seems to fix the issue. Thanks for the pointer @bgmort

[dev]
  autoLaunch = false

jonathan-wondereur avatar Feb 25 '25 12:02 jonathan-wondereur