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

punycode deprecation warning in node 21 #1332

Open
twelvelabs opened this issue Nov 16, 2023 · 14 comments · Fixed by #1719 · May be fixed by #1755
Open

punycode deprecation warning in node 21 #1332

twelvelabs opened this issue Nov 16, 2023 · 14 comments · Fixed by #1719 · May be fixed by #1755

Comments

@twelvelabs
Copy link

Describe the bug

I'm getting a node depreciation warning whenever I run redocly on node v21. Looks like it's coming from whatwg-url. They appear to have fixed it in v13.0.0.

To Reproduce

$ node --version
v21.1.0

$ redocly --version
1.4.1

$ NODE_OPTIONS='--trace-deprecation' redocly lint
(node:48436) [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:392:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
    at loadBuiltinModule (node:internal/modules/helpers:101:7)
    at Module._load (node:internal/modules/cjs/loader:1001:17)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/@redocly/cli/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
validating /src/schemas/default/openapi.yaml...
/src/schemas/default/openapi.yaml: validated in 3ms

Woohoo! Your API description is valid. 🎉

Expected behavior

No depreciation warning 😄.

Redocly Version(s)

1.4.1

Node.js Version(s)

v21.1.0

@twelvelabs twelvelabs added the Type: Bug Something isn't working label Nov 16, 2023
@tatomyr
Copy link
Contributor

tatomyr commented Nov 16, 2023

Thanks for reporting! We'll take a look at this.

@tatomyr tatomyr added the p3 label Nov 16, 2023
@bentcoder
Copy link

Same here.

node: v21.2.0
npm: 10.2.4
yarn: 1.22.19

To reproduce.

FROM node:alpine3.18
ENV REDOCLY_TELEMETRY off
ENV NODE_OPTIONS --trace-deprecation
RUN npm install -g [email protected]
RUN npm install -g @redocly/cli
WORKDIR /api
COPY spec.yaml /api
RUN redocly lint spec.yaml

@tatomyr tatomyr added Type: Maintenance and removed Type: Bug Something isn't working p3 labels Dec 29, 2023
@tatomyr
Copy link
Contributor

tatomyr commented Dec 29, 2023

The issue comes from AJV:


┬ @redocly/[email protected] -> ./packages/core
└─┬ @redocly/[email protected]
  └─┬ [email protected]
    └── [email protected]

@RomanHotsiy
Copy link
Member

We need to update our fork to the upstream version I think.

@domdomegg
Copy link

See garycourt/uri-js#95

@drwpow
Copy link

drwpow commented Jun 20, 2024

Update: problem also exists in Node 22 (current version)

@piotr-cz
Copy link

The issue also comes up from outdated tr46 package.

My workaround in package.json

{
  "overrides": {
    "@redocly/cli": {
      "uri-js": "npm:uri-js-replace",
      "whatwg-url": "^14.0.0"
    }
  }
}

It seems that updating project dependencies (ajv, node-fetch) should fix the problem

@lornajane lornajane added the p2 label Sep 4, 2024
@DmitryAnansky
Copy link
Contributor

DmitryAnansky commented Sep 6, 2024

@tatomyr / @lornajane
This issue should be fixed in @redocly/ajv "version": "8.11.2",
But it will take effect with the next version of CLI release.

@piotr-cz
Copy link

piotr-cz commented Sep 10, 2024

The native punycode is still required inside the outdated version [email protected]:

https://github.com/jsdom/tr46/blob/0.0.3/index.js#L3

@tatomyr
Copy link
Contributor

tatomyr commented Sep 16, 2024

It's still reproducible. Reopening the issue.

@tatomyr tatomyr reopened this Sep 16, 2024
@piotr-cz
Copy link

piotr-cz commented Oct 2, 2024

The uri-js package has been replaced by uri-js-replace in recent versions of @redocly/cli dependencies, but the issue persist due to [email protected]

@adamaltman
Copy link
Member

Can we increase the priority of this (not because it causes any functional issue but because of pure aesthetics)?

DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

@tatomyr
Copy link
Contributor

tatomyr commented Oct 4, 2024

@adamaltman sure. @DmitryAnansky was about to pick it up the next week.

@piotr-cz
Copy link

piotr-cz commented Oct 4, 2024

Given that node-fetch (that requires outdated whatwg-url package) is a polyfill for native fetch which is available in newer node versions,
I'd use it only when native fetch is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment