Skip to content

src: add SetAbortHandler - #64684

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

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

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_MESSAGE macro is also added for cases where a message can be passed describing the reason for 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

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. 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