Title: Synchronous Lambda callback causes undesirable second captureException call · Issue #2956 · getsentry/sentry-javascript · GitHub
Open Graph Title: Synchronous Lambda callback causes undesirable second captureException call · Issue #2956 · getsentry/sentry-javascript
X Title: Synchronous Lambda callback causes undesirable second captureException call · Issue #2956 · getsentry/sentry-javascript
Description: See example event here: null.
Open Graph Description: See example event here: null.
X Description: See example event here: null.<anonymous> Package + Version @sentry/serverless Version: 5.25.0 Description If the callback-based lambda invocation is used, as opposed to the Promise-based styl...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/2956
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Synchronous Lambda callback causes undesirable second captureException call","articleBody":"See example event here: [null.\\\u003canonymous\\>](https://sentry.io/organizations/smol-ltd/issues/1941898665/)\r\n\r\n## Package + Version\r\n\r\n- [x] `@sentry/serverless`\r\n\r\n### Version:\r\n\r\n```\r\n5.25.0\r\n```\r\n\r\n## Description\r\n\r\nIf the callback-based lambda invocation is used, as opposed to the Promise-based style, then `@sentry/serverless` pushes the error correctly, but then also sends an empty exception. The reason is because this line:\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/ce16e339982c42cd7690b4b16aa220cf98766e23/packages/serverless/src/awslambda.ts#L168\r\n\r\ncalls `captureExceptionAsync` with the error correctly, but then also calls `.finally(... reject(callback(...))` \r\n\r\nwhich rejects this **awaited** promise with `undefined` (the return value of calling `callback`): \r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/ce16e339982c42cd7690b4b16aa220cf98766e23/packages/serverless/src/awslambda.ts#L180\r\n\r\nwhich causes execution to drop into the `catch` block below which then calls `captureExceptionAsync` again, but this time passing `undefined` as `e`:\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/ce16e339982c42cd7690b4b16aa220cf98766e23/packages/serverless/src/awslambda.ts#L198\r\n\r\n## Solution\r\n\r\nI guess the `catch` block could no-op if `e === undefined` or you could change the `callbackWrapper`\r\n\r\n```typescript\r\n// from:\r\ncaptureExceptionAsync(args[0], context, options).finally(() => reject(callback(...args)));\r\n\r\n// to:\r\ncallback(...args);\r\nreject(args[0]);\r\n```\r\n\r\nas that would then push the error through the `catch` block instead of the result of `callback`, and would also honour the `rethrow` option.","author":{"url":"https://github.com/leemhenson","@type":"Person","name":"leemhenson"},"datePublished":"2020-10-07T14:39:44Z","url":"https://github.com/getsentry/sentry-javascript/issues/2956"}
| 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:1e9761aa-29d8-a3da-9a9a-d39f901ce7a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2E8:1FAF:1F433F8:2A224AA:6B044D73 |
| html-safe-nonce | 9b05babe249e5e607d89006a4831f05311be46ef4b0bdc9da3138be235722ce0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkU4OjFGQUY6MUY0MzNGODoyQTIyNEFBOjZCMDQ0RDczIiwidmlzaXRvcl9pZCI6IjI0MjA5MzUxOTgxMDA0NDI0ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4245b7ac2e6a8fa3b593179072a28d40311cc9d69140b3fd079c0b2d49cc946a |
| hovercard-subject-tag | issue:716591771 |
| 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/2956/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dbd16305b6a98c84ce9411a713ef6608fe41f1940b39b5c43a8faa6fed6eea45/getsentry/sentry-javascript/issues/2956 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dbd16305b6a98c84ce9411a713ef6608fe41f1940b39b5c43a8faa6fed6eea45/getsentry/sentry-javascript/issues/2956 |
| og:image:alt | See example event here: null. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | leemhenson |
| hostname | github.com |
| expected-hostname | github.com |
| None | 002aa6b95ffa730b0aec436a5c383f536ad677284e60056037fb120afe37b730 |
| 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 | 059f24c781e3a0d7df3f27a97da0e93fab06ae39 |
| 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