Skip to content

Global fetch produces unhelpful Error for ENOTFOUND #42804

Description

@kevinoid

Version

v18.0.0

Platform

Linux kevinolos 5.18.0-rc3 #197 SMP PREEMPT_DYNAMIC Mon Apr 18 07:08:40 MDT 2022 x86_64 GNU/Linux

Subsystem

http

What steps will reproduce the bug?

Run node -e "fetch('http://invalid')"

How often does it reproduce? Is there a required condition?

100% reliable.

What is the expected behavior?

A helpful error, such as the one produced by undici:

Error: getaddrinfo ENOTFOUND invalid.
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'invalid'
}

What do you see instead?

An error indicating that fetch failed with a cause of Error: [object Object]:

TypeError: fetch failed
    at Object.processResponse (node:internal/deps/undici/undici:7188:34)
    at node:internal/deps/undici/undici:7516:42
    at node:internal/process/task_queues:140:7
    at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: [object Object]
      at makeNetworkError (node:internal/deps/undici/undici:6317:51)
      at httpNetworkFetch (node:internal/deps/undici/undici:7810:16)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async httpNetworkOrCacheFetch (node:internal/deps/undici/undici:7703:33)
      at async httpFetch (node:internal/deps/undici/undici:7557:37)
      at async schemeFetch (node:internal/deps/undici/undici:7489:18)
      at async node:internal/deps/undici/undici:7342:20
      at async mainFetch (node:internal/deps/undici/undici:7338:20) {
    [cause]: undefined
  }
}

Additional information

No response

Activity

  1. meixg commented on Apr 21, 2022

    @meixg
    Member

    This seems to be a bug of undici, I tried on the same code on the undici master branch and get the same output.

  2. meixg commented on Apr 21, 2022

    @meixg
    Member

    reopen as we need to update undici

  3. reopened this on Apr 21, 2022
  4. zadmarbella commented on Apr 25, 2022

    @zadmarbella

    Seeing this error also. update to what version? does anyone know the cause? @meixg

  5. mcollina commented on May 4, 2022

    @mcollina
    SponsorMember

    This was fixed in #42939

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

    fetchIssues and PRs related to the Fetch API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions