diff --git a/lib/fetch/body.js b/lib/fetch/body.js index fe8c4333b5e..415e4ea34da 100644 --- a/lib/fetch/body.js +++ b/lib/fetch/body.js @@ -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) } } } diff --git a/test/node-fetch/response.js b/test/node-fetch/response.js index 3d41aad3b07..b6dea5aec76 100644 --- a/test/node-fetch/response.js +++ b/test/node-fetch/response.js @@ -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 + }) })