Repository navigation
chore(deps): replace isomorphic-fetch with native fetch - #1208
Merged
Merged
Conversation
Open
4 tasks
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
isomorphic-fetchfrom@lhci/utilsand@lhci/cli,@types/isomorphic-fetchfrom the root devDependencies, and the old Parcel-era"alias": {"isomorphic-fetch": "clsx"}hack from@lhci/serverand@lhci/viewer, in favor of the globalfetchbuilt into Node (engines.nodeis>=22.19.0) and browsers.@lhci/utils&@lhci/serverapi-client.js/psi-client.jsdefault to the globalfetch(via a small wrapper so it's always invoked unbound and resolved at call time, as browsers andjsdomtests require), and use the globalbtoaandURLdirectly. Thefetchoption types are nowtypeof fetch.use-api-data.jsxdrops the now-redundantURL: window.URLandfetch: window.fetch.bind(window)options when constructingApiClient.whatwg-fetchpolyfill (verifiedisomorphic-fetch/whatwg-fetchno longer appear indist/).@lhci/clisrc/fetch.js(proxy support)The global
fetchignoresoptions.agent, andNODE_USE_ENV_PROXYneeds Node 22.21+ (above our>=22.19.0minimum), soproxy-agentis kept:ProxyAgent#getProxyForUrlresolves a proxy for the target URL (supporting upper/lowercasehttp_proxy/https_proxy/all_proxywhile keepingNO_PROXYmatches on nativefetch) or an explicitoptions.agentis passed, the request goes through a smallnode:http/node:httpsimplementation using a sharedProxyAgent(or the provided agent) and returns a realResponse. It normalizes method/headers/body vianew Request(...), sets defaultuser-agent/accept/accept-encodingheaders, follows redirects likefetch(follow/manual/error, max 20, 303 / POST-on-301/302 become GET, credentials andhostdropped cross-origin), decompresses gzip/deflate (including raw deflate)/br, and setsresponse.urlandresponse.redirected.fetchdirectly.packages/cli/test/fetch.test.jscovers the global-fetch path (includingNO_PROXY), the agent path (status/headers/body, default headers, redirects + cross-origin header stripping, compression including raw deflate and empty encoded bodies, 204, errors), and end-to-endhttp_proxy/NO_PROXYrouting.Tests / lint
fetchinstead of requiringisomorphic-fetch..eslintrc.jsdeclares thebtoa/fetch/Headers/Request/Responseglobals (eslint 8'snodeenv predates them).yarn.lock: only theisomorphic-fetch,whatwg-fetchand@types/isomorphic-fetchentries are removed (node-fetchis still required transitively).