问题描述
我跑了
然后跑
所以我可以调试addMessage函数.但是调试无法正常工作.
So I could debug the addMessage function. Debugging however did not work.
运行
已经工作了,可以调试了,但是它似乎不支持热重装.
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());
});
});
推荐答案
尝试: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
functions-framework只是从工作目录(这里为目标函数的index.js文件)扩展到已安装的function-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\"}
- https://github.com/GoogleChromeLabs/ndb
- https://cloud.google.com/functions/docs/functions-framework
- https://github.com/GoogleCloudPlatform/functions-framework-nodejs /issues/15
- https://github.com/GoogleChromeLabs/ndb
- https://cloud.google.com/functions/docs/functions-framework
- https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/15
这篇关于firebase的服务和调试功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!