Reputation: 1816
successfully configured firestore cloud functions in local.
able to run the functions locally using below command.
firebase var data = require('./data'); wChangedEvent(data.default);
... ... printing whatever console.log there in wChangedEvent. So this is working properly.
But i need to attach debugger in visual studio code. I tried with below configuration.
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 3535,
"protocol": "inspector"
},
But it is not working.
Upvotes: 2
Views: 1187
Reputation: 4785
As of late 2020, this pull request added support for the --inspect-functions
flag.
firebase functions:shell --inspect-functions
Unless you explicitly provide another, it will open the default node debugger port 9229
.
With Jetbrains IDEs you can attach to the running process by using an "Attach to Node.js/Chrome" run configuration.
Upvotes: 5
Reputation: 4874
You can use the functions emulator. There is ver little documentation, but this is a good start: https://firebase.google.com/docs/functions/config-env
$ npm install -g @google-cloud/functions-emulator`
$ functions start
$ functions deploy api --trigger-http --timeout 600s
$ functions inspect api --port 9229
Create a VS Launce config:
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
}
Now you can F5 to start debugging.
This will not receive triggers from your database automatically, but it still very helpful as you can use an http request to trigger functions and debug them.
Tip: add this script to your package.json
so you can easily npm run debug
to build and deploy to the emulator:
"scripts": {
...
"debug": "npm run build && functions deploy api --trigger-http --timeout 600s && functions inspect api --port 9229"`
}
Upvotes: -1