Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hamlim opened this issue Mar 4, 2024 · 0 comments · Fixed by #52
Closed

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

hamlim opened this issue Mar 4, 2024 · 0 comments · Fixed by #52
Labels
enhancement New feature or request

Comments

@hamlim
Copy link
Collaborator

hamlim commented Mar 4, 2024

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: gajus/global-agent#52, particularly this one: gajus/global-agent#52 (comment) 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: nodejs/node#43187

@hamlim hamlim added the enhancement New feature or request label Mar 4, 2024
ballercat pushed a commit that referenced this issue Mar 8, 2024
This change patches `undici` which is what `globalThis.fetch` uses in
modern Node versions (18+), allowing for native fetches to also be
routed through the proxy (`mockttp`) in Jambox!

Closes: #51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant