-
Notifications
You must be signed in to change notification settings - Fork 113
Debugging with Chrome DevTools
Table of Contents
- The Chrome DevTools Debugger
- Debugging functions in
childprocessisolation mode - Debugging functions in
inprocessisolation mode - Additional Chrome DevTools reading
The Chrome DevTools are a set of web authoring and debugging tools built into Google Chrome. As of Node.js v6.3.1 you can use the DevTools to debug and profile your Node.js code.
In `childprocess isolation mode, functions are invoked in their own processes, separate from the main Emulator process. This is more secure and safer for the Emulator, but it means the debugger is started on function invocation.
-
Switch to
childprocessisolation mode.functions config set isolation childprocess -
Enable debugging:
functions config set inspect true -
Restart the Emulator:
functions restartYou should see something like the following printed to the console:
Inspect mode is enabled for the Supervisor. During function execution the debugger will listen on port 9229 and the Chrome debugging URL will be printed to the console. -
Deploy a function.
-
Call the function.
You should see something like the following printed to the console:
Function execution paused. Connect to the debugger on port 9229 (e.g. using the "node2" launch type in VSCode), or open the following URL in Chrome: chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/fae86ac1-2e59-46b8-9b08-3e997104662c -
Paste the printed
chrome-devtoolsURI into a new tab in Chrome. -
Script execution will be paused on the first line of the Emulator's
worker.jsfile.
TODO
- https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js
- https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
- https://mattdesl.svbtle.com/debugging-nodejs-in-chrome-devtools
- https://blog.hospodarets.com/nodejs-debugging-in-chrome-devtools
Disclaimer: This is not an official Google product.
@google-cloud/functions-emulator is currently in pre-1.0.0 development. Before the 1.0.0 release, backwards compatible changes and bug fixes will bump the patch version number and breaking changes will bump the minor version number.