Skip to content

Commit

Permalink
fix(fetch): do not set bodyUsed to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Apr 18, 2022
1 parent 7c1a52c commit 31b3a9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const properties = {
bodyUsed: {
enumerable: true,
get () {
return this[kState].body && util.isDisturbed(this[kState].body.stream)
return !!this[kState].body && util.isDisturbed(this[kState].body.stream)
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/node-fetch/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,9 @@ describe('Response', () => {
const res = new Response(null, { statusText: undefined })
expect(res.statusText).to.equal('')
})

it('should not set bodyUsed to undefined', () => {
const res = new Response()
expect(res.bodyUsed).to.be.false
})
})

0 comments on commit 31b3a9c

Please sign in to comment.