clone twice works incorrect in v3.1.0
See original GitHub issueCall response.clone() twice cause issue in v3.1.0, in v3.0.0 it works as expected
await res.clone().text(); // here it will return the same text as res contains
await res.clone().text(); // here it will return empty
Problem I think in change that was done in clone method, it reads body from instance[INTERNALS] let {body} = instance[INTERNALS];
, but then updates different property stream instance[INTERNALS].stream = p1;
and body remains the same.
But in v3.0.0 it both reads and then updates [INTERNALS].body
Reproduction
Steps to reproduce the behavior:
test:
it('should support clone() method', async () => {
const body = stream.Readable.from('a=1');
const res = new Response(body, {
headers: {
a: '1'
},
url: base,
status: 346,
statusText: 'production',
highWaterMark: 789
});
const cl = res.clone();
expect(cl.headers.get('a')).to.equal('1');
expect(cl.type).to.equal('default');
expect(cl.url).to.equal(base);
expect(cl.status).to.equal(346);
expect(cl.statusText).to.equal('production');
expect(cl.highWaterMark).to.equal(789);
expect(cl.ok).to.be.false;
// Clone body shouldn't be the same body
expect(cl.body).to.not.equal(body);
await cl.text().then(result => {
expect(result).to.equal('a=1');
})
const cl2 = res.clone();
await cl2.text().then(result => {
expect(result).to.equal('a=1');
});
});
Fails in last expect, result is empty instead of a=1
Expected behavior
Test passed
Your Environment
software | version |
---|---|
node-fetch | 3.1.0 |
node | 12.22.7 |
npm | 6.x |
Operating System | mac os |
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
The remote end hung up unexpectedly while git cloning
Quick solution: With this kind of error, I usually start by raising the postBuffer size by: git config --global http.postBuffer 524288000.
Read more >Does git clone overwrite the existing files in the directory is ...
But no, clone even refuses to clone into an existing empty directory.
Read more >95 questions with answers in TA CLONING | Scientific method
Hi all, These days, I tried to move an insert originally in the TA cloning vector (pGEM-T Easy, Promega) to my target plasmid...
Read more >Fixed issues in Illustrator releases - Adobe Support
We've been working hard at fixing the issues you reported to us. Here's a list of issues we fixed in the latest release...
Read more >Internet Explorer (IE) mode troubleshooting and FAQ
Incorrect Document mode configurations; Incomplete neutral site ... For example, buttons that worked with Internet Explorer don't do ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hopefully going to take a closer look to this tonight.
This bug is still present in v3.2.10.