Skip to content

Error's cause not respected (for non-Error causes) #9913

Closed
@jeengbe

Description

@jeengbe

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

7.88.0

Framework Version

n/a

Link to Sentry event

https://prisjakt-ab.sentry.io/issues/4738454694/events/latest/?project=4506415694348288

SDK Setup

Sentry.init({
  // ...
  integrations: [
    new Sentry.Integrations.Http(),
    new Sentry.Integrations.FunctionToString(),
    new Sentry.Integrations.ContextLines(),
    new Sentry.Integrations.LocalVariables(),
    new Sentry.Integrations.LinkedErrors(),
    new Sentry.Integrations.RequestData({
      include: {
        user: false,
        ip: true,
        cookies: false,
        data: false,
        headers: false,
        query_string: false,
        url: false,
      },
    }),
  ],
  // ...
});
Sentry.withScope((scope) => {
  scope.setSDKProcessingMetadata({ request: ctx.request });
  Sentry.captureException(error);
});

Steps to Reproduce

  1. Do API request:
try {
  const res = await doFetch();

  if (res.error) {
    throw new Error("Request failed", {
      cause: res
    });
  }
  1. Catch error and log it
} catch (err) {
  Sentry.withScope((scope) => {
    scope.setSDKProcessingMetadata({ request: ctx.request });
    Sentry.captureException(err);
  });
}

This adds the failed API response as cause on the error object. Yet on the linked issue in Sentry, there is no reference to that error cause.

Expected Result

The cause should somehow show in Sentry. I saw it do that for Error-causes. I saw some other GH issue thread that had something to do with a React boundary, but that was fixed and closed, so likely not applicable (also I can't find the link any more)

Actual Result

The cause doesn't show on the Sentry issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: browserIssues related to the Sentry Browser SDK

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions