gaxios icon indicating copy to clipboard operation
gaxios copied to clipboard

feat!: Upgrade to `node-fetch` v3

Open danielbankhead opened this issue 10 months ago • 7 comments

Fixes #429 Fixes #508

🦕

danielbankhead avatar Apr 16 '24 22:04 danielbankhead

Warning: This pull request is touching the following templated files:

  • README.md - README.md is managed by synthtool. However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml

We'll merge this once we're ready to drop Node 14/16 (which is WIP)

danielbankhead avatar Apr 16 '24 22:04 danielbankhead

General question / comment I know that both fetch and FormData are marked experimental stability in Node 18 but does it make more sense to free ourselves from node-fetch as opposed to upgrading? Edit: looks like it is marked stable as of Node 21.

ddelgrosso1 avatar Apr 17 '24 13:04 ddelgrosso1

General question / comment I know that both fetch and FormData are marked experimental stability in Node 18 but does it make more sense to free ourselves from node-fetch as opposed to upgrading? Edit: looks like it is marked stable as of Node 21.

I was a bit torn on this decision; technically it would be experimental, however the API surface hasn't really changed since its introduction. The catch is the experimental warnings for customers below v18.13 (which we'd likely have to support given engines would be >=18.0.0). However, I would be surprised if a lot of folks are actually using an old version of 18, without any security patches/minor features whatsoever - I would suspect those pre-LTS early adopters would've upgraded by now.

Outside from that, internally we would need to use a beta version of nock, which includes unidici support - it seems to work fine in testing.

danielbankhead avatar Apr 17 '24 16:04 danielbankhead

Ah I hadn't even considered nock not supporting it. I wonder if by the time we are ready to move to Node 18 nock will be out of the beta phase.

ddelgrosso1 avatar Apr 17 '24 17:04 ddelgrosso1

Created a proof-of-concept for migrating to fetch, along with current limitations:

  • https://github.com/googleapis/gaxios/pull/618

danielbankhead avatar Apr 19 '24 19:04 danielbankhead

Node 18 & 20 pass in this commit 👌🏽:

  • https://github.com/googleapis/gaxios/pull/617/commits/35a73b1e35ffb2fd1b93ccac2b91fae93ad91d72

danielbankhead avatar Apr 19 '24 23:04 danielbankhead