← Back to Pull requests

node-api: clear the pending exception before handling it #67448

Merged
manusingh090 merged 4 files (167 lines) on Nov 27, 2026 04:42 UTC
View on GitHub
manusingh090 manusingh090 commented on Nov 13, 2026 03:22 UTC
Author

CallIntoModule() reset last_exception only after handle_exception() returned. When handle_exception() reports the exception through 'uncaughtException', the listener runs while the exception is still pending, so calling back into the module from it saw the same exception again:

  • A finalizer run by gc() in an experimental module reported it a second time, which aborted the process with "Re-entrant uncaught exception detected" (the case in the issue).

  • An addon function called from the listener failed with napi_pending_exception and rethrew the old exception. This also happens with non-experimental modules (Node-API 10).
  • This takes the exception out of last_exception before handling it.

    The new test covers both cases. Without the fix it aborts with the error from the issue and rethrows the stale exception. With it, it passes, as do the existing node-api and js-native-api tests.

    Fixes: https://github.com/nodejs/node/issues/67421
    Assisted-by: a coding agent

    Diff: 167 lines (+166 / -1) across 4 files Reviewer: jasnell Review duration: 20239m
    All Vouch review confidence checks passed
    Residual risk 0.12 = Change Risk (0.38) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 167 lines diff across 4 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.56 · 5 substantive comment(s)
    0.56
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    68%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.307
    Real PR Conversation Timeline
    9 items
    nodejs-github-bot nodejs-github-bot commented on Nov 13, 2026 03:23 UTC
    Bot

    Review requested:

  • @nodejs/gyp

  • @nodejs/node-api
  • codecov[bot] codecov[bot] commented on Nov 13, 2026 04:56 UTC
    Bot

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    :white_check_mark: Project coverage is 90.69%. Comparing base (7b4c9e3) to head (072d521).
    :warning: Report is 343 commits behind head on main.

    <details><summary>Additional details and impacted files</summary>

    @@            Coverage Diff             @@
    ##             main   #67448      +/-   ##
    ==========================================
    - Coverage   90.71%   90.69%   -0.02%     
    ==========================================
      Files         801      801              
      Lines      281889   281890       +1     
      Branches    54315    54318       +3     
    ==========================================
    - Hits       255709   255664      -45     
    - Misses      16307    16366      +59     
    + Partials     9873     9860      -13     
    

    | Files with missing lines | Coverage Δ | |
    |---|---|---|
    | src/js\_native\_api\_v8.h | 90.98% <100.00%> (+0.07%) | :arrow_up: |

    ... and 36 files with indirect coverage changes
    </details>
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    manusingh090 manusingh090 commented on Nov 13, 2026 05:26 UTC
    Author

    The aarch64-linux: with shared openssl-fips failure is in test-fs-stat-cancel-inflight, which is unrelated to this change and is being deflaked in #67449.

    jasnell jasnell approved these changes on Nov 14, 2026 05:47 UTC
    Approved Reviewer

    Approved these changes.

    legendecas legendecas approved these changes on Nov 25, 2026 21:31 UTC
    Approved Reviewer

    Approved these changes.

    nodejs-github-bot nodejs-github-bot commented on Nov 27, 2026 04:42 UTC
    Bot

    Landed in 0089699ae34df258b1e47ee3fd1e1bee5a08cf40

    Reviewers
    Assignees
    manusingh090 manusingh090
    Labels
    risk: low confidence: 68.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38% (MEDIUM) · Higher = larger blast radius
    38%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 68.5% · Lower = rushed or shallow review
    68.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 12.0% · Safe to merge
    12.0%
    Repository