Title: Error's `cause` not respected (for non-Error causes) · Issue #9913 · getsentry/sentry-javascript · GitHub
Open Graph Title: Error's `cause` not respected (for non-Error causes) · Issue #9913 · getsentry/sentry-javascript
X Title: Error's `cause` not respected (for non-Error causes) · Issue #9913 · getsentry/sentry-javascript
Description: Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
Open Graph Description: Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
X Description: Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
Opengraph URL: https://github.com/getsentry/sentry-javascript
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error's `cause` not respected (for non-Error causes)","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [X] I have reviewed the documentation https://docs.sentry.io/\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/browser\n\n### SDK Version\n\n7.88.0\n\n### Framework Version\n\nn/a\n\n### Link to Sentry event\n\nhttps://prisjakt-ab.sentry.io/issues/4738454694/events/latest/?project=4506415694348288\n\n### SDK Setup\n\n```ts\r\nSentry.init({\r\n // ...\r\n integrations: [\r\n new Sentry.Integrations.Http(),\r\n new Sentry.Integrations.FunctionToString(),\r\n new Sentry.Integrations.ContextLines(),\r\n new Sentry.Integrations.LocalVariables(),\r\n new Sentry.Integrations.LinkedErrors(),\r\n new Sentry.Integrations.RequestData({\r\n include: {\r\n user: false,\r\n ip: true,\r\n cookies: false,\r\n data: false,\r\n headers: false,\r\n query_string: false,\r\n url: false,\r\n },\r\n }),\r\n ],\r\n // ...\r\n});\r\n```\r\n\r\n```ts\r\nSentry.withScope((scope) => {\r\n scope.setSDKProcessingMetadata({ request: ctx.request });\r\n Sentry.captureException(error);\r\n});\r\n```\n\n### Steps to Reproduce\n\n1. Do API request:\r\n```ts\r\ntry {\r\n const res = await doFetch();\r\n\r\n if (res.error) {\r\n throw new Error(\"Request failed\", {\r\n cause: res\r\n });\r\n }\r\n```\r\n2. Catch error and log it\r\n```ts\r\n} catch (err) {\r\n Sentry.withScope((scope) => {\r\n scope.setSDKProcessingMetadata({ request: ctx.request });\r\n Sentry.captureException(err);\r\n });\r\n}\r\n```\r\n\r\nThis 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. \n\n### Expected Result\n\nThe 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)\n\n### Actual Result\n\nThe cause doesn't show on the Sentry issue.","author":{"url":"https://github.com/jeengbe","@type":"Person","name":"jeengbe"},"datePublished":"2023-12-19T12:54:20Z","url":"https://github.com/getsentry/sentry-javascript/issues/9913"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:8f1c0671-ff90-5895-42d6-7025be47fd3e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9ACE:45E1A:164CF7:1F03F8:6B0465EC |
| html-safe-nonce | 01170fdf77331af1d9bb66ead2f0e5b5f72f8bfb18a16c3d45678222b2cba43f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUNFOjQ1RTFBOjE2NENGNzoxRjAzRjg6NkIwNDY1RUMiLCJ2aXNpdG9yX2lkIjoiNDI4MjQ1OTYzNTc2OTk1OTkxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4899ffee8924ad149e895bec6f61e09f897884aa91b93ba2e18b05f8608ef589 |
| hovercard-subject-tag | repository:3328572 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/getsentry/sentry-javascript/issues/9913 |
| twitter:image | https://repository-images.githubusercontent.com/3328572/1b73c77d-6488-4ece-9e12-e61d9eb2ac2b |
| twitter:card | summary_large_image |
| og:image | https://repository-images.githubusercontent.com/3328572/1b73c77d-6488-4ece-9e12-e61d9eb2ac2b |
| og:image:alt | Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub. |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| turbo-cache-control | no-cache |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width