chore(cli)!: replace node-fetch with undici - #306
Conversation
so0k
left a comment
There was a problem hiding this comment.
LGTM, noticed this is flagged as breaking change (due to Node version bump?)
|
Shouldn't be a breaking change. The |
I had marked as a breaking change due to the part in the PR description: I don't really see that as a problem as I expect the next release to come with a major version bump regardless. |
|
OK Jon, I've restored the breaking change marker in the PR title. |
|
LGTM, added docs PR - see preview environment - merging now Docs: open-constructs/cdk-terrain-docs#28 — bumps the Node.js prerequisite to 22.19+ in the install and deploy-applications tutorials. |
1ae4192 to
a4b3db7
Compare
|
Non-blocking follow-up: undici v8.7.0 is now available and retains the same Node.js >=22.19.0 requirement as the v8.6.0 version introduced here. After this transport migration merges, a small dependency-only update to v8.7.0 would be straightforward. |
🤖 Release PR — merge to cut a new release. Kept open and rebased as commits land on `main`. --- <details><summary>0.24.0</summary> ## [0.24.0](v0.23.4...v0.24.0) (2026-08-06) ### ⚠ BREAKING CHANGES * **lib:** validate Terraform function versions by default ([#362](#362)) * **deps:** Require Node 22 minimum ([#345](#345)) * **lib:** preserve symlinks in TerraformAsset walkers ([#321](#321)) * **cli:** replace node-fetch with undici ([#306](#306)) ### Features * **lib:** canonical asset hashes behind the canonicalAssetHashes feature flag ([#323](#323)) ([76dd4ff](76dd4ff)) * **lib:** validate Terraform function versions by default ([#362](#362)) ([4ac0736](4ac0736)) * support newer provider plugin-protocol features via targetVersions (RFC-04) ([#296](#296)) ([90322f9](90322f9)) ### Bug Fixes * **cli:** don't downgrade prebuilt providers on a transient registry failure ([#298](#298)) ([a960c5c](a960c5c)) * **cli:** include dev dependencies in npm version lookup ([#280](#280)) ([955204a](955204a)) * **docs:** fix stale constructs pin breaking with()/IMixin docs ([#305](#305)) ([605cf63](605cf63)) * **gha:** Allow pnpm to update the lockfile after package updates ([#318](#318)) ([a899b7c](a899b7c)) * **gha:** Fix pnpm upgrade workflow ([#335](#335)) ([e1a69fc](e1a69fc)) * **gha:** flip merged release PR label to autorelease: tagged ([#302](#302)) ([8d64f6c](8d64f6c)) * **gha:** mint the Go-publish token from the CDKTN Maintainers app ([#369](#369)) ([71921ce](71921ce)) * **gha:** mint the Go-publish token from the open-constructs-cdktn App ([#368](#368)) ([179f10c](179f10c)) * **gha:** pass the Go-publish App token as x-access-token userinfo ([#370](#370)) ([4e3ff19](4e3ff19)) * **lib:** Disallow constructs 10.8 until support can be added ([#363](#363)) ([8bdae0d](8bdae0d)) * **lib:** preserve symlinks in TerraformAsset walkers ([#321](#321)) ([6360e20](6360e20)) * typo in `moveFromId` JSDoc ([#355](#355)) ([e1cf8ce](e1cf8ce)) ### Miscellaneous Chores * **cli:** replace Ink + React with smaller-tree CLI libraries ([#264](#264)) ([a6aff7e](a6aff7e)) * **cli:** replace node-fetch with undici ([#306](#306)) ([1317141](1317141)) * **deps:** bump glob to 13.0.6 ([#307](#307)) ([47ee2bb](47ee2bb)) * **deps:** bump the github-actions-backward-compatible group with 2 updates ([#295](#295)) ([eab2a01](eab2a01)) * **deps:** replace lerna with nx ([#315](#315)) ([94999fc](94999fc)) * **deps:** Require Node 22 minimum ([#345](#345)) ([2bf315d](2bf315d)) * **deps:** update ci-info to 4.4.0 across all packages ([#329](#329)) ([557a163](557a163)) * **deps:** update fs-extra to 11.3.6 across all packages ([#328](#328)) ([95753a9](95753a9)) * **deps:** update minimatch to 10.2.5 ([#330](#330)) ([d1c1c53](d1c1c53)) * **deps:** Update sscaff to v2.0.388 ([#331](#331)) ([38ea0ba](38ea0ba)) * **deps:** Update zod to v4.4.3 ([#332](#332)) ([c10ee35](c10ee35)) * **deps:** Upgrade dependencies ([#347](#347)) ([45d3a66](45d3a66)) * remove cdktf from tests ([#277](#277)) ([dc9a8e9](dc9a8e9)) * ship Terraform 1.15.8 in the jsii-terraform image ([#367](#367)) ([deaa9b0](deaa9b0)) * Upgrade dependencies for lib ([#348](#348)) ([d616f17](d616f17)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: open-constructs-cdktn[bot] <291052431+open-constructs-cdktn[bot]@users.noreply.github.com>
|
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
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