Skip to content

Fixes #10610 Deprecation Warning : url.parse() is deprecated in Node.…#10625

Merged
jasonsaayman merged 4 commits into
axios:v1.xfrom
Kilros0817:my-fix-branch
Apr 2, 2026
Merged

Fixes #10610 Deprecation Warning : url.parse() is deprecated in Node.…#10625
jasonsaayman merged 4 commits into
axios:v1.xfrom
Kilros0817:my-fix-branch

Conversation

@Kilros0817
Copy link
Copy Markdown
Contributor

@Kilros0817 Kilros0817 commented Apr 1, 2026

Fix DEP0169 warning in Node.js 18+ by prioritizing fetch adapter

This pull request fixes the DEP0169 warning caused by follow-redirects using the legacy url.format() API internally when building redirect URLs. Axios uses follow-redirects via the HTTP adapter, which triggers this warning in Node.js 18+.

Solution:

In Node.js 18+ (where platform.isNode is true and global.fetch exists), the adapter priority is updated to ['xhr', 'fetch', 'http'].
This ensures the native fetch adapter is used instead of the HTTP adapter. Since fetch does not rely on follow-redirects, the warning is eliminated.
On older Node.js versions (<18) or in browsers, the original adapter order is preserved, so functionality remains unchanged and backward compatibility is maintained.


Summary by cubic

Fixes #10610 by replacing deprecated url.parse with URL/URLSearchParams in examples, sandbox, and tests. Removes Node v22 deprecation warnings and includes a tiny cleanup in lib/adapters/http.js (no behavior change).

Description

  • Replaced url.parse with URL/URLSearchParams in examples/abort-controller/server.js, sandbox/server.js, and tests.
  • Added 400 handling for invalid URLs in examples/abort-controller/server.js.
  • Minor cleanup in lib/adapters/http.js (formatting only).
  • Reasoning: Use WHATWG URL API and silence Node v22 deprecation warnings.

Docs

  • No API changes. Update any docs/snippets that use url.parse to URL/URLSearchParams.

Testing

  • Updated tests/unit/adapters/http.test.js to use URL; behavior unchanged.
  • No new tests needed. Run CI on Node v22 to confirm no deprecation warnings.

Written for commit 6da3bf4. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Confidence score: 3/5

  • There is a concrete regression risk in lib/defaults/index.js: prioritizing fetch as the Node default adapter may bypass http-adapter-specific Node options and change runtime behavior for existing users.
  • Given the issue severity (7/10) and high confidence (8/10), this is more than a minor housekeeping concern and introduces some meaningful merge risk.
  • Pay close attention to lib/defaults/index.js - adapter selection order may break Node configurations that rely on http adapter options.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/defaults/index.js">

<violation number="1" location="lib/defaults/index.js:43">
P1: Changing Node default adapter priority to fetch can cause functional regressions by bypassing http-adapter-specific Node options.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread lib/defaults/index.js Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="sandbox/server.js">

<violation number="1" location="sandbox/server.js:79">
P1: `pathname` is declared as `const` but reassigned for `/`, causing a runtime TypeError on root requests.</violation>
</file>

<file name="lib/defaults/index.js">

<violation number="1">
P1: Default adapter priority regression in Node: `http` is selected before `fetch`, likely reintroducing the DEP0169 warning path via `follow-redirects`.</violation>
</file>

<file name="examples/abort-controller/server.js">

<violation number="1" location="examples/abort-controller/server.js:2">
P2: Uncaught `URL` parsing error on untrusted `req.url` can crash the request handler/process.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread sandbox/server.js
Comment thread examples/abort-controller/server.js Outdated
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

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

thanks for the contribution 🔥

@jasonsaayman jasonsaayman merged commit 947f709 into axios:v1.x Apr 2, 2026
20 checks passed
@Kilros0817 Kilros0817 deleted the my-fix-branch branch April 2, 2026 11:03
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.

Deprecation Warning: url.parse() is deprecated in Node.js v22 (via follow-redirects)

3 participants