firebase serve and debugging functions?

后端 未结 2 1644
庸人自扰
庸人自扰 2020-12-19 17:19

I ran

firebase serve --only-functions

Then ran

functions inspect addMessage

So I

相关标签:
2条回答
  • 2020-12-19 17:57

    As of firebase-tools v7.11.0, the Firebase emulator now supports attaching a debugger with the --inspect-functions option. This answer shows WebStorm-specific instructions that can be easily adapted to other debuggers.

    0 讨论(0)
  • 2020-12-19 18:14

    try: ndb firebase serve

    debugger breakpoints are hit with stack traces visible, note it's a little slow so give the debugger time to instrument the child processes

    Additionally I was able to debug cloud functions in isolation using (caps for removed values):

    GCLOUD_PROJECT=THE-FIREBASE-PROJECT node --inspect-brk /path/to/functions-framework --target FUNCTION-NAME --port=5000

    where functions-framework simply expands to the full path for the installed functions-framework (global in my case) from the working directory where the index.js file is for the target functions.

    Alternately when or where the FIREBASE_CONFIG is needed try this format adjusted to fit: FIREBASE_CONFIG="{\"databaseURL\":\"https://YOUR-FIREBASE-PROJECT.firebaseio.com\",\"storageBucket\":\"YOUR-FIREBASE-PROJECT.appspot.com\",\"projectId\":\"YOUR-FIREBASE-PROJECT\"}

    • https://github.com/GoogleChromeLabs/ndb
    • https://cloud.google.com/functions/docs/functions-framework
    • https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/15
    0 讨论(0)
提交回复
热议问题