Skip to content

Commit 30d6c52

Browse files
authored
docs(learn): correct the example code for the consumption of response… (#8322)
docs(learn): correct the example code for the consumption of response body
1 parent 9fbb9f6 commit 30d6c52

File tree

1 file changed

+2
-0
lines changed
  • apps/site/pages/en/learn/getting-started

1 file changed

+2
-0
lines changed

apps/site/pages/en/learn/getting-started/fetch.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ async function streamOllamaCompletion(prompt) {
104104
// You can read about HTTP status codes here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
105105
// 200 means the request was successful.
106106
if (statusCode !== 200) {
107+
// consuming the response body is mandatory: https://undici.nodejs.org/#/?id=garbage-collection
108+
await body.dump();
107109
throw new Error(`Ollama request failed with status ${statusCode}`);
108110
}
109111

0 commit comments

Comments
 (0)