Skip to content

Make Response.arrayBuffer() always resolve with a ArrayBuffer#816

Merged
JakeChampion merged 2 commits intomasterfrom
arraybuffer
Jul 31, 2020
Merged

Make Response.arrayBuffer() always resolve with a ArrayBuffer#816
JakeChampion merged 2 commits intomasterfrom
arraybuffer

Conversation

@JakeChampion
Copy link
Copy Markdown
Owner

Fixes #801

@JakeChampion JakeChampion merged commit 37b55c2 into master Jul 31, 2020
@JakeChampion JakeChampion deleted the arraybuffer branch July 31, 2020 00:45
Copy link
Copy Markdown

@freund17 freund17 left a comment

Choose a reason for hiding this comment

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

I'm not familiar with the code base, but maybe it is a better idea to convert the view to a buffer, where it is set instead of where it is used.

Because there might be other places where code is expecting an ArrayBuffer instead of a view.

this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
consumed(this)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consumed returns either undefined or a rejected Promise.

The previous code returned the rejected Promise.
This changes the original behaviour.
Was that intended?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Response.arrayBuffer() may resolve to ArrayBufferView

3 participants