react / react/react-native

Blob constructor is not spec compliant

Open
#44,125 9 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs: Attention Needs: Triage :mag: Never gets stale
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Description

The constructor for React Native's Blob has a comment:

"Currently we only support creating Blobs from other Blobs."

BlobManager confirms this:

"Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported"

This API is not spec compliant, since this is what the Blob specification specifies:

(Constructed from) "An iterable object such as an Array, having ArrayBuffers, TypedArrays, DataViews, Blobs, strings, or a mix of any of such elements, that will be put inside the Blob. Strings should be well-formed Unicode, and lone surrogates are sanitized using the same algorithm as String.prototype.toWellFormed()."

Steps to reproduce
  1. Try to call:
new Blob(new Uint8Array([
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    21, 22, 23,
  ]);

See that RN doesn't support Blobs composed of anything but Blobs or strings.

React Native Version

0.73.6

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
N/A
Stacktrace or Logs
N/A
Reproducer

N/A

Screenshots and Videos

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading packages/react-native/Libraries/Blob/Blob.js and packages/react-native/Libraries/Blob/BlobManager.js, especially the constructor and the existing unsupported-input handling. Confirm the current behavior on Android and iOS, then verify that Blob construction accepts the iterable input types listed in the issue while preserving existing Blob and string support.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.