Visitar URL original
node:util.types.isNativeError() is false for AxiosError · Issue #5394 · axios/axios · GitHub
Skip to content

node:util.types.isNativeError() is false for AxiosError #5394

Closed

Description

@SchroederSteffen

Describe the bug

Using util.types.isNativeError() with an AxiosError returns false.
At the same time, axiosError instanceof Error returns true.

I would consider this a bug of axios, because it claims that class AxiosError extends Error:

export class AxiosError<T = unknown, D = any> extends Error {

I couldn't figure out why it behaves like that.

To Reproduce

https://runkit.com/embed/nty2gimaty2q

Code snippet

var { types } = require('node:util');
var { AxiosError } = require("axios");

console.log(types.isNativeError(new AxiosError())); // false
console.log(new AxiosError() instanceof Error); // true

// at the same time:
class CustomSubError extends Error {}
console.log(types.isNativeError(new CustomSubError())); // true

Expected behavior

util.types.isNativeError(new AxiosError()) should return true.

Axios Version

1.2.1

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

16.19.0

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

Activity

  1. brodo commented on Feb 13, 2023

    @brodo
    Contributor

    I ran into this issue today. I'm willing to submit a PR and refactor AxiosError from a function to a class that extends Error if that kind of PR is welcome.

  2. self-assigned this
    on Aug 6, 2025
  3. added a commit that references this issue on Jan 26, 2026
  4. jasonsaayman commented on Apr 9, 2026

    @jasonsaayman
    Member

    Closing as this was fixed by merged PR #5558

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

Metadata

Metadata

Assignees

Labels

issue::bugThis issue is related to a bug that requires fixing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions