ballercat / jambox

CLI tool for recording and playing back networks requests for node & Frontend Apps.
MIT License
11 stars 2 forks source link

Add support / workaround for builtin `fetch` (undici) #51

Closed hamlim closed 7 months ago

hamlim commented 7 months ago

The undici based fetch (exposed as globalThis.fetch in Node 18 and up) doesn't work out of the box with global-agent which we use to proxy the requests through Jambox.

There are some workarounds mentioned on this issue: https://github.com/gajus/global-agent/issues/52, particularly this one: https://github.com/gajus/global-agent/issues/52#issuecomment-1134525621 which seems like a good thing to consider doing inside Jambox to normalize the fetch handling/proxying.

Thought about applying this in our application code but other apps probably want a similar fix as well.

There is some traction on an issue for the Node steering committee to standardize this which should make this code obsolete, but who knows when that will land, see: https://github.com/nodejs/node/issues/43187