Open zmillman opened 4 months ago
Hey @zmillman, thanks for reaching out. Currently our wrapHandler
function does not support streamifyResponse
. If you still want to use wrapHandler
make sure you pass a function that takes the correct arguments.
We will put this issue onto our backlog to support streamifyResponse
.
Ran into this as well, although the error message was different
underlyingStream.setContentType is not a function
Here's an example workaround that worked for me.
export const handler = awslambda.streamifyResponse(
async function (event, responseStream, context) {
const sentryHandler = SentryServerless.wrapHandler(async function () {
return sstHandlerModule.handler(event, responseStream, context);
});
return sentryHandler(event, context, () => undefined);
},
);
You can "trick" the wrapHandler
function and then pass the actual 3 arguments needed for streaming inside.
Hey @JQuezada0 thanks for posting this workaround. For the time being, this is how we recommend using the wrapper with streamifyResponse
.
Note: If anyone coming across this issue is using our AWS Lambda layer and relied on its auto-wrapping capabilities, I suggest switching to the alternative layer usage which gives you the freedom to apply our wrapper yourself as shown in the code snippet above.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
8.15.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup/Reproduction Example
Steps to Reproduce
Expected Result
Code should execute identically as if there had been no
Sentry.wrapHandler
(returning "hello")Actual Result
Error logs from code above:
My guess is that
wrapHandler
wasn't written to detect the streaming Lambda handler which takes different arguments than the default handler.The Sentry docs have this snippet:
...but the AWS streaming handler expects the second argument to be
responseStream
(notcontext
)