Firebase 服务和调试功能?



我跑了

火力基地服务 --仅功能

然后跑了

函数检查添加消息

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

运行

Firebase deploy addMessage --trigger-http 火力基地检查添加消息

确实有效并允许我调试,但它似乎不支持热重载。

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

我的索引.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

调试器断点命中时堆栈跟踪可见,请注意,它有点慢,因此请让调试器有时间检测子进程

此外,我还能够单独调试云函数,使用(删除值的大写字母(:

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

其中 functions-framework 只是从 index.js 文件用于目标函数的工作目录中扩展到已安装的函数框架的完整路径(在我的例子中是全局的(。

或者,在需要FIREBASE_CONFIG的时间或地点尝试调整以下格式以适应: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

从 Firebase-tools v7.11.0 开始,Firebase 模拟器现在支持使用--inspect-functions选项附加调试器。此答案显示了特定于 WebStorm 的说明,这些指令可以轻松适应其他调试器。

最新更新