Skip to content

Fix undici usage on node 26. - #53

Draft
davidlehn wants to merge 2 commits into
remove-cjs-supportfrom
fix-undici-usage
Draft

Fix undici usage on node 26.#53
davidlehn wants to merge 2 commits into
remove-cjs-supportfrom
fix-undici-usage

Conversation

@davidlehn

Copy link
Copy Markdown
Member

This was purely done via asking claude to fix the undici issue on node 26. It had long winded text about issue and did matrix tests of undici and node versions and came up with this fix. Claims update to undici 8 will work too. Needs review.

davidlehn and others added 2 commits July 24, 2026 23:12
A dispatcher is only usable by the undici instance that created it. Node
bundles its own undici (node 22: 6.x, node 24: 7.x, node 26: 8.x) and the
dispatcher handler interface changed between majors, so passing an
installed-undici dispatcher to `globalThis.fetch` fails. undici 7 still
accepted 6.x style handlers, but undici 8 does not, breaking node 26 with
`UND_ERR_INVALID_ARG` ("invalid onError method").

Call undici's own `fetch` instead so the dispatcher and the `fetch` using
it always come from the same module. This works on any node version and
with any installed undici, rather than pinning undici to whichever node
happens to match.

undici's `fetch` does not accept the global `Request` that `ky` passes,
so unpack it into a url and init pair.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant