Title: Sentry.wrapHandler breaks streaming Lambda handlers · Issue #12815 · getsentry/sentry-javascript · GitHub
Open Graph Title: Sentry.wrapHandler breaks streaming Lambda handlers · Issue #12815 · getsentry/sentry-javascript
X Title: Sentry.wrapHandler breaks streaming Lambda handlers · Issue #12815 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/12815
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sentry.wrapHandler breaks streaming Lambda handlers","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/aws-serverless\n\n### SDK Version\n\n8.15.0\n\n### Framework Version\n\n_No response_\n\n### Link to Sentry event\n\n_No response_\n\n### SDK Setup/Reproduction Example\n\n```\r\nSentry.init({ dsn: process.env.SENTRY_DSN });\r\n```\n\n### Steps to Reproduce\n\n1. Define an AWS Lambda running with the Node 20.x runtime & configure the SENTRY_DSN env variable:\r\n\r\n```js\r\nimport * as Sentry from \"@sentry/aws-serverless\";\r\n\r\nSentry.init({ dsn: process.env.SENTRY_DSN });\r\n\r\n// awslambda.streamifyResponse is patched into the global object by the lambda runtime\r\n// https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html\r\nexport const handler = Sentry.wrapHandler(\r\n awslambda.streamifyResponse(async function (event, responseStream, _context) {\r\n\r\n responseStream.write(\"hello\");\r\n responseStream.end();\r\n })\r\n);\r\n```\r\n\r\n2. Make a request (any payload)\r\n3. Check Lambda logs for error\n\n### Expected Result\n\nCode should execute identically as if there had been no `Sentry.wrapHandler` (returning \"hello\")\r\n\r\n\n\n### Actual Result\n\nError logs from code above:\r\n\r\n```\r\n2024-07-09T00:38:31.701Z\ta203c0fb-7d33-4a3f-b5af-f76ed67423e6\tERROR\tInvoke Error \t\r\n{\r\n \"errorType\": \"TypeError\",\r\n \"errorMessage\": \"responseStream.write is not a function\",\r\n \"stack\": [\r\n \"TypeError: responseStream.write is not a function\",\r\n \" at file:///var/task/index.js:299031:20\",\r\n \" at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\",\r\n \" at async processResult (file:///var/task/index.js:10:14)\"\r\n ]\r\n}\r\n```\r\n\r\nMy guess is that `wrapHandler` wasn't written to detect the streaming Lambda handler which takes different arguments than the default handler.\r\n\r\nThe [Sentry docs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/#configure) have this snippet:\r\n\r\n```ts\r\nexports.handler = Sentry.wrapHandler(async (event, context) => {\r\n // Your handler code\r\n});\r\n```\r\n...but the AWS streaming handler expects the second argument to be `responseStream` (not `context`)","author":{"url":"https://github.com/zmillman","@type":"Person","name":"zmillman"},"datePublished":"2024-07-09T00:54:20Z","url":"https://github.com/getsentry/sentry-javascript/issues/12815"}
| 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:b41d5ac4-37d1-63c9-d2be-c74e0a9c64de |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D51E:104CA3:1AF96F8:252DD3E:6B059481 |
| html-safe-nonce | 956404b5e402bc265d4f5ab6ab2ed84663d4c158464d30a42dfb18b232545f30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTFFOjEwNENBMzoxQUY5NkY4OjI1MkREM0U6NkIwNTk0ODEiLCJ2aXNpdG9yX2lkIjoiMTI0OTY2NjYwNjgxNzQ0OTA4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fadd503a3b659d5aed37e82f38829e4a1ae7d8350e36d61dd48ed02d670cae94 |
| hovercard-subject-tag | issue:2396860716 |
| 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/12815/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a932ed1a37bfa3a2d10b5e239733c67f5f9e8e71993fd3efb8ae9416450cd5ac/getsentry/sentry-javascript/issues/12815 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a932ed1a37bfa3a2d10b5e239733c67f5f9e8e71993fd3efb8ae9416450cd5ac/getsentry/sentry-javascript/issues/12815 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zmillman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3b72fd2385d76a50ce0fe937d50bb4a81434432c4fd47866074a26f6cd03623f |
| 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 | 58e2bd32336f3dcee343ec627a4d09c7c444e214 |
| 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