Skip to content

[Regression] #fetch() is now returning generic terminated error message in some cases #1140

Description

Bug Description

It seems like #fetch() is returning different (i.e. less useful) error messages starting in 4.11.2. I'm not exactly sure which change caused it or if it was intentional, but it's now just returning a super generic terminated error message in some cases. Is there any way to access the root cause / detailed description of getaddrinfo ENOTFOUND not-real-subdomain.github23.com in the below example?

Reproducible by

  1. npm install undici@4.11.1
  2. Open up Node REPL
  3. Run the following code: require('undici').fetch('https://not-real-subdomain.github23.com').catch(console.log)

Pre-4.11.2 behavior

TypeError: fetch failed
    at Object.processResponse (/<redacted>/node_modules/undici/lib/fetch/index.js:176:23)
    at fetchFinale (/<redacted>/test/node_modules/undici/lib/fetch/index.js:720:17)
    at EventEmitter.mainFetch (/<redacted>/test/node_modules/undici/lib/fetch/index.js:695:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  cause: Error: getaddrinfo ENOTFOUND not-real-subdomain.github23.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'not-real-subdomain.github23.com'
  }
}

Post-4.11.2 behavior

TypeError: fetch failed
    at Object.processResponse (/<redacted>/test/node_modules/undici/lib/fetch/index.js:175:23)
    at fetchFinale (/<redacted>/test/node_modules/undici/lib/fetch/index.js:717:17)
    at EventEmitter.mainFetch (/<redacted>/test/node_modules/undici/lib/fetch/index.js:692:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  cause: Error: terminated
      at EventEmitter.onRequestAborted (/<redacted>/test/node_modules/undici/lib/fetch/index.js:1507:51)
      at EventEmitter.emit (node:events:390:28)
      at EventEmitter.emit (node:domain:537:15)
      at EventEmitter.terminate (/<redacted>/test/node_modules/undici/lib/fetch/index.js:92:12)
      at Object.onError (/<redacted>/test/node_modules/undici/lib/fetch/index.js:1815:24)
      at Request.onError (/<redacted>/test/node_modules/undici/lib/core/request.js:212:27)
      at errorRequest (/<redacted>/test/node_modules/undici/lib/client.js:1830:13)
      at onError (/<redacted>/test/node_modules/undici/lib/client.js:1056:7)
      at connect (/<redacted>/test/node_modules/undici/lib/client.js:1223:7)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
}

Environment

node@16.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions