Skip to content

Commit 28dbade

Browse files
committed
docs(learn): correct another example code for the consumption of response body
1 parent 9fbb9f6 commit 28dbade

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

apps/site/pages/en/learn/manipulating-files/reading-files-with-nodejs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ async function downloadFile(url, outputPath) {
101101
const response = await fetch(url);
102102

103103
if (!response.ok || !response.body) {
104+
// consuming the response body is mandatory: https://undici.nodejs.org/#/?id=garbage-collection
105+
await response.body.dump();
104106
throw new Error(`Failed to fetch ${url}. Status: ${response.status}`);
105107
}
106108

0 commit comments

Comments
 (0)