Skip to content

TypeError: callback is not a function thrown by Sentry.GCPFunction.wrapEventFunction #5607

Closed
@rstreefland

Description

@rstreefland

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/serverless

SDK Version

7.11.1

Framework Version

No response

Link to Sentry event

https://sentry.io/organizations/ember/issues/3461754605/events/ef4935183dfb4b5ea54ec171645131b8/?project=6603393

Steps to Reproduce

  1. Set up a GCP PubSub function with a handler function that does not have the optional callback argument.
export const rawHandler: EventFunction = async (
  message: PubsubMessage,
  context: CloudEventsContext
): Promise<void> => {

}
  1. Wrap your handler function in sentry
export const handler = Sentry.GCPFunction.wrapEventFunction(rawHandler);
  1. 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/events.ts#L65. It invokes a callback without checking if it exists first.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions