Skip to content

fix: Use arrayBuffer instead of blob when memoizing responses#442

Merged
angeloashmore merged 1 commit into
prismicio:masterfrom
anakinj:replace-blob-with-arraybuffer
Apr 2, 2026
Merged

fix: Use arrayBuffer instead of blob when memoizing responses#442
angeloashmore merged 1 commit into
prismicio:masterfrom
anakinj:replace-blob-with-arraybuffer

Conversation

@anakinj

@anakinj anakinj commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Resolves: React native compatibility

Description

The react native blob implementation is apparently a bit lacking. The memoization introduced in #437 is using some functions that do not exist in the react native blob.

Resulting in the following errors:

TypeError: _blob.text is not a function (it is undefined)

This change uses the response.arrayBuffer() combined with TextEncoder.

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1


Note

Medium Risk
Changes the core request() deduplication/memoization path to buffer bodies as ArrayBuffer, which could affect response decoding and memory usage across all callers. Risk is moderate because it touches shared HTTP plumbing but is a localized behavioral swap.

Overview
Fixes response memoization to be React Native compatible by buffering deduplicated responses using response.arrayBuffer() instead of response.blob().

memoizeResponse() now reconstructs text()/json() via TextDecoder, exposes arrayBuffer(), and recreates blob() from the buffered bytes; WriteClient.fetchForeignAsset() is updated to build File objects from an ArrayBuffer rather than a Blob.

Written by Cursor Bugbot for commit 71c6c7e. This will update automatically on new commits. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

@lihbr lihbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you so much for taking the time to open a PR! 💙

@angeloashmore angeloashmore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me too! Thanks for the fix. 🙂

@angeloashmore
angeloashmore merged commit bda71f4 into prismicio:master Apr 2, 2026
1 of 2 checks passed
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.

3 participants