apollographql / apollographql/datasource-rest
"DeprecationWarning: The `punycode` module is deprecated." in Node 22
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Node version: 22.1.0
@apollo/datasource-rest version: 6.2.2 (latest version at time of writing)
# The problem
Since moving to use node 22, we have seen the following deprecation warning:
```
(node:47562) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
at node:punycode:3:9
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:337:10)
at loadBuiltinModule (node:internal/modules/helpers:104:7)
at Module._load (node:internal/modules/cjs/loader:1075:17)
at Module.require (node:internal/modules/cjs/loader:1310:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/Users/remy.oudemans/Documents/apply-bff/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
at Module._compile (node:internal/modules/cjs/loader:1480:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
```
This will affect everyone using Node 22, which is the Current Node release and will move to LTS on 2024-10-29.
# Where it comes from
We have tracked this down to `@apollo/datasource-rest` using `"node-fetch": "^2.6.7"` ([link](https://github.com/apollographql/datasource-rest/blob/main/package.json#L65C6-L65C27)) which uses `"whatwg-url": "^5.0.0"` ([link](https://github.com/node-fetch/node-fetch/blob/v2.7.0/package.json#L40)) which [uses the deprecated punycode module](https://github.com/jsdom/whatwg-url/blob/v5.0.0/src/url-state-machine.js#L2).
The current version of node-fetch does not depend on `whatwg-url` at all: https://github.com/node-fetch/node-fetch/blob/v3.3.2/package.json#L64. So updating to that version should fix this warning.
Node-fetch v3 is an ESM-only package, so that may make the update tricky.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing package.json and the dependency path from @apollo/datasource-rest through node-fetch and whatwg-url. Check how the package currently loads node-fetch, then evaluate the Node 22 warning and the ESM implications of the proposed update. Done means the deprecated punycode warning no longer appears for Node 22 users and the existing package behavior remains covered by the project checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100