Debugging an application

Debugging your Cloud Run application

To debug your application, follow these steps:

  1. Use the Cloud Code status bar and select Debug on Cloud Run Emulator to run your application and attach a debugger session to it.
  2. This launches the Run/Debug on Cloud Run Emulator dialog where you can set the specifications for your configuration. Run/Debug on Cloud Run Emulator UI
  3. Optionally, you can further customize how your application is run by specifying your environment variables and directly defining fields in your launch.json.
  4. Click 'Debug' to begin debugging your application.
  5. For each debuggable container in your application, you'll be prompted to confirm or enter the directory in the remote container where the program you'd like to debug is found.

    Alternatively, you can press ESC to skip debugging the container.

    Remote Root prompt

    Cloud Code will attach a debug session for each debuggable container in the application.

  6. Click in the editor margin of the file you are debugging to add a breakpoint.

    Red filled circles denote active breakpoints, while gray hollow circles signify disabled breakpoints. For finer breakpoint control, you can use the Breakpoints section in VS Code's Debug view.

    Breakpoints section in the left hand panel of Debug View that allows adding, removing, and disabling breakpoints

    When you send a new request to your application, it will pause at that desired line.

  7. (Optional) To inspect variables and stack info, use the Debug Sidebar. To interact with the debugging session, use the Debug Console in the bottom pane debugger.

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.