Skip to content

Conversation

@andrewMacmurray
Copy link
Contributor

This re-implements the http client using node's builtin fetch api. We did this is for a few reasons:

  • The fetch api is a more modern standard for making http request in node
  • It opens the path for a cross platform http client that works in the browser and node (and potentially other JS runtimes like bun and deno)

Streaming requests and responses

The fetch api natively supports streaming request and response bodies, so it's pretty trivial to implement:

  • withStreamBody
  • expectStream

This means we can work with native gren/core/Streams when making http requests 🎉 .

Legacy streaming api

For now we've left the custom stream api so we don't have to make a breaking change, and we'll aim to remove this around the December release.

Follow up work

After this change when a stream error occurs during an http request an UnknownError will be returned.

Ideally we'd like to get a structured error for this case, but we haven't arrived yet at the right design for this (can we only include this error case for streaming requests so non streaming request don't need to handle it?).

@robinheghan robinheghan merged commit 0ec25f7 into gren-lang:main Aug 25, 2025
2 checks passed
@robinheghan
Copy link
Member

Thank you! 💯

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.

2 participants