getsentry / getsentry/sentry

Prioritize error cause as primary exception for Node.js chained errors

Open
#107,984 4 comments 1 reaction 0 assignees View on GitHub
Improvement Issues > Grouping Product Area: Issues
Dominant language
Python
Stars
44.8k
Forks
4.9k
Avg merge
21h 10m
Merged PRs (30d)
635

Description

### Problem Statement

A user pointed out that when a Node.js error is thrown with a cause (e.g. throw new CustomError(message, { cause: originalError })), Sentry always surfaces the outermost wrapper error in issue titles, alerts, and crash locations. The inner cause, which is often the most actionable part of the failure is buried.

Sentry already handles this for React 19 errors, RxJava, and Kotlin Coroutines via `main_exception_id` overrides in `_maybe_override_main_exception_id()`. But there is no equivalent for generic Node.js `cause` chains, which are a very common pattern.

### Solution Brainstorm

Extend the existing main_exception_id override mechanism to recognize generic Node.js cause chains and treat the cause as the primary exception, similar to how it's already done for React, RxJava, and Kotlin.

### Product Area

Issues

Contributor guide

Open the contributing guide

Research direction

Start by reading _maybe_override_main_exception_id() and the existing React 19, RxJava, and Kotlin Coroutines override handling mentioned in the issue. Add coverage for a generic Node.js cause chain and verify that the inner cause becomes the primary exception for issue titles, alerts, and crash locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.