process: expose enhanced stack trace to uncaughtException handlers - #65849
process: expose enhanced stack trace to uncaughtException handlers#65849santusht06 wants to merge 1 commit into
Conversation
|
Review requested:
|
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. Caution AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context. |
When an EventEmitter emits an unhandled 'error' event, V8 appends an 'Emitted \'error\' event at:' frame to the stack trace via the inspector stack trace enhancer. However, this enhancement was applied only during the default fatal-exception path (inside fatalException()), after the uncaughtException and uncaughtExceptionMonitor handlers had already been invoked, so user-registered handlers never saw the enriched stack. Fix this by calling fatalExceptionStackEnhancers.beforeInspector() in createOnGlobalUncaughtException() before dispatching to the handlers. Fixes: nodejs#55838 Assisted-by: Antigravity Signed-off-by: santusht06 <115890693+santusht06@users.noreply.github.com>
|
I used AI assistance to help prepare this PR, personally verified and tested all changes locally, and take full responsibility for this submission. |
|
The recommendations in: advise you should tackle only one issue at a time and that you should not open any new PRs until your first PR has been approved. You already have other unapproved PRs open: |
|
Apologies for the noise and duplicate PR! Closing this as it is an accidental duplicate of #65580. Thank you for pointing that out, @MikeMcC399. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65849 +/- ##
==========================================
- Coverage 90.19% 90.17% -0.02%
==========================================
Files 771 771
Lines 264622 264627 +5
Branches 50223 50225 +2
==========================================
- Hits 238663 238634 -29
- Misses 16965 16974 +9
- Partials 8994 9019 +25
🚀 New features to boost your workflow:
|
Summary
Fixes #55838.
When an
EventEmitteremits an unhandled'error'event, V8 appends anEmitted 'error' event at:frame to the stack trace via the inspector stacktrace enhancer. However, this enhancement was applied only during the default
fatal-exception path (inside
fatalException()), after theuncaughtExceptionanduncaughtExceptionMonitorhandlers had already beeninvoked, so user-registered handlers never saw the enriched stack.
Root Cause
fatalExceptionStackEnhancers.beforeInspector()was called insidefatalException()— the final, process-exiting path — but not insidecreateOnGlobalUncaughtException()which fires the user handlers first.Fix
Call
fatalExceptionStackEnhancers.beforeInspector(er)insidecreateOnGlobalUncaughtException()before emitting touncaughtExceptionMonitoranduncaughtException. The guarder != null && typeof er === 'object'safely handles primitive throws.Testing
Added
test/parallel/test-process-uncaught-exception-enhanced-stack.jswhichverifies both a plain
EventEmitterand a subclass expose theEmitted 'error' event at:frame to both handlers.
Signed-off-by: santusht06 115890693+santusht06@users.noreply.github.com
Assisted-by: Antigravity