sco*_*lee 13 firebase google-cloud-platform flutter google-cloud-functions
我正在尝试从本地计算机部署 firebase 功能
\n我运行以下代码:
\nfirebase deploy --only functions \nRun Code Online (Sandbox Code Playgroud)\n我收到这个错误。
\n\xe2\x9c\x94 functions: Finished running predeploy script.\ni functions: ensuring required API cloudfunctions.googleapis.com is enabled...\ni functions: ensuring required API cloudbuild.googleapis.com is enabled...\n\xe2\x9c\x94 functions: required API cloudbuild.googleapis.com is enabled\n\xe2\x9c\x94 functions: required API cloudfunctions.googleapis.com is enabled\ni functions: preparing functions directory for uploading...\ni functions: packaged functions (95.46 KB) for uploading\n\xe2\x9c\x94 functions: functions folder uploaded successfully\ni functions: creating Node.js 14 function messageNotification(us-central1)...\n\xe2\x9a\xa0 functions: failed to create function projects/xxx/locations/us-central1/functions/messageNotification\nRun Code Online (Sandbox Code Playgroud)\n没有任何错误消息。它只是指出该函数创建失败。有谁知道为什么?提前致谢!
\n编辑
\n我按照约翰·汉利的建议跑了
\nfirebase deploy --debug --only functions\nRun Code Online (Sandbox Code Playgroud)\n并收到以下错误消息
\n[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"}\n[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 [^/]+/[^/]+(/[^/]+/[^/]+)*"}]}]}}\nRun Code Online (Sandbox Code Playgroud)\n我意识到我编写函数的方式是错误的。我正在写它
\nexport const messageNotification = functions.firestore\n .document("channels/{channelId}/{messageId}")...\nRun Code Online (Sandbox Code Playgroud)\n但我应该写成如下所示
\nexport const messageNotification = functions.firestore\n .document("channels/{channelId}/messages/{messageId}")\nRun Code Online (Sandbox Code Playgroud)\n
Joh*_*ley 35
要调试部署,请尝试两种技术:
添加命令行选项--debug "
firebase deploy --debug --only functions
Run Code Online (Sandbox Code Playgroud)
检查日志中的消息:
firebase functions:log
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9162 次 |
| 最近记录: |