Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: callback is not a function thrown by Sentry.GCPFunction.wrapCloudEventFunction #9044

Closed
3 tasks done
dancallaghan opened this issue Sep 19, 2023 · 3 comments · Fixed by #11701
Closed
3 tasks done
Labels
Package: serverless Issues related to the Sentry Serverless SDK Type: Bug

Comments

@dancallaghan
Copy link

Is there an existing issue for this?

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

  1. 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)
  }
}
  1. Wrap your handler function in sentry
export const handler = Sentry.GCPFunction.wrapCloudEventFunction(
  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/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:

@github-actions github-actions bot added the Package: serverless Issues related to the Sentry Serverless SDK label Sep 19, 2023
@Lms24
Copy link
Member

Lms24 commented Sep 19, 2023

Hi @dancallaghan thanks for reporting and thanks for already debugging the issue!
I agree, we should apply the same fix as for the event function.

Since you already found the responsible line, are you interested in submitting a PR? We'd make sure to mention you as a contributor in the next release. If not, no worries, we'll try to fix it ourselves eventually.

@getsantry
Copy link

getsantry bot commented Oct 11, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Oct 11, 2023
tcoyze added a commit to tcoyze/sentry-javascript that referenced this issue Apr 19, 2024
tcoyze added a commit to tcoyze/sentry-javascript that referenced this issue Apr 19, 2024
tcoyze added a commit to tcoyze/sentry-javascript that referenced this issue Apr 22, 2024
tcoyze added a commit to tcoyze/sentry-javascript that referenced this issue Apr 22, 2024
tcoyze added a commit to tcoyze/sentry-javascript that referenced this issue Apr 22, 2024
tcoyze added a commit to tcoyze/sentry-javascript that referenced this issue Apr 22, 2024
@AbhiPrasad
Copy link
Member

Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/7.112.0 - thank you @tcoyze for contributing!!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: serverless Issues related to the Sentry Serverless SDK Type: Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants