Skip to content

ping emits ERR_SOCKET_CLOSED_BEFORE_CONNECTION immediately on Node.js 24.20.0 #1873

Description

@MikeMcC399

Situation

Running node src/ping-cli.js http://localhost:3000 using Node.js 24.20.0 when there is no webserver available on localhost shows an immediate error ERR_SOCKET_CLOSED_BEFORE_CONNECTION instead of waiting.

Steps to reproduce

Under Node.js 24.20.0 or Node.js >=26.7.0, with no server running, execute:

node src/ping-cli.js http://localhost:3000

Logs

$ node src/ping-cli.js http://localhost:3000
pinging url http://localhost:3000 for 30 seconds
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

Error [ERR_SOCKET_CLOSED_BEFORE_CONNECTION]: Socket closed before the connection was established
    at Socket.onClose (node:net:1239:10)
    at Socket.wrapper (node:events:639:12)
    at Socket.emit (node:events:526:24)
    at TCP.<anonymous> (node:net:362:12) {
  code: 'ERR_SOCKET_CLOSED_BEFORE_CONNECTION'
}

Node.js v24.20.0

Assessment

The action currently uses got@11.8.6, released in Dec 2022, which is the latest CommonJS compatible version.

Higher versions, starting with got@12.0.0. released in Dec 2021, are pure ESM.

got@16.0.0, released on Aug 31, 2026, includes the fix "Retry on connection errors reported by request.end() instead of failing the request"

Suggestion

Migrate

FROM TO
got@11.8.6 CommonJS got@16.0.0 ESM

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions