本文介绍了firebase 服务和调试功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑了

firebase 服务 --only-functions

然后跑了

函数检查 addMessage

所以我可以调试 addMessage 函数.但是调试不起作用.

So I could debug the addMessage function. Debugging however did not work.

运行

firebase 部署 addMessage --trigger-httpfirebase 检查 addMessage

确实可以调试,但它似乎不支持热重载.

Did work and allow me to debug but it doesn't seem to support hot reloading.

是否可以同时进行热重载和调试?

Is it possible to have hot reloading and debugging working at the same time?

我的 index.js:

My index.js:

const functions = require('firebase-functions');

// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
admin.initializeApp();

exports.addMessage = functions.https.onRequest((req, res) => {
    // Grab the text parameter.
    const original = "123";//req.query.text;
    // Push the new message into the Realtime Database using the Firebase Admin SDK.
    return admin.database().ref('/messages').push({original: original}).then((snapshot) => {
      // Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
      return res.redirect(303, snapshot.ref.toString());
    });
  });

推荐答案

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 节点 --inspect-brk/path/to/functions-framework --target FUNCTION-NAME --port=5000

其中functions-framework 只是从index.js 文件用于目标函数的工作目录扩展为已安装functions-framework(在我的情况下为全局)的完整路径.

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.

或者在需要 FIREBASE_CONFIG 的时间或地点尝试调整此格式以适应:FIREBASE_CONFIG="{"databaseURL":"https://YOUR-FIREBASE-PROJECT.firebaseio.com","storageBucket":"YOUR-FIREBASE-PROJECT.appspot.com","projectId":"YOUR-FIREBASE-PROJECT"}

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"}

这篇关于firebase 服务和调试功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 10:49