Firebase Functions debugging in Local VSCode.
When we’re debugging our code, making breakpoint is a necessity. And we can make breakpoint for debugging our Firebase Functions exactly same like common Nodejs project.
execute emulator with ‘inspect’ option
> firebase emulators:start --inspect-functions
Now, you can find a port for functions debugging.
add config into launch.json
add this into your ‘/.vscode/launch.json’
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Functions",
"port": 9229
}
]
}
and execute.
Now your breakpoint is activated and work.
Alternative.
Remove this. And turn on ‘Auto Attach’
and Execute.
> firebase emulators:start --inspect-functions
Your VSCode automatically connects the inspection port. and Debugging mode activated.
Fixing for problems
If your debug connection been broken, and you’d faced with this error.
Error activating auto attach, please report to https://aka.ms/js-dbg-issue
try this another launch configuration.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"restart": true,
"skipFiles": [
"<node_internals>/**"
]
}
]
}
[ “restart”: true ] this option will make a try when the connection is broken.