Title: `@sentry/serverless` does not send Error events on crashes (GCP Function) · Issue #3387 · getsentry/sentry-javascript · GitHub
Open Graph Title: `@sentry/serverless` does not send Error events on crashes (GCP Function) · Issue #3387 · getsentry/sentry-javascript
X Title: `@sentry/serverless` does not send Error events on crashes (GCP Function) · Issue #3387 · getsentry/sentry-javascript
Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javascript/releases Provide a link to the aff...
Open Graph Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas...
X Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/3387
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`@sentry/serverless` does not send Error events on crashes (GCP Function)","articleBody":"\u003c!-- Requirements: please go through this checklist before opening a new issue -->\r\n\r\n- [x] Review the documentation: https://docs.sentry.io/\r\n- [x] Search for existing issues: https://github.com/getsentry/sentry-javascript/issues\r\n- [x] Use the latest release: https://github.com/getsentry/sentry-javascript/releases\r\n- [x] Provide a link to the affected event from your Sentry account\r\n\r\n## Package + Version\r\n\r\nUsing:\r\n- `@sentry/serverless@6.2.5`\r\n- `@sentry/tracing@6.2.5`\r\n\r\n## Description\r\n\r\nWhen using `@sentry/serverless`, uncaught exception are not sent to Sentry when hosted on GCP Functions (or when executed locally using `@google-cloud/functions-framework` package). Here is the basic code I have for this integration:\r\n\r\n```ts\r\nimport * as Sentry from '@sentry/serverless'\r\nimport * as SentryTracing from '@sentry/tracing'\r\nimport { HttpFunction } from '@google-cloud/functions-framework/build/src/functions'\r\n\r\n// Necessary so Sentry doesn't crash on error (because of Webpack tree-shaking)\r\nSentryTracing.addExtensionMethods()\r\n\r\nSentry.GCPFunction.init({\r\n dsn: 'SENTRY_DSN_HERE',\r\n tracesSampleRate: 1.0,\r\n environment: 'development',\r\n debug: true,\r\n})\r\n\r\nconst myHandler: HttpFunction = async (req, res) => {\r\n if (req.method === 'POST') {\r\n throw new Error('Dummy function error')\r\n }\r\n\r\n // Rest of code...\r\n}\r\n\r\nexport const myFunc = Sentry.GCPFunction.wrapHttpFunction(myHandler)\r\n```\r\n\r\nWhen running this locally, here is the output I get when calling this with a manual POST request (it doesn't work either when deployed on GCP Functions):\r\n\r\n```\r\nSentry Logger [Log]: Integration installed: InboundFilters\r\nSentry Logger [Log]: Integration installed: FunctionToString\r\nSentry Logger [Log]: Integration installed: Console\r\nSentry Logger [Log]: Integration installed: Http\r\nSentry Logger [Log]: Integration installed: OnUncaughtException\r\nSentry Logger [Log]: Integration installed: OnUnhandledRejection\r\nSentry Logger [Log]: Integration installed: LinkedErrors\r\nSentry Logger [Log]: Integration installed: GoogleCloudHttp\r\nSentry Logger [Log]: Integration installed: GoogleCloudGrpc\r\nServing function...\r\nFunction: contactUs\r\nURL: http://localhost:8081/\r\nSentry Logger [Log]: [Tracing] starting gcp.function.http transaction - POST /\r\nThis error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:\r\nError: Dummy function error\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:560827\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:561650\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:60124\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:54696\r\n at Object.apply (/Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:54787)\r\n at /Users/username/Projects/projectName/node_modules/@google-cloud/functions-framework/build/src/invoker.js:100:17\r\n at processTicksAndRejections (internal/process/task_queues.js:79:11)\r\nUnhandled rejection\r\nError: Dummy function error\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:560827\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:561650\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:60124\r\n at /Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:54696\r\n at Object.apply (/Users/username/Projects/projectName/packages/functions-contact-us/dist/index.js:2:54787)\r\n at /Users/username/Projects/projectName/node_modules/@google-cloud/functions-framework/build/src/invoker.js:100:17\r\n at processTicksAndRejections (internal/process/task_queues.js:79:11)\r\nError: Process exited with code 16\r\n at process.\u003canonymous> (/Users/username/Projects/projectName/node_modules/@google-cloud/functions-framework/build/src/invoker.js:275:22)\r\n at process.emit (events.js:314:20)\r\n at process.EventEmitter.emit (domain.js:483:12)\r\n at process.exit (internal/process/per_thread.js:168:15)\r\n at Object.sendCrashResponse (/Users/username/Projects/projectName/node_modules/@google-cloud/functions-framework/build/src/logger.js:37:9)\r\n at process.\u003canonymous> (/Users/username/Projects/projectName/node_modules/@google-cloud/functions-framework/build/src/invoker.js:271:22)\r\n at process.emit (events.js:326:22)\r\n at process.EventEmitter.emit (domain.js:483:12)\r\n at processPromiseRejections (internal/process/promises.js:209:33)\r\n at processTicksAndRejections (internal/process/task_queues.js:98:32)\r\n```\r\n\r\nIf I manually use `Sentry.captureException(error)`, errors are sent correctly to Sentry, but just instrumenting the code as in the Sentry GCP documentation just doesn't track the errors at all. Also, I don't know if it is normal that I get the same error twice in the console logs.\r\n\r\nI honestly don't understand what is going on and feel like I will need to manually annotate my code with try/catch and `Sentry.captureException(error)` everywhere in order for the Crash reporting to work... However, this should all be done automatically by `@sentry/serverless`.","author":{"url":"https://github.com/alexbchr","@type":"Person","name":"alexbchr"},"datePublished":"2021-04-12T17:26:00Z","url":"https://github.com/getsentry/sentry-javascript/issues/3387"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ae35d66f-f14d-91be-c89d-aa4cdd73c4b8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D5EC:2843FB:4811CF:62BAEB:6B047051 |
| html-safe-nonce | 50e4263b98e8a32c27b99972897b569f719b58f812215ad718081d8eec83c45f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUVDOjI4NDNGQjo0ODExQ0Y6NjJCQUVCOjZCMDQ3MDUxIiwidmlzaXRvcl9pZCI6IjEyNzY2NTAzNDg3Mzk4NTAzMjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 525ae5a67ee69924115708e388dae8313f1d74de030dc4613567c9bcae9e9867 |
| hovercard-subject-tag | issue:856190030 |
| 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/_view_fragments/issues/show/getsentry/sentry-javascript/3387/issue_layout |
| twitter:image | https://opengraph.githubassets.com/59a525c5be49e87a631d3dd20c87380c0d5bddb7f11c89bb4ac08312ae1307e2/getsentry/sentry-javascript/issues/3387 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/59a525c5be49e87a631d3dd20c87380c0d5bddb7f11c89bb4ac08312ae1307e2/getsentry/sentry-javascript/issues/3387 |
| og:image:alt | Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexbchr |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| turbo-cache-control | no-preview |
| 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 | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| 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