nodejs / nodejs/node

Add a method to unset encoding on a stream

Open
#51,083 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request never-stale stream
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?

Currently it is impossible to unset the encoding of a ReadableStream once setEncoding is called. This makes it impossible to obtain Buffers from the stream again after temporarily switching to an encoding. I know that this could be worked around but there is a much better fix which is backward compatible.

In my opinion, this is a major parity issue in the API.

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

I propose adding a new special buffer encoding which will unset/reset the encoding so that the stream returns a buffer again.

What alternatives have you considered?

I originally thought binary encoding was supposed to do this but then I found out that it's just an alias for latin1! Any alternatives outside of the standard library will always be inferior to a new option which would be available to everyone using new versions with this proposed fix 😄

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 locating the ReadableStream setEncoding implementation and its existing encoding-related tests. Trace how encoding changes affect returned chunks, then define completion as supporting the proposed special buffer encoding so the stream returns Buffers again after an encoding was set.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.