Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response.bodyUsed should be false when there is no body #1214

Closed
tkrotoff opened this issue Dec 2, 2022 · 0 comments · Fixed by #1357
Closed

Response.bodyUsed should be false when there is no body #1214

tkrotoff opened this issue Dec 2, 2022 · 0 comments · Fixed by #1357

Comments

@tkrotoff
Copy link
Contributor

tkrotoff commented Dec 2, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@tkrotoff and others