nodejs / nodejs/node

Accept `Blob`s anywhere where a `Buffer` is currently accepted for writing

Open
#53,090 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

buffer feature request web streams
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

Because Buffers aren't immutable, any time a Buffer is passed to something which will perform an asynchronous write, there is a concurrency hazard where the buffer could conceivably get modified before it gets a chance to be written. This can lead to bugs which are hard to track down. (I speak from experience.)

What is the feature you are proposing to solve the problem?

Anywhere where Buffer is currently accepted for a write operation, e.g. and perhaps most notably stream.Writable.write() and stream.Writable.end(), also make it acceptable to pass a Blob. Blobs are always immutable.

What alternatives have you considered?

Just keep using Buffers, mostly keep my fingers crossed, and sometimes make copies of Buffers as a safeguard.

(Note: It also makes sense to have a way to optionally have Blobs returned from readable streams, but I figure that'd be a different feature request.)

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 with the Node.js stream.Writable.write() and stream.Writable.end() entry points, then inspect other APIs that currently accept Buffer for asynchronous writes. Determine the required Blob behavior and update the relevant implementation, tests, and API documentation so Blob inputs are accepted consistently without changing readable-stream return behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.