Skip to content

Printed errors should show cause #8856

Description

@OliverJAsh

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.64.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'https://abc@app.getsentry.com/123' });

throw new Error('foo', { cause: 'bar' });

Expected Result

The printed error should include the cause.

Actual Result

The printed error does not include the cause:

$ node test.js
Error: foo
    at Object.<anonymous> (/Users/oliver/Code/unsplash/unsplash-web/test.js:4:7)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

If we remove Sentry.init, the cause is shown:

$ node test.js
/Users/oliver/Code/unsplash/unsplash-web/test.js:4
throw new Error('foo', { cause: 'bar' });
^

Error: foo
    at Object.<anonymous> (/Users/oliver/Code/unsplash/unsplash-web/test.js:4:7)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  [cause]: 'bar'
}

It seems that Sentry is changing the way that exceptions are printed. I believe this custom logic needs to be updated to include the cause. Furthermore, I am wondering if it's possible to disable this and use Node's default behaviour?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions