All jobs

Fix "[DEP0060] DeprecationWarning: The util._extend API is deprecated" From http-proxy on Node 22

Yes. An agent traces the Node 22 warning to http-proxy, tests a maintained replacement against your proxy options, and opens a pull request with the tradeoffs.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The full line is (node:1234) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead. It started appearing on Node 22, and for most projects that see it the call is not in their own code. It is in http-proxy, which loads require('util')._extend in lib/http-proxy/common.js and lib/http-proxy/index.js and uses it to copy headers and options. The newest release of http-proxy on npm is still 1.18.1, so no upgrade of that package makes the warning go away. That is why the usual first attempt, npm update, changes nothing.

The agent finds the caller before proposing anything. It runs the program with node --trace-deprecation, which prints the stack at the point of the warning: common.setupOutgoing at line 43 of common.js, reached from the proxy's web-incoming pass. It also establishes when the warning fires, which is easy to get wrong. Requiring the module prints nothing, and so does creating the proxy server. The line appears when the first request is proxied, once per process. A quick check that only starts the program and exits looks clean whether or not anything was fixed.

icflorescu/iisexpress-proxy, a command-line proxy for reaching IIS Express from other devices, is a direct user. Its package.json depends on "http-proxy": "^1.18.1", and index.js builds the server with httpProxy.createProxyServer({ target, secure: false, changeOrigin: true, xfwd: true, autoRewrite: true, ws: true, ssl }). The repository has no test suite, so the agent writes a throwaway check: a small upstream HTTP server, the proxy in front of it with the same options, and two requests through it, run under --trace-deprecation so that any warning shows its origin. When the dependency is indirect instead, npm ls http-proxy names the package that brings it in, commonly http-proxy-middleware under a dev server, and the fix moves to that package's version.

There are three honest options and the agent tests each one. http-proxy-3 is a maintained rewrite that exports the same createProxyServer; the check passes on it with no warning, but its engines field requires Node 22 or later, while this project declares "node": ">=6", so adopting it raises the minimum Node version and that belongs in the release notes. Keeping http-proxy and starting Node with --disable-warning=DEP0060 hides the line without changing code, which suits an application you launch yourself and does not suit a published command whose users run it through a shebang. The third is to wait, and to make sure nothing in CI runs with --throw-deprecation, because under that flag the first proxied request throws instead of warning.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "On Node 22 this project prints \"[DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.\" Find where it comes from. Search the project's own source for util._extend first. Then run npm ls http-proxy and report whether http-proxy is a direct dependency or which package brings it in, and the installed version. Write a temporary script outside the source tree that starts a local upstream HTTP server, puts the project's proxy in front of it with the same options the project uses, and sends two requests through it. Run it on Node 22 with --trace-deprecation and save the warning with its stack. Note at which step the warning appears (require, server creation or first request). Check the npm registry for the newest http-proxy release and say whether any release removes the call. Then evaluate the options with the same script: a maintained drop-in replacement for http-proxy with the same API (check its engines field against this project's supported Node versions and against websocket and TLS options the project uses); for an indirect dependency, a newer release of the parent package; and suppressing only this warning code at launch. For each option report whether the warning is gone, what else changes, and the minimum Node version it implies. Implement the option that removes the warning with the fewest side effects for this project, update the lockfile, and adjust the engines field and README if the minimum Node version changes. Do not silence all warnings. Open a pull request with the stack trace before, the script's output after, and the options you rejected with the reason for each.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request that changes the dependency in package.json, the lockfile, the require line and, if the supported Node range moved, the engines field and the README. The description contains the traced warning from before the change, with the file and line inside http-proxy that produced it, and the output of the same two-request check afterwards. It lists the options that were tried and not taken, each with one line on why.

A reviewer weighs the Node version first. Replacing the library is the only way to remove the call itself, and for a tool that promises to run on old Node versions that is a breaking change, to be released as a major version or declined. They then look at behaviour the two-request check does not cover: websocket upgrades, self-signed certificates, rewritten redirects. If the project relies on those, ask the agent in a follow-up message to extend its check, and it continues in the same sandbox. Where the agent chose suppression, the reviewer confirms that the flag names this one code and nothing wider.

Run it on every Node.js upgrade

Runtime deprecations arrive with a Node major, and they arrive in every service at once. When your base image or .nvmrc moves to a new Node, send the request above to each repository from a script, with the warning text replaced by whatever the new version prints. Each call carries its own request_id, a new UUID, so a retried call returns the run it started the first time. Runs beyond the key's concurrency limit wait as queued.

To see new warnings before users do, add an automation to each Project with a schedule trigger, a weekly cron and a prompt that runs the test suite on the newest Node release with --throw-deprecation, then reports each deprecation with the package that triggered it. Most weeks the list is unchanged and the run opens nothing.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

A deprecation warning from inside a dependency invites two bad answers: ignore it, or silence every warning. Finding the right one takes a reproduction that actually triggers the code path, here a request through a running proxy, and a comparison of alternatives under the same conditions. The agent builds that in its sandbox, where it can start servers on local ports and swap one library for another without disturbing a working checkout, and the stack traces and outputs are kept in the session for the reviewer.

It also brings back the fact that settles the choice. Whether a replacement is acceptable depends on details such as its minimum Node version and whether it handles the options you pass. Those are read from the package's own metadata and tested with your configuration, and the pull request states them, so the decision is yours to make with the constraints in view.

Frequently asked questions

Is the warning harmful?

Not today. util._extend still works on Node 22 and the proxy behaves as before. It matters in two cases: when a process runs with --throw-deprecation, where the warning becomes an exception, and when a future Node release removes the function.

Why does updating http-proxy not help?

Because there is nothing newer to update to. The latest published http-proxy is 1.18.1 and it still contains the call. The warning ends only when the code that runs is a different package or a parent package stops depending on it.

I do not use http-proxy directly. Where is it coming from?

Run npm ls http-proxy. In front-end projects it usually arrives through http-proxy-middleware, which dev servers use for their proxy option. The remedy there is a newer release of the dev server or middleware, or an overrides entry in package.json, and the agent tests which of those removes it.

Can I hide just this one warning?

Yes. Start Node with --disable-warning=DEP0060, on the command line or through NODE_OPTIONS. It suppresses that code only and leaves other warnings visible. It is a reasonable stopgap for a service you start yourself.

Why did my smoke test not show the warning?

The call runs when a request is proxied, not when the module loads or the server starts listening, and Node prints a given deprecation once per process. A check has to send at least one request through the proxy to see it.

More jobs like this: Fix a bug from an alert

Keep reading