Skip to content

Use global fetch instead of cross-fetch to eliminate node-fetch url.parse deprecation#8822

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-deprecation-warning-url-parse
Draft

Use global fetch instead of cross-fetch to eliminate node-fetch url.parse deprecation#8822
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-deprecation-warning-url-parse

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Users see [DEP0169] DeprecationWarning: url.parse() in the VS Code Window output. The warning originates from this extension: importing fetch from cross-fetch pulls in node-fetch@2.6.7 on the Node/desktop target, which calls the deprecated Url.parse() on every request.

The main REST path (@octokit/rest@22) already uses globalThis.fetch, so the remaining call sites were the only ones still routing through node-fetch: the Apollo/GraphQL link, avatar image fetches, the Copilot API, and enterprise-server detection.

Changes

  • Drop cross-fetch imports in credentials.ts, githubServer.ts, common/uri.ts, and copilotApi.ts so these use the environment's global fetch (Node 20+ / browser), which is WHATWG-URL based and never calls url.parse().
  • Add dom to lib in the Node tsconfig.json. DOM types (Element, BlobPart, DOM fetch/Response) were previously supplied transitively by cross-fetch's type defs (/// <reference lib="dom" />); this makes them explicit, matching the browser and test tsconfigs.
-import fetch from 'cross-fetch';
 import * as vscode from 'vscode';

Notes

  • The node-fetch/url.parse() code is no longer present in the bundled output.
  • cross-fetch remains as a dependency and its webworker webpack alias is left in place (now inert) to keep the change minimal and avoid lockfile churn; it can be removed in a follow-up.

Copilot AI linked an issue Jul 1, 2026 that may be closed by this pull request
… deprecation

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix deprecation warning for url.parse Use global fetch instead of cross-fetch to eliminate node-fetch url.parse deprecation Jul 1, 2026
Copilot AI requested a review from alexr00 July 1, 2026 15:03
@alexr00

alexr00 commented Jul 2, 2026

Copy link
Copy Markdown
Member

@copilot, will global fetch work in the browser?

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot, will global fetch work in the browser?

Yes. In the browser/web-worker extension host, fetch is a native global (self.fetch), so it's available without any import. In fact cross-fetch's own browser build (browser-ponyfill.js) just re-exports that same global self.fetch, so switching to the global is behaviorally identical there — the only real change is on the Node target, where we drop node-fetch (and its deprecated url.parse()). The webworker bundle compiles and builds successfully.

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.

GitHub Pull Requests Deprecation Report

2 participants