Skip to content

TypeError: Right-hand side of 'instanceof' is not an object (non-existent AbortError export from node-fetch) #1794

Open

Description

@inshatan

Summary

A runtime error occurs because the code imports AbortError as a named export from node-fetch, but this export does not exist in the runtime version being used. This incorrect import was introduced due to incompatible node-fetch type definitions.

Location

if (err instanceof AbortError) {

Description

In request handling, AbortError is imported from node-fetch and then used in an instanceof check. At runtime, the imported value is not a valid constructor/object. The underlying cause is a typings mismatch: the installed @types/node-fetch version (^2.5.7 => 2.6.11) corresponds to node-fetch v3 and does not match the actual node-fetch v2 used by the project.

Suggested fix

  • Align node-fetch typings with the actual runtime version (pin a compatible @types/node-fetch version for node-fetch v2), or
  • Upgrade to node-fetch v3 and remove @types/node-fetch, since v3 includes built-in TypeScript declarations.
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

    area:node-fetch-v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions