【问题标题】:Failed to create function project when deploying firebase cloud function部署firebase云功能时创建功能项目失败
【发布时间】:2023-04-01 10:10:02
【问题描述】:

我正在尝试从本地机器部署 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}")

【问题讨论】:

  • 您在日志中看到什么了吗?**firebase 函数:log** 2) 尝试 firebase deploy --debug --only 函数
  • 嘿@JohnHanley,我运行了该代码并设法解决了问题。我已经编辑了我的问题,如上所示。如果需要,您可能希望将评论移至建议的答案。我会将其标记为正确答案。谢谢!

标签: firebase flutter google-cloud-platform google-cloud-functions


【解决方案1】:

要调试部署,请尝试两种技术:

添加命令行选项--debug"

firebase deploy --debug --only functions

检查日志中的消息:

firebase functions:log

【讨论】:

    猜你喜欢
    • 2022-09-12
    • 2020-10-19
    • 2018-08-05
    • 2021-12-29
    • 2022-09-01
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    相关资源
    最近更新 更多