Skip to content

fix: #83183 Replace deprecated url.parse() with WHATWG URL API#87307

Closed
smuk3c wants to merge 1 commit into
vercel:canaryfrom
smuk3c:fix/dep0169-url-parse
Closed

fix: #83183 Replace deprecated url.parse() with WHATWG URL API#87307
smuk3c wants to merge 1 commit into
vercel:canaryfrom
smuk3c:fix/dep0169-url-parse

Conversation

@smuk3c

@smuk3c smuk3c commented Dec 18, 2025

Copy link
Copy Markdown

Summary

Fixes #83183

Replace Node.js deprecated url.parse() and url.format() with WHATWG URL API to resolve DEP0169 warnings in Node.js 24+.

Changes

  • Enhanced parseReqUrl() in src/lib/url.ts to match url.parse() behavior
  • Replaced url.parse() with parseReqUrl() in core server files
  • Replaced url.format() with formatUrl() from shared utils
  • Updated test files to use direct WHATWG URL pattern
  • Added ESLint rule to prevent future usage of deprecated APIs

Why WHATWG URL?

  • url.parse() is deprecated since Node.js 11 (DEP0169)
  • WHATWG URL follows browser standard - consistent, predictable parsing
  • Stricter validation - throws on malformed URLs instead of guessing
  • No backwards compatibility needed (Next.js requires Node.js >=20.9.0)

Test Plan

  • pnpm build passes
  • pnpm typescript passes
  • pnpm test-dev test/integration/i18n-support-fallback-rewrite/ passes
  • pnpm test-dev test/integration/i18n-support-fallback-rewrite-legacy/ passes

@nextjs-bot nextjs-bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. tests type: next labels Dec 18, 2025
@nextjs-bot

nextjs-bot commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

Allow CI Workflow Run

  • approve CI run for commit: 26a22fa

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@smuk3c smuk3c force-pushed the fix/dep0169-url-parse branch 3 times, most recently from 1471bb1 to d3b9ddb Compare December 19, 2025 09:25
Replace Node.js deprecated url.parse() and url.format() with WHATWG URL API
to resolve DEP0169 warnings in Node.js 24+.

Changes:
- Enhanced parseReqUrl() in src/lib/url.ts to match url.parse() behavior
- Replaced url.parse() with parseReqUrl() in core server files
- Replaced url.format() with formatUrl() from shared utils
- Updated test files to use direct WHATWG URL pattern
- Added ESLint rule to prevent future usage of deprecated APIs
@smuk3c smuk3c force-pushed the fix/dep0169-url-parse branch from d3b9ddb to 26a22fa Compare December 19, 2025 14:35
@Jainil8923

Copy link
Copy Markdown

This PR fixes a production-blocking issue for us; would appreciate it being prioritized when possible.

mattc0llier added a commit to mattc0llier/node24-parse.url-repro that referenced this pull request Jan 13, 2026
This repository provides a minimal reproduction case for the DEP0169
deprecation warning that occurs in Next.js custom servers when running
on Node.js 24+.

The custom server uses the deprecated url.parse() method which triggers
security-related deprecation warnings on every HTTP request. This
reproduction helps verify the fix proposed in Next.js PR #87307.

Key features:
- Custom Next.js server that triggers url.parse() deprecation
- Example pages and API routes for testing
- Clear documentation on how to reproduce the warning
- Runs on Node 24+ with full deprecation trace

Related to: vercel/next.js#87307

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@eps1lon

eps1lon commented Jan 13, 2026

Copy link
Copy Markdown
Member

Appreciate the work. We also started this effort in parallel and landed it in #87257. If there are more instances of ur.parse were missed, please open an issue and ping me.

@eps1lon eps1lon closed this Jan 13, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked tests type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On the custom server, DeprecationWarning: url.parse() warning!

4 participants