Skip to content

UND_ERR_HEADERS_TIMEOUT received even when setting a larger headersTimeout in dispatcher for fetch() #1864

@xconverge

Description

@xconverge

Bug Description

I am trying to make a fetch request that can take 5+ minutes.

I make a fetch() request with a custom Agent containing atleast these parameters (I have also overridden connect for overriding checkServerIdentity())

    headersTimeout: 3000000,
    bodyTimeout: 3000000,

fetch() call looks like this:

      fetch( url,  {
          dispatcher: this.apiParameters.httpAgent,
          method: "get",
        }

yet after about ~200 seconds I am getting a headers timeout

TypeError: fetch failed
    at fetch (/node_modules/undici/index.js:105:13)
    at location I called unidici fetch) {
  cause: HeadersTimeoutError: Headers Timeout Error
      at Timeout.onParserTimeout [as _onTimeout] (/node_modules/undici/lib/client.js:902:28)
      at listOnTimeout (node:internal/timers:566:11)
      at process.processTimers (node:internal/timers:507:7) {
    code: 'UND_ERR_HEADERS_TIMEOUT'
  }
}

Reproducible By

Performing a LONG fetch operation

Expected Behavior

I would expect some combination of me setting headerTimeout to either 0 or a very high number to not trigger this timeout.

Logs & Screenshots

Environment

Ubuntu 20 in WSL, Node 18

Additional context

I have seen some stuff related to "blocking" https://undici.nodejs.org/#/docs/api/Dispatcher but am unable to figure out where to set it and am unsure if its even related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions