netlify / netlify/cli

ECONNRESET from `fetch` still crashes netlify-cli

Open
#7,952 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
1.9k
Forks
474
Avg merge
23h 30m
Merged PRs (30d)
53

Description

Describe the bug

I believe this is similar to #7747.

FetchError: request to http://localhost:8080/ failed, reason: connect ECONNRESET 127.0.0.1:8080
    at ClientRequest.<anonymous> (/home/pierre/code/hello/node_modules/node-fetch/lib/index.js:1501:11)
    at ClientRequest.emit (node:events:519:28)
    at emitErrorEvent (node:_http_client:107:11)
    at Socket.socketErrorListener (node:_http_client:574:5)
    at Socket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

  System:
    OS: Linux 6.17 Linux Mint 22.2 (Zara)
    CPU: (8) x64 Intel(R) Xeon(R) E-2134 CPU @ 3.50GHz
  Binaries:
    Node: 22.21.1 - ~/.local/share/mise/installs/node/22.21.1/bin/node
    Yarn: 1.22.22 - ~/.local/share/pnpm/yarn
    npm: 10.9.4 - ~/.local/share/mise/installs/node/22.21.1/bin/npm
Steps to reproduce

Start a local server that will reset the connection:

python3 -c "import socket,struct; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1); s.bind(('0.0.0.0', 8080)); s.listen(1); 
while True: c,_=s.accept(); c.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0)); c.close()"

Test:

$ curl localhost:8080
curl: (56) Recv failure: Connection reset by peer

Have this function:

function handler(event, context, callback) {
  fetch('http://localhost:8080')
    .then(reponse => response.json())
    .then(json => callback(null, {statusCode: 200, body: JSON.stringify({hello: 'world'}))
}

Then start the dev server with netlify-cli and get the error.

Configuration

No response

Environment
$ npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli
sh: 1: envinfo: not found
$ npx netlify-cli --version
netlify-cli/23.15.1 linux-x64 node-v22.21.1

$ node --version
v22.21.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Reproduce the ECONNRESET case with the provided local reset server, then trace netlify-cli's fetch error handling and add coverage for this failure; done means the dev server handles the reset without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.