Skip to content

interceptors.responseError does not raise networking errors #3929

@Gigioliva

Description

@Gigioliva

interceptors.responseError does not raise networking errors

When the interceptors.responseError interceptor is used, this does not raise network errors, returning the request as if it had been successful.

Reproducible By

import { Pool } from "undici";

const URL = "https://foo.bar.ciao.com"; // <- URL does not exist

async function main() {
  const client = new Pool(URL);

  try {
    const response = await client
      .compose(interceptors.responseError({ throwOnError: true }))
      .request({ method: "GET", path: "/" });

    console.log(response.statusCode);
  } catch (e) { // <- not raised
    console.log(e);
  }
}

if (require.main === module) {
  void main();
}

Expected Behavior

request raises an error Error: getaddrinfo ENOTFOUND. This is raised when we don't use interceptors.responseError

Environment

  • node: 20.18
  • undici: 7.1.0

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