Skip to content

Google Cloud Functions: Async errors not caught #3695

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

Closed
5 tasks done
martinklepsch opened this issue Jun 17, 2021 · 3 comments
Closed
5 tasks done

Google Cloud Functions: Async errors not caught #3695

martinklepsch opened this issue Jun 17, 2021 · 3 comments
Assignees

Comments

@martinklepsch
Copy link

Package + Version

  • @sentry/serverless 5.26.0

Description

I just tried using sentry/serverless with our Firebase application and can't get it to work at all. One thing that I noticed, which might be considered a bug is that errors thrown from within a promise don't seem to be caught by GCPFunction.wrapHttpFunction. Errors thrown synchronously are caught (as evident by the stacktrace) but also don't seem to be reported to Sentry in my particular case.

Should the wrapHttpFunction catch errors thrown from async evaluations? This forum thread indicates that this is a limitation with GCP. If that's still the case I think this limitation should be documented in the documentation (happy to provide a PR).

Overall I didn't have the best experience trying this and am a bit at a loss on how do debug this further. Is there a way to initialize Sentry in debug mode to get some additional information?

Thanks

@HazAT
Copy link
Member

HazAT commented Jun 24, 2021

Related: #3325
We don't instrument for unhandled promise rejections in our HTTP wrapper.

@alexbchr
Copy link

alexbchr commented Jul 1, 2021

For reference, here is a duplicated issue on this I believe: #3387

@HazAT So if I understand right, if using @sentry/serverless with Promises, we should do something like:

exports.helloHttp = Sentry.GCPFunction.wrapHttpFunction(async (req, res) => {
  try {
    const something = await fooBar()
    return res.status(200).send()
  } catch (error) {
    Sentry.captureException(error)
    Sentry.flush(1000)
  } 
});

Basically, we have to do the captureException and flush manually, as promises are not handled appropriately on GCP?

I didn't find any mention of this in the Sentry documentation and I feel it should be something that people should be informed on before using the @sentry/serverless library. I believe that most GCP functions people write use Promises and I don't get why this is not already built-in (or at least documented accordingly) in @sentry/serverless. Would be great to have an official example of how to use the library also with Promises.

Is there any plans to support Promises without any workarounds like this? If yes, how soon can we expect this feature?

@github-actions
Copy link
Contributor

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 label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


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

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

No branches or pull requests

6 participants