Skip to content

Conversation

@wojtekn
Copy link
Contributor

@wojtekn wojtekn commented Jul 17, 2025

Related issues

Proposed Changes

  • I propose to suppress punycode warnings for both the CLI and the app. It doesn't cause any problems for the app, but it shows a confusing warning as part of the command output.
Before After
Screenshot 2025-07-17 at 14 23 51 Screenshot 2025-07-17 at 14 23 12

Installing punycode as an explicit dependency didn't help - there is some dependency that loads deprecated punycode.

Testing Instructions

  1. Rebuild command:
npm run cli:watch
  1. Run command
node dist/cli/main.js
  1. Confirm there is no punycode warning.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@wojtekn wojtekn requested a review from a team July 17, 2025 12:25
@wojtekn wojtekn self-assigned this Jul 17, 2025
Copy link
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

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

Changes LGTM and I can confirm that the warnings are suppressed. 👍

trunk this branch
Image Image

sejas

This comment was marked as resolved.

@wojtekn
Copy link
Contributor Author

wojtekn commented Jul 22, 2025

@sejas thanks for confirming. I tried again, and reproduced.

Copy link
Member

sejas commented Jul 22, 2025

yep, all good, I was able to reproduce it.

Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

I confirm this PR hides the punycode warning with code DEP0040.
It would be interesting to track an issue if upgrading some dependencies can fix the issue in the future.

Before:

❯ node dist/cli/main.js  --help
(node:31152) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
WordPress Studio CLI

Commands:
  studio preview  Manage preview sites

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --path     Path to the WordPress files   [string] [default: Current directory]

You must provide a valid command

After

❯ node dist/cli/main.js --help
WordPress Studio CLI

Commands:
  studio preview  Manage preview sites

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --path     Path to the WordPress files   [string] [default: Current directory]
`

@sejas
Copy link
Member

sejas commented Jul 22, 2025

Here are the dependencies that use punycode.

❯ npm ls punycode
./studio
├─┬ @wp-playground/[email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected]
└─┬ [email protected]
  └─┬ [email protected]
    ├─┬ [email protected]
    │ └── [email protected] deduped
    └─┬ [email protected]
      └─┬ [email protected]
        └── [email protected] deduped

I suspect that I didn't see the error at first because I was experimenting with the latest playground dependencies. We can revisit if we can remove this custom code after we update to Blueprints 1.2.3+.

@wojtekn
Copy link
Contributor Author

wojtekn commented Jul 22, 2025

@sejas the trick is that the warning doesn't come from NPM dependencies you showed in the npm ls output. The Punycode 2.3.1 module installed as an NPM dependency is functioning correctly.

The warning thrown from punycode, which is part of Node, and used by one of our dependencies, possibly this one:

% npm ls tr46                                              
[email protected] /Users/cyphelf/Sites/studio
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected]
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected]

We could pursue it further, but even if we fix it, it can resurface if any other dependency starts using Node's punycode.

@sejas
Copy link
Member

sejas commented Jul 22, 2025

Yeah, I think it makes sense to merge this PR. But I also think that from time to time, if we upgrade a dependency that includes punycode, we should check if this warning is gone. My feeling is that @wp-playground/blueprints is the one pulling that dependency and causing the warning, but you're right that it could be tr46 or another package.

@wojtekn wojtekn merged commit 81aa95b into trunk Jul 23, 2025
13 checks passed
@wojtekn wojtekn deleted the fix/punycode-warnings branch July 23, 2025 05:22
@epeicher
Copy link
Contributor

epeicher commented Jul 23, 2025

@sejas, @wojtekn, also there is the npm why command that can be used to identify the chain of dependencies causing a package to be installed: https://docs.npmjs.com/cli/commands/npm-explain.

For example, npm why punycode. The problem is that the output is a bit verbose.

Additionally, we can temporarily use yarn && yarn why punycode and the output is more concise:

CleanShot 2025-07-23 at 09 13 49@2x

Then delete the yarn.lock afterwards to clean leftovers.

@wojtekn
Copy link
Contributor Author

wojtekn commented Jul 23, 2025

@epeicher thanks for sharing those steps.

As I mentioned above, it's not really about an NPM dependency that uses punycode as NPM dependency. It's about some dependency that loads NPM's punycode module which is deprecated since Node 22 - as far as I see, at least tr46 package does that:

require("punycode")

See the StackOverflow thread.

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.

5 participants