Skip to content

fix(http-client): name a connection that failed on every address - #705

Merged
abernatskiy merged 2 commits into
masterfrom
fix/http-client-empty-connect-reason
Dec 4, 2026
Merged

abernatskiy merged 2 commits into
masterfrom
fix/http-client-empty-connect-reason

Conversation

@abernatskiy

Copy link
Copy Markdown
Contributor

Problem. With autoSelectFamily, Node's default since version 20, a connection that fails on every address the host resolves to raises an AggregateError, and its message is empty. node-fetch keeps only the error's code and builds the message from that empty text, so the log reads:

FetchError: request to https://portal.sqd.dev/datasets/base-mainnet/head failed, reason:

Nothing after the colon. Slow Portal head requests in fallback live runs logged exactly this. Reading them needed a reproduction, which showed the code was ETIMEDOUT and that every connection attempt had failed.

Fix. The client fills in the empty reason from the code the FetchError still carries: … failed, reason: connect ETIMEDOUT on every address the host resolves to. The message still starts with request to, so it is still classified as a connection error and retried (the test checks isHttpConnectionError). The Portal client, the RPC client and anything else built on @subsquid/http-client gets the clearer message.

Test: client.connect-error.test.ts. A custom lookup resolves the host to closed ports on 127.0.0.1 and ::1, which gives a deterministic ECONNREFUSED on both families. The test fails without the fix. http-client tests pass (6) and tsc --noEmit is clean.

🤖 Generated with Claude Code

With autoSelectFamily, a connect that fails on every address is an
AggregateError with an empty message, and node-fetch reports it as
"request to <url> failed, reason: " with nothing after the colon. Its
code survives on the FetchError: name it in the message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active moderate finding remains because the test relies on a Node option whose default differs across supported Node versions, causing failures and incomplete error coverage on older versions.

1 open issue
What changed in this PR

Improves shared HTTP client diagnostics when connection attempts fail on every resolved address, while preserving connection-error classification for retries.

Changes:

  • Fills empty connection-error reasons with the error code.
  • Adds a dual-address failure regression test.
  • Records a patch release change.
File Description
util/​http-client/​src/​client.ts Adds descriptive text to empty connection failures.
util/​http-client/​src/​client.connect-error.test.ts Checks error text and retry classification.
common/​changes/​@subsquid/​http-client/​fix-http-client-empty-connect-reason_2026-12-05-00-00.json Records the diagnostic fix for release.

Review effort: Lite

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain, and the changes include targeted regression coverage for both the diagnostic message and retry classification.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@abernatskiy
abernatskiy merged commit 2d48de9 into master Dec 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants