0
votes

There is a similar question regarding Debugging Firebase Cloud Functions using Stackdriver.

The answer there, however, doesn't seem to help at all with getting Stackdriver Debug to work with my normal Cloud Function (not Firebase). I've tried sourcing the code from Github and a Cloud Source Repository - but that doesn't seem to work. Both times I get in the side bar:

This project does not include any running applications.

The documentation about debugging Cloud Functions seems to say nothing about using Stackdriver Debug. Is there any way to use Stackdriver Debug with Cloud Functions?

4

4 Answers

0
votes

I ended up finding the solution from this video: https://youtu.be/BybYim0HRmY?t=21m42s

Quite simply you add require("@google/cloud-debug") to the top of your index.js (or whatever file your function is in). Then add @google/cloud-debug as a dependency in your package.json.

You can then manually import the code into Stackdriver Debug and you're good to go.

0
votes

Cloud Debugger does not support Cloud Functions just yet.

Although it might seem to work by adding require("@google/cloud-debug"), it is not reliable as you would like it to be. This is because the Function might be shutdown before the debugger code is able to initialize or able to report the result back to the debugger server.

The Cloud Function team at google are working to enable the debugger in a reliable way.

0
votes

Looks like the cloud-debug package is obsolete and has been renamed to @google-cloud/debug-agent:

    yarn add @google/cloud-debug
    yarn add v0.23.4
    [1/4] 🔍  Resolving packages...
    warning @google/[email protected]: This module has been renamed to @google-cloud/debug-agent, please use that instead.
    warning @google/cloud-debug > google-auth-library > request > [email protected]: Use uuid module instead`
0
votes

The Stackdriver Debugger npm package has been renamed to @google-cloud/debug-agent and you need to use the newly introduced isReady function to make it work reliably on Google Cloud Functions.

Check out the solution here: https://medium.com/@thoughtspeed7/stackdriver-debugger-on-google-cloud-functions-d49a6ee5f12c