Skip to content

ECONNRESET from fetch still crashes netlify-cli #7952

@coaxial

Description

@coaxial

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions