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

DeprecationWarning: The punycode module is deprecated #29

Closed
Arondight opened this issue Aug 5, 2022 · 8 comments
Closed

DeprecationWarning: The punycode module is deprecated #29

Arondight opened this issue Aug 5, 2022 · 8 comments
Labels
dependencies Pull requests that update a dependency file

Comments

@Arondight
Copy link

(node:2941255) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:5:10
    at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:312:7)
    at NativeModule.compileForPublicLoader (node:internal/bootstrap/loaders:252:10)
    at loadNativeModule (node:internal/modules/cjs/helpers:49:9)
    at Function.Module._load (node:internal/modules/cjs/loader:804:15)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/opt/apps/Adachi-BOT/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
# npm list whatwg-url
adachi-bot@1.5.3 /opt/apps/Adachi-BOT
└─┬ sync-fetch@0.4.1
  └─┬ node-fetch@2.6.7
    └── whatwg-url@5.0.0

jsdom/whatwg-url#191

node-fetch/node-fetch@0959ca9#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L63

@larsgw Will you support node-fetch 3.x (or newer)?

@larsgw
Copy link
Owner

larsgw commented Aug 5, 2022

Will you support node-fetch 3.x (or newer)?

node-fetch 3 introduces a lot of breaking changes, the most problematic one being that the package has been converted to an ES module which makes it impossible to import synchronously.

@larsgw
Copy link
Owner

larsgw commented Aug 5, 2022

But in this case there's not much of a choice, I will see if I can figure something out.

@larsgw larsgw added the dependencies Pull requests that update a dependency file label Aug 5, 2022
@Arondight
Copy link
Author

the package has been converted to an ES module which makes it impossible to import synchronously

This project can also be turned into ESM :)

@larsgw
Copy link
Owner

larsgw commented Aug 5, 2022

I know :) However, I think that a lot of situations in which a synchronous version of fetch is required or useful, will not allow asynchronous import() or import ... from statements.

I see two workarounds:

  1. Forking node-fetch. That might cause compatibility problems if both sync-fetch and non-forked node-fetch are used and though I am not sure.
  2. In worker.js it's fine to use import() since it is asynchronous anyway. It's imported in index.js to provide basic implementations of Request, Response, Headers, and FetchError (so I only have to implement the sync part, not input parsing etc.). I could copy the parts of these implementations that I need, but that is effectively also a fork, and the sync-fetch implementation might become incompatible with the node-fetch implementation used in worker.js.

@Arondight
Copy link
Author

@larsgw You can fork node-fetch 2.x and update whatwg-url, then everything be fine

@Arondight
Copy link
Author

That might cause compatibility problems if both sync-fetch and non-forked node-fetch are used and though I am not sure

I don't think so, use @larsgw/node-fetch in your module and node-fetch outside the module so it won't cause problems

@larsgw
Copy link
Owner

larsgw commented Jun 11, 2023

I think I will close this issue in favor of #32 since it is basically about the same thing.

@larsgw larsgw closed this as completed Jun 11, 2023
@ashfaque9426
Copy link

If you are using windows and still getting this warning after updating to node version 21.1.0 then you need to update the npm itself. type 'npm install -g npm@latest' in cmd and that probably fix your issue. It worked for me.

tnir added a commit to tnir/mattermost-developer-documentation that referenced this issue Jul 10, 2024
node-fetch 2.x, followed by sync-fetch, does not support
Node.js 21 and higher fully as it relies on punycode
depending from whatwg-url 5.0.0.

See also larsgw/sync-fetch#29

This change replaces sync-fetch with await and node-fetch v3.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
M-ZubairAhmed pushed a commit to tnir/mattermost-developer-documentation that referenced this issue Jul 18, 2024
node-fetch 2.x, followed by sync-fetch, does not support
Node.js 21 and higher fully as it relies on punycode
depending from whatwg-url 5.0.0.

See also larsgw/sync-fetch#29

This change replaces sync-fetch with await and node-fetch v3.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
cwarnermm pushed a commit to mattermost/mattermost-developer-documentation that referenced this issue Jul 19, 2024
node-fetch 2.x, followed by sync-fetch, does not support
Node.js 21 and higher fully as it relies on punycode
depending from whatwg-url 5.0.0.

See also larsgw/sync-fetch#29

This change replaces sync-fetch with await and node-fetch v3.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

3 participants