Skip to content

Commit

Permalink
fix(fetch): do not set bodyUsed to undefined (nodejs#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen authored and metcoder95 committed Dec 26, 2022
1 parent 4732496 commit cdfe12e
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
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
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 cdfe12e

Please sign in to comment.