chore(cli)!: replace node-fetch with undici#306
Open
X-Guardian wants to merge 2 commits into
Open
Conversation
jsteinich
approved these changes
Jul 7, 2026
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.
Description
@cdktn/cli-coredepended on the legacynode-fetchpackage and its proxy helperhttps-proxy-agent. This PR replaces that with theundicipackage — a modern, actively maintainedfetchimplementation with first-class proxy and mocking support — and removesnode-fetch,@types/node-fetch, andhttps-proxy-agent.Changes
Fetch →
undici. All three files nowimport { fetch } from "undici"instead ofnode-fetch. We use undici's exportedfetchrather than the globalfetchdeliberately: it keeps the whole HTTP stack — code and test mocks — on a single undici instance.globalThis.fetchuses Node's internal undici, which is a different instance from theundicinpm package, so mocking has to target the same one the code uses.Proxy → undici
ProxyAgentvia thedispatcheroption.node-fetch'sagentoption (a Nodehttp.Agentfromhttps-proxy-agent) is replaced by an undiciProxyAgentbuilt from the samehttp_proxy/HTTP_PROXYenv vars and passed as the requestdispatcher.Proxy support extended to
package-manager.ts. Previously onlyregistry-api.tsandprebuilt-providers.tshonoured a proxy;package-manager.ts(the PyPI / NuGet / Maven Central / GitHub / npm availability probes) never did. It now uses the samedispatcher, so all registry traffic respects a corporate proxy consistently.undici@8.6.0dependency + Node floor.undiciis added to@cdktn/cli-core. undici 8 requires Node ≥ 22.19.0, so both published packages (@cdktn/cli-coreandcdktn-cli) declare"engines": { "node": ">=22.19.0" }— surfacing a clear install-time warning on older Node instead of an opaque runtime failure.Tests → undici
MockAgent.prebuilt-providers.test.tsandpackage-manager.test.tsexercise undici'sfetch, so theirnockscopes are replaced with an undiciMockAgentwired viasetGlobalDispatcher.Checklist