Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cross-fetch as a server package dependency #658

Open
MasterKale opened this issue Dec 10, 2024 · 0 comments · May be fixed by #661
Open

Remove cross-fetch as a server package dependency #658

MasterKale opened this issue Dec 10, 2024 · 0 comments · May be fixed by #661

Comments

@MasterKale
Copy link
Owner

Describe the issue

Running the example project in Node 22 reveals a DeprecationWarning about the "punycode" module:

example/ $ npm run build
example/ $ node --trace-deprecation dist/index.js
(node:73571) [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:399:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:338:10)
    at loadBuiltinModule (node:internal/modules/helpers:112:7)
    at Function._load (node:internal/modules/cjs/loader:1100:17)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
    at Module.require (node:internal/modules/cjs/loader:1340:12)
    at require (node:internal/modules/helpers:138:16)
    at Object.<anonymous> (/Users/mattmil3/Developer/SimpleWebAuthn/example/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
🚀 Server ready at http://localhost:8000 (127.0.0.1:8000)

Digging into the dependency graph, whatwg-url is a dependency of cross-fetch:

example/ $ npm list --depth=5
[email protected] /Users/mattmil3/Developer/SimpleWebAuthn/example
├─┬ @simplewebauthn/[email protected]
│ ├─┬ ...
│ └─┬ [email protected]
│   └─┬ [email protected]
│     ├── UNMET OPTIONAL DEPENDENCY encoding@^0.1.0
│     └─┬ [email protected]
│       ├── [email protected]
│       └── [email protected]

Cross-fetch shouldn't be needed anymore, though, as the minimum supported Node is 20 where the fetch API is available globally. Deno features fetch globally too. Looking at when I added cross-fetch (which replaced node-fetch) two years ago now, it was necessary when this project still targeted Node 16 (Node 18 introduced fetch support.)

Interestingly only MetadataService uses cross-fetch by importing helpers/fetch.ts:

Screenshot 2024-12-10 at 7 34 33 AM

Enough time has passed I think it's safe to cross cross-fetch from the server package to prevent this issue, and to update MetadataService to use globally-available fetch() instead.

@MasterKale MasterKale linked a pull request Dec 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant