Skip to content

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

Closed

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.

Activity

  1. self-assigned this
    on Aug 19, 2022
  2. lforst commented on Aug 19, 2022

    @lforst
    Contributor

    Hi, thank you very much for reporting this! I opened a PR to fix the bug - pointing to the offending line of code helped a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions