Skip to content

Conversation

@tenkirin
Copy link
Contributor

@tenkirin tenkirin commented Nov 5, 2025

Description

Docs, fix #8331.

Added await response.body?.cancel(); to explicitly destroy the response body before throwing an error.

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

Validation

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@tenkirin tenkirin requested a review from a team as a code owner November 5, 2025 09:27
@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nodejs-org Ready Ready Preview Nov 5, 2025 9:50am

@tenkirin tenkirin force-pushed the docs/correct-example-code-2 branch from 902ed4b to e4d7028 Compare November 5, 2025 09:49
@tenkirin tenkirin marked this pull request as ready for review November 5, 2025 09:49
Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! In the future, there's no need to open an issue for these little things. In fact, if you want, you can also group them all into a single PR.

@avivkeller avivkeller enabled auto-merge November 6, 2025 15:35
@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.74%. Comparing base (9fbb9f6) to head (e4d7028).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8332      +/-   ##
==========================================
+ Coverage   76.72%   76.74%   +0.02%     
==========================================
  Files         118      118              
  Lines        9805     9805              
  Branches      335      335              
==========================================
+ Hits         7523     7525       +2     
+ Misses       2280     2278       -2     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@avivkeller avivkeller added this pull request to the merge queue Nov 6, 2025
Merged via the queue into nodejs:main with commit 15921e1 Nov 6, 2025
16 checks passed
@tenkirin tenkirin deleted the docs/correct-example-code-2 branch November 7, 2025 09:08
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 this pull request may close these issues.

[Docs] incorrect example code in docs

3 participants