Skip to content

fix(api): correct ReadableStreamDefaultController.desiredSize value type#44536

Open
gords2 wants to merge 1 commit into
mdn:mainfrom
gords2:fix/desiredsize-value-type
Open

fix(api): correct ReadableStreamDefaultController.desiredSize value type#44536
gords2 wants to merge 1 commit into
mdn:mainfrom
gords2:fix/desiredsize-value-type

Conversation

@gords2

@gords2 gords2 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #44486

The Value section claimed desiredSize is "An integer", which is inaccurate on two counts (both raised in the issue):

  • It can be nullReadableStreamDefaultController.desiredSize returns null when the stream has errored (and 0 when it is closed), per the spec algorithm.
  • It is not necessarily an integer — the default controller computes desiredSize from the queuing strategy's size() results. A custom queuing strategy can return non-integer sizes, so desiredSize can be non-integer too.

Updated the description to state the type as "A number, or null" and to explain the negative / non-integer / null / closed cases.

desiredSize is not always an integer: with a custom queuing strategy the
chunk sizes (and therefore desiredSize) can be non-integer. It is also
null when the stream has errored and 0 when it is closed.
@gords2 gords2 requested a review from a team as a code owner June 21, 2026 18:49
@gords2 gords2 requested review from dipikabh and removed request for a team June 21, 2026 18:49
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@dipikabh dipikabh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for sending a PR, @gords2!

Comment on lines +17 to +22
A number, or `null`.

This can be negative if the queue is over-full, and it is not necessarily an
integer: when a custom queuing strategy is used, chunk sizes — and therefore
`desiredSize` — can be non-integer values. The value is `null` if the stream has
errored, and `0` if it is closed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"it is not necessarily an integer" - Instead of saying what it's not, we can be direct and mention the possible value types.

In fact, we have a few other desiredSize property pages. The ReadableByteStreamController.desiredSize is the closest to what we want to say here.

For consistency, could you update this "Value" section to match what we have on that page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReadableStream desiredSize is not always an integer

3 participants