Skip to content

[Bug] isNetworkError Checks Node Errno Codes on Wrong Property (error.name vs error.code) #737

Closed

Description

@akramcodez

Description

The isNetworkError function checks error.name for Node.js system error codes such as ECONNREFUSED, ENOTFOUND, ECONNRESET, and ETIMEDOUT. In Node.js, these codes live on error.code, not error.name. The name property of a system error is always "Error". As a result, isNetworkError never returns true for actual Node network failures - only for the loose message-string matches further down the condition.

The same problem affects ETIMEDOUT in isTimeoutError.

Environment

  • OS: Any
  • Node version: Any (v18+)
  • Nanocoder version: Latest
  • Provider: Any network-facing provider (OpenRouter, OpenAI-compatible)
  • Model: Any

Steps to Reproduce

  1. Configure a provider with an unreachable base URL.
  2. Send a prompt and wait for the connection to be refused.
  3. Inspect the ErrorInfo object returned by createErrorInfo().
  4. Observe isNetworkError is false even though the error is ECONNREFUSED.

Expected Behavior

isNetworkError should return true when Node throws a system error with error.code === 'ECONNREFUSED' (or ENOTFOUND, ECONNRESET).

Actual Behavior

isNetworkError returns false because it checks error.name which is always "Error" for system errors, not the errno code.

Logs/Screenshots

N/A

Additional Context

  • Fix: replace error.name === 'ECONNREFUSED' with (error as NodeJS.ErrnoException).code === 'ECONNREFUSED' (and equivalents for ENOTFOUND, ECONNRESET, ETIMEDOUT).
  • Note: This issue is intentionally kept small and is suitable for first-time contributors. If you're interested in working on it, please leave a comment below and ask to be assigned before opening a pull request.
  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder

Activity

  1. added
    bug
    good first issue
    on Aug 1, 2026
  2. nightcityblade commented on Aug 1, 2026

    @nightcityblade

    Hi, I'd like to work on this. Could you please assign it to me? I'll submit a focused fix with regression tests shortly.

  3. MsadafK commented on Aug 1, 2026

    @MsadafK

    Hi @akramcodez , I would like to work on this issue. Please assign it to me!

  4. akramcodez commented on Aug 2, 2026

    @akramcodez
    MemberAuthor

    Hey @nightcityblade and @MsadafK, you both are already assigned to other issues. Could you please complete those first before taking on new ones? Thanks!

  5. RealBhupesh commented on Aug 2, 2026

    @RealBhupesh
    Contributor

    I would like to work on this issue. I will include a focused fix and regression coverage in a PR shortly.

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

Metadata

Metadata

Assignees

Labels

buggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions