Skip to content

google-gax / gaxios: node-fetch@3 keeps deprecated node-domexception in every install, on Node >=22 where fetch is native #9929

Open

Description

@JaTvoiRabotnik

Summary

A clean npm install [email protected] on Node 22 prints:

npm warn deprecated [email protected]: Use your platform's native DOMException instead

The chain is:

[email protected]
└─┬ [email protected]              (direct dependency of google-gax, and of [email protected])
  └─┬ [email protected]
    └── [email protected]

Every @google-cloud/* client built on gax inherits it. For example, we see it through @google-cloud/tasks. Related reports are #7666 (core libraries, via gaxios) and #7221 (BigQuery, via teeny-request). This issue covers the gax and gaxios path specifically, with notes on what a fix involves.

What I found

Both packages already require engines.node >= 22, where fetch, Response, AbortController and DOMException are all built in. Yet:

  1. google-gax uses node-fetch for types only. In core/packages/gax/src, fallbackServiceStub.ts has import type {Response as NodeFetchResponse} from 'node-fetch', and streamArrayParser.ts only mentions node-fetch in comments. The real request goes through gaxios (auth.fetch()). So gax's direct dependency could probably become a devDependency, or be replaced by the global Response type. On its own that does not remove the warning, because of point 2.
  2. gaxios always loads node-fetch on Node. Gaxios.#getFetch() uses window.fetch in browsers and the native fetch in Bun, but on Node it unconditionally runs (await import('node-fetch')).default. That is the runtime consumer keeping node-fetch@3, and therefore fetch-blob and node-domexception, in every install.

Why this is not just a one-line switch to globalThis.fetch

The obvious blocker is proxy and agent support: gaxios passes an agent (for example from https-proxy-agent) that node-fetch understands, but Node's built-in fetch (undici) ignores it. It needs a dispatcher instead, such as undici's ProxyAgent or EnvHttpProxyAgent. There are also behaviour differences already worked around in the code: abort-signal reasons, and res.data configurability.

Possible directions

  • In gaxios, use the native fetch on Node when no custom agent is set, and keep node-fetch (or an undici dispatcher) only for the agent/proxy path. Making node-fetch an optional peer, or loading it lazily, would let users who don't use proxies drop it.
  • Or use the native fetch throughout and map agent/proxy settings onto an undici dispatcher.
  • In google-gax, drop the type-only node-fetch dependency (independent of the above, and low-risk).

Environment

  • google-gax 6.17.0, gaxios 8.3.3, node-fetch 3.3.2, fetch-blob 3.2.0
  • Node 22.23, npm 10.9

Activity

  1. maciejbaba commented on Nov 23, 2026

    @maciejbaba

    Linking related work so this can be triaged alongside it:

    The warning only goes away for good once gaxios stops loading node-fetch, so #9785 on its own won't remove it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions