Closed athal7 closed 5 years ago
This solution does not work for responses > 16Kb unfortunately.
There is a PR in node-fetch repository that introduces highWaterMark
parameter to clone
method. It will fix the mentioned issue.
Thanks @nikdo do you mind posting a link to that PR?
Yeah. Sorry for omitting the link, I've just forgotten to add it there. This is the PR.
In the meantime, I realized @zkat is using her own fork of node-fetch. I'll create PR there too.
Thanks @nikdo
Calling
res.buffer()
marks the body as having already been used, which makes subsequent parsing calls (e.g.res.json()
) throw this error. By using a clone of the response for buffering / saving, the response's parse-ability is preserved to be consistent with a cache-miss response.