Skip to content

Commit b6a7262

Browse files
authored
fix(fetch): do not set bodyUsed to undefined (nodejs#1346)
1 parent 7c1a52c commit b6a7262

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/fetch/body.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ const properties = {
348348
bodyUsed: {
349349
enumerable: true,
350350
get () {
351-
return this[kState].body && util.isDisturbed(this[kState].body.stream)
351+
return !!this[kState].body && util.isDisturbed(this[kState].body.stream)
352352
}
353353
}
354354
}

test/node-fetch/response.js

+5
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,9 @@ describe('Response', () => {
224224
const res = new Response(null, { statusText: undefined })
225225
expect(res.statusText).to.equal('')
226226
})
227+
228+
it('should not set bodyUsed to undefined', () => {
229+
const res = new Response()
230+
expect(res.bodyUsed).to.be.false
231+
})
227232
})

0 commit comments

Comments
 (0)