簡體   English   中英

firebase 服務和調試功能?

[英]firebase serve and debugging functions?

我跑了

firebase serve --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\\"}

從 firebase-tools v7.11.0 開始,Firebase 模擬器現在支持使用--inspect-functions選項附加調試器。 這個答案顯示了 WebStorm 特定的指令,可以很容易地適應其他調試器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM