Skip to content

src: add SetAbortHandler - #64684

Closed
maxhfisher wants to merge 8 commits into
nodejs:mainfrom
maxhfisher:aborthandler
Closed

src: add SetAbortHandler#64684
maxhfisher wants to merge 8 commits into
nodejs:mainfrom
maxhfisher:aborthandler

Conversation

@maxhfisher

@maxhfisher maxhfisher commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This adds SetAbortHandler, which allows embedders to specify custom behavior in situations where ABORT() is called. The current behavior of ABORT() is to stream both the native and JS backtraces to stderr and exit with platform specific behavior. Some embedders may want to change this behavior, such as changing where the backtrace is provided. Embedders can also use the handler to exit with their own behavior, but node will still guarantee an exit if the provided abort handler returns.

A DefaultAbortHandler is used to ensure existing behavior does not change unless an abort handler is explicitly provided. The only difference with this design is an additional stack frame in the backtrace for the abort handler, but this behavior was never guaranteed.

A new ABORT_WITH_DETAILS macro is also added for cases where a location and message can be passed describing the abort. This new macro replaces existing calls to ABORT in various error handlers in node_errors.cc where a message is already available. This message is then propagated to the abort handler, but no changes are made to the default abort handler. That behavior does not change here.

Signed-off-by: Max H Fisher <mfisher187@bloomberg.net>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp

@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. labels Jul 22, 2026
Comment thread test/abort/test-addon-abort-handler.js Outdated
Comment thread src/node.h Outdated
Comment thread src/node.h Outdated
Comment thread src/node.h Outdated
Comment thread src/node_errors.cc Outdated
Comment thread src/node_errors.cc Outdated
Comment thread src/node.h Outdated
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.46154% with 8 lines in your changes missing coverage. Please review.
βœ… Project coverage is 90.28%. Comparing base (efc0a14) to head (6b87c15).
⚠️ Report is 231 commits behind head on main.

Files with missing lines Patch % Lines
src/node_errors.cc 38.46% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64684      +/-   ##
==========================================
+ Coverage   90.11%   90.28%   +0.17%     
==========================================
  Files         741      759      +18     
  Lines      242196   247639    +5443     
  Branches    45606    46691    +1085     
==========================================
+ Hits       218246   223581    +5335     
- Misses      15438    15520      +82     
- Partials     8512     8538      +26     
Files with missing lines Coverage Ξ”
src/node.h 92.30% <ΓΈ> (ΓΈ)
src/util.h 90.98% <ΓΈ> (ΓΈ)
src/node_errors.cc 62.58% <38.46%> (-0.18%) ⬇️

... and 196 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.

Signed-off-by: Max H Fisher <mfisher187@bloomberg.net>
Comment thread src/util.h Outdated
Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2026
@nodejs-github-bot

This comment was marked as outdated.

@legendecas legendecas added the review wanted PRs that need reviews. label Jul 29, 2026
@nodejs-github-bot

This comment was marked as outdated.

@maxhfisher
maxhfisher marked this pull request as draft August 5, 2026 15:28
@maxhfisher
maxhfisher marked this pull request as ready for review August 5, 2026 19:44
Comment thread src/util.h
@legendecas legendecas added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Aug 7, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@legendecas legendecas added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Aug 11, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Aug 11, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64684
βœ”  Done loading data for nodejs/node/pull/64684
----------------------------------- PR info ------------------------------------
Title      src: add SetAbortHandler (#64684)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     maxhfisher:aborthandler -> nodejs:main
Labels     c++, author ready, needs-ci, review wanted, commit-queue, commit-queue-squash
Commits    8
 - src: add SetAbortHandler
 - fix: fix lint
 - fix: respond to PR comments
 - fix: Update default abort message
 - fix: Split handler arguments into location and message
 - Merge branch 'nodejs:main' into aborthandler
 - fix: Be more clear about null arguments in abort handler
 - fix: Prose
Committers 2
 - Max H Fisher <mfisher187@bloomberg.net>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/64684
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64684
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Wed, 22 Jul 2026 20:52:39 GMT
   βœ”  Approvals: 1
   βœ”  - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/64684#pullrequestreview-4883277125
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2026-08-09T07:55:41Z: https://ci.nodejs.org/job/node-test-pull-request/75684/
- Querying data for job/node-test-pull-request/75684/
βœ”  Build data downloaded
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  No git cherry-pick in progress
   βœ”  No git am in progress
   βœ”  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
βœ”  origin/main is now up-to-date
- Downloading patch for 64684
From https://github.com/nodejs/node
 * branch                  refs/pull/64684/merge -> FETCH_HEAD
βœ”  Fetched commits as 2749388e44ac..455cbed91694
--------------------------------------------------------------------------------
Auto-merging src/util.h
[main 8c9e8f5a6d] src: add SetAbortHandler
 Author: Max H Fisher <mfisher187@bloomberg.net>
 Date: Wed Jul 22 16:07:43 2026 -0400
 8 files changed, 148 insertions(+), 3 deletions(-)
 create mode 100644 test/abort/test-addon-abort-handler.js
 create mode 100644 test/addons/abort-handler/binding.cc
 create mode 100644 test/addons/abort-handler/binding.gyp
 create mode 100644 test/addons/abort-handler/test.js
[main f64686a503] fix: fix lint
 Author: Max H Fisher <mfisher187@bloomberg.net>
 Date: Wed Jul 22 17:48:50 2026 -0400
 1 file changed, 2 insertions(+), 2 deletions(-)
Auto-merging src/util.h
[main ca1cadebfb] fix: respond to PR comments
 Author: Max H Fisher <mfisher187@bloomberg.net>
 Date: Thu Jul 23 17:16:39 2026 -0400
 7 files changed, 55 insertions(+), 45 deletions(-)
 delete mode 100644 test/abort/test-addon-abort-handler.js
Auto-merging src/util.h
[main deac2a26a1] fix: Update default abort message
 Author: Max Fisher <66274614+maxhfisher@users.noreply.github.com>
 Date: Fri Jul 24 16:58:44 2026 -0400
 1 file changed, 1 insertion(+), 1 deletion(-)
Auto-merging src/util.h
error: commit f579940a11b9a8d0afb94a9b6d7353bc2b348ebe is a merge but no -m option was given.
fatal: cherry-pick failed
[main c0979cfc85] fix: Split handler arguments into location and message
 Author: Max H Fisher <mfisher187@bloomberg.net>
 Date: Wed Aug 5 15:26:31 2026 -0400
 5 files changed, 29 insertions(+), 22 deletions(-)
   ✘  Failed to apply patches
https://github.com/nodejs/node/actions/runs/31535700850

legendecas pushed a commit that referenced this pull request Aug 11, 2026
Signed-off-by: Max H Fisher <mfisher187@bloomberg.net>
PR-URL: #64684
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
@legendecas

Copy link
Copy Markdown
Member

Landed in 559afb1

@legendecas legendecas closed this Aug 11, 2026
aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Signed-off-by: Max H Fisher <mfisher187@bloomberg.net>
PR-URL: #64684
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. review wanted PRs that need reviews.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants