Skip to content

fix: remove punycode deprecation warning (DEP0040) on every wrangler invocation - #14843

Open
Irishsmurf wants to merge 1 commit into
cloudflare:mainfrom
Irishsmurf:fix/punycode-deprecation-warning
Open

fix: remove punycode deprecation warning (DEP0040) on every wrangler invocation#14843
Irishsmurf wants to merge 1 commit into
cloudflare:mainfrom
Irishsmurf:fix/punycode-deprecation-warning

Conversation

@Irishsmurf

@Irishsmurf Irishsmurf commented Jul 25, 2026

Copy link
Copy Markdown

Summary

Every wrangler invocation logs a Node deprecation warning:

(node:...) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

Root cause: the bundled cloudflare API client (packages/wrangler's cloudflare devDependency, used by @cloudflare/workers-utils too) depends on node-fetch@2.x, which depends on whatwg-url@5.0.0. Both whatwg-url@5.0.0 itself and its tr46@0.0.3 dependency directly require("punycode") against Node's deprecated built-in module instead of the (API-identical) userland punycode npm package.

Note that tr46's public API changed completely starting at v1.0.0 (positional-args API replaced with an options-object API, string returns replaced with {domain, error} objects), so bumping tr46/whatwg-url's version isn't a safe fix for whatwg-url@5.0.0 — it would silently change IDNA/domain-parsing behavior. Bumping the cloudflare SDK to v7 (which dropped node-fetch and this whole dependency chain in favor of native fetch) would fix it too, but that's a major-version bump used extensively throughout the codebase, better scoped and tested by folks who know every call site.

Fix

Two pnpm patches, both same-version (no behavior change):

  • patches/tr46@0.0.3.patch: require("punycode")require("punycode/")
  • patches/whatwg-url@5.0.0.patch: same change in lib/url-state-machine.js

The trailing slash forces Node to resolve the userland punycode package instead of the deprecated builtin. Since pnpm patch doesn't re-resolve a patched package's declared dependencies, I added packageExtensions entries in pnpm-workspace.yaml to properly wire punycode@^2.3.1 into both packages' dependency graphs (verified in the lockfile diff — it's a real dependency edge, not incidental hoisting).

Test plan

  • pnpm turbo build --filter=wrangler succeeds
  • grep -n 'require(.punycode' wrangler-dist/cli.js — no matches (previously 2)
  • NODE_OPTIONS='--trace-deprecation' node wrangler-dist/cli.js --version — no warning
  • pnpm test -F wrangler — 250 test files, 4826 tests passed
  • pnpm exec turbo check:type -F wrangler -F @cloudflare/workers-utils — passes
  • Added changeset (patch bump for wrangler and @cloudflare/workers-utils)

Open in Devin Review

…invocation

The bundled `cloudflare` API client depends on node-fetch@2.x, which
depends on whatwg-url@5.0.0 and its tr46@0.0.3 dependency. Both
directly `require("punycode")` against Node's deprecated built-in
module instead of the userland `punycode` package, so every wrangler
command logs:

  (node:...) [DEP0040] DeprecationWarning: The `punycode` module is
  deprecated. Please use a userland alternative instead.

Patch both packages to require the userland `punycode` package
instead (identical API, no behavior change) and wire it into the
dependency graph via packageExtensions, since pnpm doesn't re-resolve
a patched package's declared dependencies.
@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a0f16c0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
wrangler Patch
@cloudflare/workers-utils Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch
@cloudflare/workers-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod
workers-devprod requested review from a team and emily-shen and removed request for a team July 25, 2026 16:06
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/fix-punycode-deprecation-warning.md: [@cloudflare/wrangler]
  • patches/tr46@0.0.3.patch: [@cloudflare/wrangler]
  • patches/whatwg-url@5.0.0.patch: [@cloudflare/wrangler]
  • pnpm-lock.yaml: [@cloudflare/wrangler]
  • pnpm-workspace.yaml: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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 this pull request may close these issues.

2 participants