Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/web/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,6 @@ function cloneBody (body) {
}
}

function throwIfAborted (state) {
if (state.aborted) {
throw new DOMException('The operation was aborted.', 'AbortError')
}
}

function bodyMixinMethods (instance, getInternalState) {
const methods = {
blob () {
Expand Down Expand Up @@ -443,24 +437,30 @@ function mixinBody (prototype, getInternalState) {
* @param {any} instance
* @param {(target: any) => any} getInternalState
*/
async function consumeBody (object, convertBytesToJSValue, instance, getInternalState) {
webidl.brandCheck(object, instance)
function consumeBody (object, convertBytesToJSValue, instance, getInternalState) {
try {
webidl.brandCheck(object, instance)
} catch (e) {
return Promise.reject(e)
}
Comment on lines +441 to +445
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this on the other hand is kind of stupid


const state = getInternalState(object)

// 1. If object is unusable, then return a promise rejected
// with a TypeError.
if (bodyUnusable(state)) {
throw new TypeError('Body is unusable: Body has already been read')
return Promise.reject(new TypeError('Body is unusable: Body has already been read'))
}

throwIfAborted(state)
if (state.aborted) {
return Promise.reject(new DOMException('The operation was aborted.', 'AbortError'))
}

// 2. Let promise be a new promise.
const promise = createDeferredPromise()

// 3. Let errorSteps given error be to reject promise with error.
const errorSteps = (error) => promise.reject(error)
const errorSteps = promise.reject

// 4. Let successSteps given a byte sequence data be to resolve
// promise with the result of running convertBytesToJSValue
Expand Down
Loading