FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Replace deprecated url.parse() with WHATWG URL (DEP0169) by kyungseopk1m · Pull Request #3124 · firebase/firebase-admin-node · GitHub

fix: Replace deprecated url.parse() with WHATWG URL (DEP0169) - #3124

Merged
lahirumaramba merged 1 commit into
firebase:v14from
kyungseopk1m:fix/url-parse-deprecation
May 27, 2026
Merged

fix: Replace deprecated url.parse() with WHATWG URL (DEP0169)#3124
lahirumaramba merged 1 commit into
firebase:v14from
kyungseopk1m:fix/url-parse-deprecation

Conversation

Copy link
Copy Markdown
Contributor

Closes #3118.

url.parse() is deprecated (DEP0169) and emits warnings on every cold start in serverless runtimes. This swaps the two call sites in BaseRequestConfigImpl.buildUrl() for the WHATWG URL constructor, matching the pattern @lahirumaramba used for validator.isURL() in #3061.

Changes

  • BaseRequestConfigImpl.buildUrl() returns URL instead of url.UrlWithStringQuery. The method is protected and only used by two subclasses inside the same file, so this is not a public surface change.
  • Both branches of buildUrl() now reuse a single new URL(fullUrl) instance instead of allocating one and re-parsing it via url.parse().
  • parsed.path is replaced with ${parsed.pathname}${parsed.search} so the request path on the wire stays byte-for-byte identical.
  • parsed.port is now string (always) rather than string | null. The existing if (!port) falsy check still picks up the empty case.

Behavior

For valid inputs the request URL is byte-for-byte identical. For malformed inputs the WHATWG parser is stricter than url.parse(): depending on the input shape it may either canonicalize the input differently (urlWithProtocol() always prepends https://, so e.g. //evil.com becomes https://evil.com/) or throw a TypeError. SDK-internal callers normalize their URLs before invoking, so well-formed usage is unaffected.

Out of scope

The transitive callers listed in #3118 (http-proxy-agent, teeny-request/agent-base, faye-websocket, @firebase/database-compat) live in separate repositories and need to be addressed there.

Verification

  • npx tsc --noEmit -p . — clean
  • npx eslint src/utils/api-request.ts — 0 warnings
  • npx mocha test/unit/utils/api-request.spec.ts --require ts-node/register — 199 passing
  • npx mocha test/unit/index.spec.ts --require ts-node/register — 6231 passing

No spec changes: existing api-request tests already cover explicit non-default ports (mockHost:8080), POST with entity body, GET path matching, and nock interceptor URL parsing — all of which exercise the changed code paths.

gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request refactors src/utils/api-request.ts to replace the deprecated Node.js url module with the native URL API. Key changes include updating the buildUrl method to return a URL instance and modifying property accesses to use pathname and search instead of the non-existent path property. I have no feedback to provide.

lahirumaramba changed the base branch from main to v14 May 27, 2026 18:27
url.parse() is deprecated (DEP0169) and emits warnings on every cold
start in serverless runtimes. Migrate the two call sites in
BaseRequestConfigImpl.buildUrl() to the WHATWG URL constructor,
matching the pattern from firebase#3061.

The protected buildUrl() return type changes from url.UrlWithStringQuery
to URL. Both call sites are inside the same file. parsed.path is
replaced with ${parsed.pathname}${parsed.search} so the request path on
the wire stays byte-for-byte identical, and parsed.port is now string
(always); the existing if (!port) falsy check still catches the empty
case.

Fixes firebase#3118.
lahirumaramba force-pushed the fix/url-parse-deprecation branch from e878ef8 to 8344df7 Compare May 27, 2026 19:42
lahirumaramba changed the title fix(api-request): replace deprecated url.parse() with WHATWG URL (DEP0169) fix: Replace deprecated url.parse() with WHATWG URL (DEP0169) May 27, 2026

lahirumaramba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for your contribution! LGTM!

lahirumaramba merged commit c9db870 into firebase:v14 May 27, 2026
11 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate url.parse() → WHATWG URL API to eliminate DEP0169 deprecation warnings in serverless logs

2 participants


Back | FazBrowse Home | New Git URL