You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. #1283
Running datadog-ci git-metadata upload returns the following error every time:
[DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
This sort of warning makes it very difficult to maintain clean CI/CD pipelines. These warnings build up and eventually hide items that are real issues. ...which make this sort of issue a real issue.
The history of this repo shows the warning as occurring in this code for well over a year.
The issue started in datadog/ci:v2.25.0 because the Node.js version bundled in the Docker image went from v20.8.1 to v21.4.0:
$ docker run --entrypoint node datadog/ci:v2.24.1 --version
v20.8.1
$ docker run --entrypoint node datadog/ci:v2.25.0 --version
v21.4.0
To reproduce the issue:
$ docker run -e NODE_OPTIONS=--trace-deprecation datadog/ci:v2.25.0 2>&1| tail -n 14
You can also print more details about any of these commands by calling them with
the `-h,--help` flag right after the command name.
(node:1) [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:397:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:333: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> (/usr/local/lib/node_modules/@datadog/datadog-ci/node_modules/ent/encode.js:1:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
As you can see, the warning comes from ent, which is a 9-years-old package to decode HTML entities.
But sadly, the warning still remains, and this time it's because of the node-fetch package, which is used by gaxios (used in multiple Google API packages).
We can still see the deprecation message in the latest version of datadog-ci:
$ docker run -e NODE_OPTIONS=--trace-deprecation datadog/ci:v2.46.2
(node:1) [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:114:7)
at Function._load (node:internal/modules/cjs/loader:1100:17)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
at Module.require (node:internal/modules/cjs/loader:1340:12)
at require (node:internal/modules/helpers:141:16)
at Object.<anonymous> (/usr/local/lib/node_modules/@datadog/datadog-ci/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
And as I said above, this is caused by whatwg-url, which is a dependency of node-fetch:
From reading whatwg-url release notes, pretty much every breaking release is mostly about raising minimum supported nodejs version
In theory, this dep from node-fetch to whatwg-url is a de facto noop since nodejs 7.x because node 7.x shipped the URL module, and node-fetch@2 uses whatwg-url as follows: const URL = Url.URL || whatwgUrl.URL;
Although, I just tried forcing whatwg-url@14 through yarn resolution in my userland repo, and I get ReferenceError: TextEncoder is not definedhere which makes no sense with node22 🤔
Maybe the remaining non-migrated usages are not called from our code paths.
@jakub-g the issue is that we currently import all commands at startup, which import all the dependencies. And the punycode deprecation warning happens at import time.
I'll try with some await import() at the right places.
The DeprecationWarning should disappear in @datadog/[email protected], except using datadog-ci cloud-run flare with the --with-logs option in Node.js 21+.
I'll keep the issue open until googleapis/google-cloud-node#7565 is closed and we can finally get rid of the deprecation warning altogether.
Activity
Drarig29 commentedon Apr 15, 2024
Hi @tlunsfordCXP! What version of the Docker image are you using?
tlunsfordCXP commentedon Apr 15, 2024
Drarig29 commentedon Apr 15, 2024
Thanks for reporting!
The issue started in
datadog/ci:v2.25.0because the Node.js version bundled in the Docker image went fromv20.8.1tov21.4.0:To reproduce the issue:
As you can see, the warning comes from
ent, which is a 9-years-old package to decode HTML entities.It uses
punycode, which used to be a native module in Node.js but which is deprecated starting from Node 21.This package is imported by
@google-cloud/common:$ yarn why -R ent └─ @datadog/datadog-ci@workspace:. └─ @google-cloud/logging@npm:11.0.0 (via npm:^11.0.0) └─ @google-cloud/common@npm:5.0.1 (via npm:^5.0.0) └─ ent@npm:2.2.0 (via npm:^2.2.0)Since
entisn't maintained anymore, and the corresponding repository was deleted, I'll make a PR on@google-cloud/commonto use a different package.tlunsfordCXP commentedon Apr 15, 2024
Drarig29 commentedon May 2, 2024
Hi @tlunsfordCXP!
googleapis/nodejs-common#812 was merged and released! 🎉
But sadly, the warning still remains, and this time it's because of the
node-fetchpackage, which is used bygaxios(used in multiple Google API packages).This was already reported in googleapis/gaxios#429 (comment), and is tracked in googleapis/gaxios#508.
We'll have to wait for
gaxiosto get rid of this warning. 🙇tlunsfordCXP commentedon May 3, 2024
fishpen0 commentedon Dec 27, 2024
It looks like this package still needs punycode via ajv
ajv8.17.1 has removed punycode and datadog can now use itDrarig29 commentedon Jan 6, 2025
Hi @fishpen0! The
ajvpackage is only used by dev dependencies in datadog-ci, so it's not the culprit:yarn why -R punycode └─ @datadog/datadog-ci@workspace:. ├─ @microsoft/eslint-formatter-sarif@npm:3.1.0 (via npm:^3.0.0) │ └─ eslint@npm:8.57.0 (via npm:^8.9.0) │ ├─ @eslint/eslintrc@npm:2.1.4 (via npm:^2.1.4) │ │ └─ ajv@npm:6.12.6 (via npm:^6.12.4) │ │ └─ uri-js@npm:4.4.1 (via npm:^4.2.2) │ │ └─ punycode@npm:2.3.1 (via npm:^2.1.0) │ └─ ajv@npm:6.12.6 (via npm:^6.12.4) └─ eslint@npm:7.32.0 (via npm:^7.32.0) ├─ @eslint/eslintrc@npm:0.4.3 (via npm:^0.4.3) │ └─ ajv@npm:6.12.6 (via npm:^6.12.4) └─ ajv@npm:6.12.6 (via npm:^6.10.0)We can still see the deprecation message in the latest version of datadog-ci:
And as I said above, this is caused by
whatwg-url, which is a dependency ofnode-fetch:yarn why -R whatwg-url └─ @datadog/datadog-ci@workspace:. ├─ @google-cloud/logging@npm:11.1.0 (via npm:^11.1.0) │ ├─ @google-cloud/common@npm:5.0.2 (via npm:^5.0.0) │ │ ├─ google-auth-library@npm:9.7.0 (via npm:^9.0.0) │ │ │ ├─ gaxios@npm:6.7.0 (via npm:^6.1.1) │ │ │ │ └─ node-fetch@npm:2.7.0 [22a35] (via npm:^2.6.9 [22a35]) │ │ │ │ └─ whatwg-url@npm:5.0.0 (via npm:^5.0.0) │ │ │ ├─ gcp-metadata@npm:6.1.0 (via npm:^6.1.0) │ │ │ │ └─ gaxios@npm:6.7.0 (via npm:^6.0.0) │ │ │ └─ gtoken@npm:7.1.0 (via npm:^7.0.0) │ │ │ └─ gaxios@npm:6.7.0 (via npm:^6.0.0) │ │ ├─ retry-request@npm:7.0.2 (via npm:^7.0.0) │ │ │ └─ teeny-request@npm:9.0.0 (via npm:^9.0.0) │ │ │ └─ node-fetch@npm:2.7.0 [22a35] (via npm:^2.6.9 [22a35]) │ │ └─ teeny-request@npm:9.0.0 (via npm:^9.0.0) │ ├─ gcp-metadata@npm:6.1.0 (via npm:^6.0.0) │ ├─ google-auth-library@npm:9.7.0 (via npm:^9.0.0) │ └─ google-gax@npm:4.3.8 (via npm:^4.0.3) │ ├─ google-auth-library@npm:9.7.0 (via npm:^9.3.0) │ ├─ retry-request@npm:7.0.2 (via npm:^7.0.0) │ └─ node-fetch@npm:2.7.0 [22a35] (via npm:^2.6.9 [22a35]) ├─ @google-cloud/run@npm:1.4.0 (via npm:^1.4.0) │ └─ google-gax@npm:4.3.8 (via npm:^4.0.3) ├─ google-auth-library@npm:9.12.0 (via npm:^9.12.0) │ ├─ gaxios@npm:6.7.0 (via npm:^6.1.1) │ ├─ gcp-metadata@npm:6.1.0 (via npm:^6.1.0) │ └─ gtoken@npm:7.1.0 (via npm:^7.0.0) └─ pkg@npm:5.8.1 [77038] (via npm:5.8.1 [77038]) └─ pkg-fetch@npm:3.4.2 (via npm:3.4.2) └─ node-fetch@npm:2.7.0 [22a35] (via npm:^2.6.9 [22a35])This may have been fixed since my last message though, so I'll look into a possible update.
jakub-g commentedon Jan 27, 2025
I did some digging:
FWIW:
14.x[email protected](release logs)In theory, this dep from node-fetch to whatwg-url is a de facto noop since nodejs 7.x because node 7.x shipped the URL module, and node-fetch@2 uses whatwg-url as follows:
const URL = Url.URL || whatwgUrl.URL;Although, I just tried forcing whatwg-url@14 through yarn resolution in my userland repo, and I get
ReferenceError: TextEncoder is not definedhere which makes no sense with node22 🤔jakub-g commentedon Feb 12, 2025
FWIW, until this is fixed, it's possible to suppress this warning by running datadog-ci as follows:
(as long as you use it as a yarn dependency, without bundled node binary)
Drarig29 commentedon Feb 12, 2025
Note that there is some update on
google-auth-library's side: googleapis/google-auth-library-nodejs#1938 was created, and updatesgaxiosto7.0.0-rc.1, which includes googleapis/gaxios#617.Drarig29 commentedon Jun 11, 2025
Update:
[email protected]was released so we now need to wait for:google-gaxto use the new[email protected]@google-cloud/runto use the futuregoogle-gax@google-cloud/loggingto use the new[email protected],[email protected], and futuregoogle-gaxAnd that should be it!
jakub-g commentedon Aug 20, 2025
google-cloud/runreleased 3.0 this month which usesgoogle-gax5.0But maybe we can try to bump the deps and see if the issue is still there? Maybe the remaining non-migrated usages are not called from our code paths.
Drarig29 commentedon Aug 20, 2025
@jakub-g the issue is that we currently import all commands at startup, which import all the dependencies. And the
punycodedeprecation warning happens at import time.I'll try with some
await import()at the right places.Drarig29 commentedon Aug 21, 2025
Thanks for the suggestion @jakub-g!
The
DeprecationWarningshould disappear in@datadog/[email protected], except usingdatadog-ci cloud-run flarewith the--with-logsoption in Node.js 21+.I'll keep the issue open until googleapis/google-cloud-node#7565 is closed and we can finally get rid of the deprecation warning altogether.