# Fix "[DEP0169] DeprecationWarning: url.parse() behavior is not standardized"

Yes. An agent traces the warning to the calls in your own code, replaces url.parse() with the WHATWG URL class, tests the edge cases and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-url-parse-deprecation-warning/nodejs/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent first finds out who is calling `url.parse()`, since the warning itself names no file. It runs the project's test command with `node --trace-deprecation`, which prints a stack under the warning. In a tunnel server like derhuerst/tcp-over-websockets that stack points at `server.js` line 20, inside `verifyClient`: `const target = url.parse(req.url).pathname.slice(1)`. The function reads the target host and port from the request path, so a client connecting to `/localhost:5000` asks for a tunnel to that address.

It then explains why the warning is new. `package.json` says `"node": ">=14"` and the test workflow runs Node 14, 16 and 18. Node 18 and Node 22 stay silent by default and print the warning only when the process is started with `--pending-deprecation`. On Node 24 it prints once per process with no flag. The agent runs `node test.js` under each Node version it can install and records which ones warn, which gives the pull request a one-line answer to why production logs changed after a base image update.

The replacement is the WHATWG `URL` class, and the detail that matters is the base. `req.url` is a path, not a full URL, and `new URL('/localhost:5000')` throws without a second argument. The agent writes `new URL(req.url, 'http://localhost').pathname.slice(1)` and then checks inputs where the two parsers disagree. A request path that starts with two slashes is one: the old parser keeps it as a path, the new one reads the first segment as a host. In this server both results are then refused by the `host:port` check that follows, and the agent adds a test for that request instead of assuming it. It also removes the `require('url')` line, because `.eslintrc.json` sets `no-unused-vars` to error and `npm run lint` would fail on the leftover.

Finally it accounts for the calls it did not change. The installed `ws` package, pulled in through `websocket-stream`, calls `url.parse()` in two of its own files. Node 24 does not print this warning for calls made from inside `node_modules`, so those stay quiet, and the agent says so in the description so nobody goes looking for a warning that will not appear.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Our Node.js process logs: [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. Remove the cause. Run the test command with node --trace-deprecation and quote the stack so we know which file and line called url.parse(). Find every call to url.parse, url.resolve and url.format with a legacy object in this repository's own code, excluding node_modules, and list them. Report which Node versions the project declares in package.json engines and CI, and on which of the Node versions you can install the warning prints with and without --pending-deprecation. Replace each call with the WHATWG URL class. Where the input is a request path or other relative reference, pass an explicit base and say which base you chose and why. For each replaced call, list inputs where the two parsers return different results (paths starting with //, percent-encoding, missing or invalid ports, credentials, IPv6 literals) and add a test for each one that can reach that code. Keep behaviour the same for valid input; where it changes for odd input, say so. Remove imports the change leaves unused and run the linter. Run the tests on the oldest Node version the project supports that you can install and on the newest, with warnings shown, and quote both outputs. List calls inside dependencies separately with the package and version, and do not edit them. Open a pull request.",
  "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, for this server, changes one line of `server.js`, deletes one `require`, and adds cases to `test.js`. The existing test starts an HTTP server on port 5000, the tunnel server on 8080 and a client on 5001, fetches through the tunnel and prints a success line. The new cases connect with paths the old test never sent. The description quotes the traced warning before the change and the clean output after it on the newest Node, and the same test passing on the oldest Node the agent could install.

It also carries a short table of inputs and what each parser returns for them. That table is the review. A reviewer of a tunnel or proxy reads the row for a path beginning with `//` carefully, since that is where a parser swap could change which host the server connects to, and confirms the validation after the parse still rejects it. They also check the base URL is a constant and never taken from the `Host` header.

Two findings come back without a code change. The CI matrix lists Node versions that no longer show the warning, so the workflow would not have caught a regression; the agent proposes adding a current version. And the target parser splits on `:`, which cannot express an IPv6 literal. That limitation is the same before and after, so it is reported and left.

## Run it on every log alert for a Node deprecation warning

Deprecation warnings go to stderr once per process, so they sit in logs until someone searches for them. A log alert rule that matches `DeprecationWarning` can start the run. A Grafana contact point can send a custom `Authorization` header, so it can post directly to a Rush `webhook` trigger with the trigger's secret as the bearer token; the alert's body, up to 64 KB, is placed after the automation's saved prompt as event text. For a log system that cannot set that header, a small handler on your server receives its webhook and forwards it.

The alert names the service and the DEP code, not the file, which is why the prompt has the agent trace the warning itself. Set the automation's max runs per hour low. Every instance of a service prints the warning at start, and one run per repository is enough.

## Why run it on Rush?

The warning cannot be reproduced on whatever Node a laptop happens to have, since it depends on the major version and on a flag. The run installs the versions it needs side by side in its own sandbox and executes the same test under each, so the pull request states which versions warn as an observation, with the command output kept in the transcript.

The parser swap is also a small change with a security angle. `url.parse()` and `URL` disagree on unusual input, and the code that calls them is often routing or validation. A run that builds the comparison table, writes the tests for the rows that differ and runs them leaves a reviewer checking evidence instead of reasoning about two URL parsers from memory. Several services warning after the same image update each get their own run at the same time.

## Frequently asked questions

### Why did this warning start appearing without a code change?

Because the Node version changed. Node 18 and Node 22 print DEP0169 only under `--pending-deprecation`, and Node 24 prints it by default for calls in your own code. Moving a base image or a CI runner to a newer major version is enough to surface it.

### The warning comes from a dependency. Can it be fixed in my repository?

Not by editing the dependency. Node 24 does not print the warning for calls made from files under `node_modules`, so a visible DEP0169 usually means your own code. When a trace does point into a package, the agent looks for a release that uses `URL` and proposes the upgrade.

### Can I just silence it?

`--no-deprecation` or `NODE_OPTIONS` will hide it, along with every other deprecation warning the process would print. That trades one log line for missing the next removal notice. The agent removes the call, which is a smaller change than it sounds in most code.

### What base URL should new URL() get for a request path?

A fixed placeholder such as `http://localhost` when only the path and query are read afterwards. Build it from the `Host` header only when the code needs the real origin, and validate that header first, since the client controls it. The agent states which case applies at each call site.

## More Node.js jobs

- [Fix Vulnerable Dependencies in a Node.js App](https://getrush.ai/run/fix-vulnerable-dependencies/nodejs/)
- [Migrate a Node.js App from CommonJS to ESM](https://getrush.ai/run/migrate-commonjs-to-esm/nodejs/)
- [Migrate Cypress Tests to Playwright in a Node.js App](https://getrush.ai/run/migrate-cypress-to-playwright/nodejs/)

## More jobs like this: Fix a bug from an alert

- [Fix "Retry.__init__() got an unexpected keyword argument 'method_whitelist'"](https://getrush.ai/run/fix-urllib3-method-whitelist-error/urllib3/)
- [Fix "[DEP0060] DeprecationWarning: The util._extend API is deprecated" From http-proxy on Node 22](https://getrush.ai/run/fix-util-extend-deprecation-warning/http-proxy/)
- [Fix a Failed Vercel Deployment of an Astro Site](https://getrush.ai/run/fix-vercel-build-failures/astro/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
