Skip to content

feat: add ECONNREFUSED error code constant to AxiosError (closes #6485)#10680

Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom
MarcosNocetti:feat/add-econnrefused-error-code
Apr 25, 2026
Merged

feat: add ECONNREFUSED error code constant to AxiosError (closes #6485)#10680
jasonsaayman merged 2 commits intoaxios:v1.xfrom
MarcosNocetti:feat/add-econnrefused-error-code

Conversation

@MarcosNocetti
Copy link
Copy Markdown
Contributor

@MarcosNocetti MarcosNocetti commented Apr 10, 2026

Summary

  • Adds AxiosError.ECONNREFUSED = 'ECONNREFUSED' as a typed constant
  • Updated in 3 files: lib/core/AxiosError.js, index.d.ts, index.d.cts
  • Enables type-safe error code checks without hardcoding strings

Context

Issue #6485 requested the ability to use ECONNREFUSED as a typed constant on AxiosError, similar to existing codes like ECONNABORTED and ETIMEDOUT. Currently users must hardcode the string "ECONNREFUSED".

Test plan

  • Verify AxiosError.ECONNREFUSED resolves to 'ECONNREFUSED' at runtime
  • Verify TypeScript autocomplete includes ECONNREFUSED on the AxiosError class
  • Verify no existing tests break

Summary by cubic

Adds AxiosError.ECONNREFUSED as a typed constant for type-safe error checks and better IDE autocomplete. Synced with v1.x with no functional changes.

Description

  • Summary of changes
    • Added ECONNREFUSED to AxiosError in lib/core/AxiosError.js
    • Updated index.d.ts and index.d.cts to expose the new static constant
    • Merged v1.x into this branch (no additional changes)
  • Reasoning
    • Avoids hardcoded strings and aligns with existing codes like ECONNABORTED and ETIMEDOUT
  • Additional context

Docs

  • Add ECONNREFUSED to the list of available AxiosError codes
  • Include a small example using AxiosError.ECONNREFUSED in error handling

Testing

  • No tests added
  • Suggested:
    • Runtime: assert AxiosError.ECONNREFUSED === 'ECONNREFUSED'
    • Types: verify TS autocomplete shows AxiosError.ECONNREFUSED typed as 'ECONNREFUSED'

Semantic version impact

  • Minor: backward-compatible addition of a new typed constant to AxiosError

Written for commit 644ab15. Summary will update on new commits.

Adds `AxiosError.ECONNREFUSED` as a typed constant alongside existing
error codes like ECONNABORTED and ETIMEDOUT, enabling type-safe error
code checks without hardcoding strings.

Closes axios#6485
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@jasonsaayman jasonsaayman merged commit a501f10 into axios:v1.x Apr 25, 2026
23 checks passed
ModyQyW added a commit to uni-helper/uni-network that referenced this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::feat The PR is related to a feature priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ECONNREFUSED error code to AxiosError typings

2 participants