Skip to content

feat(fetch): add result-based SafeFetch wrapper [Codex] - #367

Draft
jderochervlk wants to merge 3 commits into
mainfrom
feat/safe-fetch
Draft

jderochervlk wants to merge 3 commits into
mainfrom
feat/safe-fetch

Conversation

@jderochervlk

@jderochervlk jderochervlk commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #363

The raw Fetch and Response bindings expose several separate failure channels: request rejection, fulfilled non-OK responses, and body-reader rejection. Applications currently have to reconstruct that distinction while also preserving response metadata and original rejection values.

This adds an opt-in WebAPI.SafeFetch module within the existing Fetch feature. Its request helpers convert synchronous throws and rejected promises into FetchRejected, classify non-OK responses as ResponseNotOk, and retain the native response. Its six body readers share one internal adapter that returns the body with the consumed response or a typed read error with the original cause.

The public interface keeps the internal reader helper private, leaves JSON domain decoding to applications, and adds no production dependency. A small internal adapter keeps calls to the raw Fetch bindings distinct from the public wrapper names without changing the raw binding definitions.

Runtime coverage exercises successful requests and init forwarding, non-OK responses, promise rejection, synchronous failure, valid and malformed bodies, already-consumed bodies, readable error bodies, and every exposed reader. The generated API reference documents every public type and function, while the Fetch guide explains the failure stages, raw-response classification, error-body reading, body consumption, and JSON validation boundary.

@jderochervlk

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T13:34:42.621166Z 34977cc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread src/fetch/Fetch.res Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 34977ccebd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
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.

Add an opt-in SafeFetch wrapper for result-based Fetch workflows

1 participant