javascript - firebase 服务和调试功能?
问题描述
我跑了
firebase 服务 --only-functions
然后跑了
函数检查 addMessage
所以我可以调试 addMessage 函数。然而,调试并没有奏效。
跑步
firebase deploy addMessage --trigger-http firebase inspect addMessage
确实工作并允许我调试,但它似乎不支持热重载。
是否可以同时进行热重载和调试?
我的 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());
});
});
解决方案
尝试:ndb firebase serve
调试器断点被可见的堆栈跟踪命中,请注意它有点慢,所以给调试器时间来检测子进程
此外,我能够使用(删除值的上限)单独调试云函数:
GCLOUD_PROJECT=THE-FIREBASE-PROJECT node --inspect-brk /path/to/functions-framework --target FUNCTION-NAME --port=5000
其中 functions-framework 只是从 index.js 文件用于目标函数的工作目录扩展为已安装的 functions-framework (在我的情况下为全局)的完整路径。
或者,在需要 FIREBASE_CONFIG 的时间或地点尝试调整此格式以适应:
FIREBASE_CONFIG="{\"databaseURL\":\"https://YOUR-FIREBASE-PROJECT.firebaseio.com\",\"storageBucket\":\"YOUR-FIREBASE-PROJECT.appspot.com\",\"projectId\":\"YOUR-FIREBASE-PROJECT\"}
推荐阅读
- javascript - Jest 测试在 Github Action 上失败但在本地通过
- git - 为什么 git merge --no-commit 在我取消暂存时向我的历史记录添加了提交?
- javascript - Nodemailer 不适用于反应联系表
- html - 元素未正确定位
- java - Spring Batch 两次执行作业
- google-sheets - 如何从 Google 表格中的数据集创建新表?
- ipfs - IPFS:MFS 中的符号链接
- c - C99:访问全局变量和别名内存指针时的编译器优化
- powershell - 如何防止 PowerShell 脚本中的尾随换行符?
- three.js - 为什么三个 js 精灵上的换行符 '\n' 不起作用?