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)
To use remote debugging start your forge tunnel with the option --debug:
forge tunnel --debug
Place the debugger; statement in your backend app code where you want the debugger to step into.
Open the Chrome devtools by visiting the following URL:
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:
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.