Closed
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/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/serverless
SDK Version
7.69.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Sentry.GCPFunction.init({
dsn: env.sentry.dsn,
release: env.sentry.release,
environment: env.sentry.environment,
integrations: [
new Integrations.RewriteFrames({
root: global.__rootdir__,
}),
],
})
Steps to Reproduce
- Set up a GCP PubSub Cloud Event function with a handler function that does not have the optional callback argument.
export const rawHandler: CloudEventFunction<PubSubData> = async (
event
) => {
try {
console.log(event.data)
} catch (e) {
console.log(e)
}
}
- Wrap your handler function in sentry
export const handler = Sentry.GCPFunction.wrapCloudEventFunction(
rawHandler
)
- Run your function
Expected Result
No error is thrown
Actual Result
A TypeError: callback is not a function error
is thrown after the handler function has finished executing.
This is the offending line of code https://github.com/getsentry/sentry-javascript/blob/master/packages/serverless/src/gcpfunction/cloud_events.ts#L62. It invokes a callback without checking if it exists first.
It looks like this was done for regular events, but not for cloud events.
See the following:
Metadata
Metadata
Assignees
Type
Projects
Status
No status