Skip to content

src,lib: add util.markPromiseAsHandled - #65805

Open
jasnell wants to merge 2 commits into
nodejs:mainfrom
jasnell:jasnell/promise-mark-promise-as-handled
Open

src,lib: add util.markPromiseAsHandled#65805
jasnell wants to merge 2 commits into
nodejs:mainfrom
jasnell:jasnell/promise-mark-promise-as-handled

Conversation

@jasnell

@jasnell jasnell commented Sep 5, 2026

Copy link
Copy Markdown
Member

Getting tired of seeing promise.catch(() => {}) in places ;-)

@jasnell jasnell added the semver-minor PRs that contain new features and should be released in the next minor version. label Sep 5, 2026
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Sep 5, 2026
Signed-off-by: James M Snell <jasnell@gmail.com>
@jasnell
jasnell force-pushed the jasnell/promise-mark-promise-as-handled branch from a784a8f to d8a9ada Compare September 5, 2026 02:55
@nodejs-github-bot

This comment was marked as outdated.

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.18%. Comparing base (57860ef) to head (5ba93a3).
⚠️ Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
src/node_util.cc 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65805      +/-   ##
==========================================
+ Coverage   90.14%   90.18%   +0.03%     
==========================================
  Files         769      771       +2     
  Lines      262968   264636    +1668     
  Branches    50052    50231     +179     
==========================================
+ Hits       237049   238658    +1609     
- Misses      16924    16967      +43     
- Partials     8995     9011      +16     
Files with missing lines Coverage Δ
lib/util.js 100.00% <100.00%> (ø)
src/node_util.cc 81.58% <88.88%> (+0.19%) ⬆️

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Probably the better perf utility

@jasnell jasnell added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 5, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

nodejs-github-bot commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

@LiviaMedeiros LiviaMedeiros left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with the test fix.

Comment thread test/parallel/test-mark-promise-handled.js Outdated
@LiviaMedeiros LiviaMedeiros removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 6, 2026
Co-authored-by: Livia Medeiros <livia@cirno.name>
@jasnell jasnell added commit-queue-squash PRs the Commit Queue should land as one squashed commit. author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Sep 6, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@LiviaMedeiros LiviaMedeiros left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should also update the suggestion here?

node/doc/api/process.md

Lines 474 to 479 in 10720f7

In this example case, it is possible to track the rejection as a developer error
as would typically be the case for other `'unhandledRejection'` events. To
address such failures, a non-operational
[`.catch(() => { })`][`promise.catch()`] handler may be attached to
`resource.loaded`, which would prevent the `'unhandledRejection'` event from
being emitted.

LGTM whether it's updated in this PR or as follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants