簡體   English   中英

部署 firebase 雲函數時創建函數項目失敗

[英]Failed to create function project when deploying firebase cloud function

我正在嘗試從我的本地機器部署 firebase 函數

我運行以下代碼:

firebase deploy --only functions  

我收到這個錯誤。

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (95.46 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: creating Node.js 14 function messageNotification(us-central1)...
⚠  functions: failed to create function projects/xxx/locations/us-central1/functions/messageNotification

沒有任何錯誤信息。 它只是說函數創建失敗。 有誰知道為什么? 提前致謝!

編輯

我按照約翰漢利的建議跑了

firebase deploy --debug --only functions

並收到以下錯誤消息

[2021-08-05T01:49:33.605Z] <<< HTTP RESPONSE 400 {"vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Thu, 05 Aug 2021 01:49:33 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2021-08-05T01:49:33.605Z] <<< HTTP RESPONSE BODY {"error":{"code":400,"message":"The request has errors","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"event_trigger","description":"Expected value channels/{channelId}/{messageId} to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*"}]}]}}

我意識到我編寫函數的方式是錯誤的。 我在寫它

export const messageNotification = functions.firestore
    .document("channels/{channelId}/{messageId}")...

但我應該把它寫成如下所示

export const messageNotification = functions.firestore
    .document("channels/{channelId}/messages/{messageId}")

要調試部署,請嘗試兩種技術:

添加命令行選項--debug "

firebase deploy --debug --only functions

檢查日志中的消息:

firebase functions:log

確保在定義文檔觸發器時使用正確選擇的文檔形式

.document("Collection/{documentID}/nestedCollection/{nestedDocumentId}")

暫無
暫無

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

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