Skip to content

Sentry now showing first line of stack traces from the Error cause #14983

@Yuripetusko

Description

@Yuripetusko

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.48.0

Framework Version

react 18.3.1, next 14.24.2

Link to Sentry event

https://taskwise-gmbh.sentry.io/issues/16694528/?project=4508482014806096&query=is:unresolved%20issue.priority:%5Bhigh,%20medium%5D&stream_index=0

Reproduction Example/SDK Setup

https://codesandbox.io/p/sandbox/nervous-brattain-kzpr8z

export class CustomError extends Error {
  userErrorMessage: string;
  name = "CustomError";

  constructor(
    message: string,
    userErrorMessage?: RelocationUserErrorMessage,
    cause?: unknown
  ) {
    super(message, { cause });

    this.userErrorMessage = userErrorMessage || "Something went wrong";
  }
}

Steps to Reproduce

  1. Throw an error in 1 file
  2. Catch an error in another file and create new error passing original error as cause
  3. Capture new custom error with sentry

Expected Result

When console.logging the custom error, the stack trace of the cause includes a line where it was thrown, however when viewing the sentry, the stack trace of cause is missing 1 line, so it's hard to see where the error originated.

Example:

Here how it is displayed in Sentry

Image

And here how it is displayed in console

Image

As you see 1 line in the cause stack trace is missing in sentry, specifically this line:

at generateAreaInfoAction (generateAreaInfoAction.ts:21:11)

Actual Result

The whole stack trace to be included in Sentry for cause error

It appears that sentry displays the custom error's stack instead of stack of the cause, and only the first line (error name and message) of the cause is displayed, with the rest of the stack being displayed on sentry is taken from the actual error and not the cause error

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nextjsIssues related to the Sentry Nextjs SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions