JakeChampion / fetch

A window.fetch JavaScript polyfill.

Home Page:http://github.github.io/fetch/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Response.bodyUsed should be false when there is no body

tkrotoff opened this issue · comments

Reproduction

const response = new Response(); // <=== Response does not have a body
expect(response.bodyUsed).toEqual(false); // OK

expect(await response.text()).toEqual('');
expect(response.bodyUsed).toEqual(false); // KO: node-fetch returns true

Same problem with Response.error()

Expected behavior

Under Chrome 107:

<< const response = new Response()
<< response.bodyUsed
>> false
<< await response.text()
<< response.bodyUsed
>> false

Your Environment

software version
whatwg-fetch 3.6.2
node 18.12.1
npm 8.19.2
Operating System macOS Monterey

Related issues: nodejs/undici#1794, node-fetch/node-fetch#1684