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
10 changes: 5 additions & 5 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ const bodyConsumedDirectlyKey = Symbol('bodyConsumedDirectly')
const bodyLockReaderKey = Symbol('bodyLockReader')
const abortReasonKey = Symbol('abortReason')

const throwBodyUnusable = (): never => {
throw new TypeError('Body is unusable')
const newBodyUnusableError = (): TypeError => {
return new TypeError('Body is unusable')
}

const rejectBodyUnusable = (): Promise<never> => {
return Promise.reject(throwBodyUnusable())
return Promise.reject(newBodyUnusableError())
}

const textDecoder = new TextDecoder()
Expand All @@ -145,7 +145,7 @@ const consumeBodyDirectOnce = (
request: Record<string | symbol, any>
): Promise<never> | undefined => {
if (request[bodyConsumedDirectlyKey]) {
return Promise.reject(throwBodyUnusable())
return rejectBodyUnusable()
}
request[bodyConsumedDirectlyKey] = true
return undefined
Expand Down Expand Up @@ -488,7 +488,7 @@ const requestPrototype: Record<string | symbol, any> = {
value: function () {
if (this[bodyConsumedDirectlyKey]) {
if (k === 'clone') {
throwBodyUnusable()
throw newBodyUnusableError()
}
return rejectBodyUnusable()
}
Expand Down
Loading