Remote Debugging with Forge is possible

Hi there,

I recently discovered a simple way to remote debug your running forge app. I wanted to share this information with you, because I did not find anything about that on the public Forge Debugging page. (I am wondering why)

  1. To use remote debugging start your forge tunnel with the option --debug:
forge tunnel --debug
  1. Place the debugger; statement in your backend app code where you want the debugger to step into.
  2. Open the Chrome devtools by visiting the following URL:
devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:8000 

That’s it. You will see all debug data in the Chrome devtools when your app code is processed.

@Atlassian Maybe you should add this to your public Forge Debugging documentation.

Happy debugging.
Sven

6 Likes

Great find! I’ve opened a PR to add this to the Tunneling docs.

2 Likes

Great tipp/initiative, given that’s a long available but rarely known and used DX feature indeed - here’s a small video snippet from June 2020 where @mventnor showcases the debug flag:

2 Likes

I’ve added a new section (full content :point_down: ) to Tunneling and it has been merged so should go live soon(ish?) :partying_face:


Interactive debugging

The forge tunnel command accepts a --debug flag that will allow you to perform remote debugging
in Chrome’s DevTools and will pause execution when a debugger;
statement is found. The debugger; is a special statement that invokes any available debugging
functionality, such as setting a breakpoint. The debugger; statement will be ignored if you’re
not tunnelling in debug mode.

When you run tunnel with the --debug flag, you’ll be prompted with a message similar to the
following:

Chrome inspector URL (add “debugger;” statement to your app to pause):
devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:8000

Opening the provided inspector URL, your app will now pause on any debugger; breakpoints you add
in your code.

This is a great way to interactively debug your application within the context of the breakpoint.

4 Likes

[FRGE-610] - Ecosystem Jira is now SOLVED with the next cli release

npm install -g  @forge/cli@3.0.1-next.6
1 Like