gpt4 book ai didi

firebase - 部署functions.pubsub.schedule时如何修复创建函数失败

转载 作者:行者123 更新时间:2023-12-05 00:10:49 24 4
gpt4 key购买 nike

当我尝试在 index.js 上像这样部署 functions.pubsub.schedule 时:

const functions = firebase.functions;
var cronCount = 0;
exports.processPostsCron = functions.pubsub.schedule('* * * *
*').onRun(context => {
cronCount++;
console.log(`### this runs every minute. count: ${cronCount}`);
});

发生了错误:

函数:未能创建函数 processPostsCron
HTTP 错误:400,请求有错误

我该如何解决这个错误,还是我做错了?
我指的是这个 https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js

我正在使用 firebase-admin@7.0.0 firebase-functions@2.3.1 .

编辑1:

调试结果:
i  functions: creating Node.js 8 function processPostsCron(us-central1)...
[2019-05-29T17:19:41.712Z] Trigger is: {"eventTrigger":{"resource":"projects/ticktock-d34b6/topics","eventType":"google.pubsub.topic.publish","service":"pubsub.googleapis.com"}}
[2019-05-29T17:19:41.714Z] >>> HTTP REQUEST POST https://cloudfunctions.googleapis.com/v1/projects/ticktock-d34b6/locations/us-central1/functions
sourceUploadUrl=https://storage.googleapis.com/gcf-upload-us-central1-f74bb5e4-12fb-4381-9f5a-ba9e11a921a8/2fac50ef-9d15-4390-8836-21209adfa8b4.zip?GoogleAccessId=service-1096541131355@gcf-admin-robot.iam.gserviceaccount.com&Expires=1559152179&Signature=EzcN7sYYs05vuTyVu7%2BMyJGU8viklA5VWPZRmMeASBCmlK6Xl%2BtMhL1G%2Fv4JHempDcLJ3FmvLDGPbar1iP%2BtNiApL%2B%2Fn6wjQINbF4CmpmqKnjxieBqpzkRYUD40zNMyCGbRDnkhcsps6DBpI9reiHvxdKkqYqadBPCaCn10nZwo96zaHcxZYHWg5PIo4cPLoPyOI7PTl4WYdwwt%2FzOHKlQSdyh1VuRgZqwfgy0vgDQR9HY846k0Tkg6RB6fGex8MzysUxiZ4RfPdt1i0LGd1KpY%2ByhG0OlEsMODQY3bBQ4TMh6LNbVyC2s9%2F0wJPkzAdJpnTjarf3hOgsF9908VkOg%3D%3D, name=projects/ticktock-d34b6/locations/us-central1/functions/processPostsCron, entryPoint=processPostsCron, deployment-tool=cli-firebase, deployment-scheduled=true, runtime=nodejs8, resource=projects/ticktock-d34b6/topics, eventType=google.pubsub.topic.publish, service=pubsub.googleapis.com
[2019-05-29T17:19:42.141Z] <<< HTTP RESPONSE 400 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Wed, 29 May 2019 17:19:42 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,44,43,39", accept-ranges=none, connection=close
[2019-05-29T17:19:42.141Z] <<< HTTP RESPONSE BODY code=400, message=The request has errors, status=INVALID_ARGUMENT, details=[@type=type.googleapis.com/google.rpc.BadRequest, fieldViolations=[field=pubsub_topic, description=Pub/Sub topic name projects/ticktock-d34b6/topics does not match the expected pattern]]
⚠ functions: failed to create function processPostsCron
HTTP Error: 400, The request has errors


Functions deploy had errors with the following functions:
processPostsCron


To try redeploying those functions, run:
firebase deploy --only functions:processPostsCron


To continue deploying other features (such as database), run:
firebase deploy --except functions

Error: Functions did not deploy properly.

似乎错误发生在:
fieldViolations=[field=pubsub_topic, description=Pub/Sub topic name projects/ticktock-d34b6/topics does not match the expected pattern]]

最佳答案

Firebase 支持给了我更新 CLI 的说明,更新后一切都很好。这是命令:

npm install -g firebase-tools@latest

起初它对我不起作用,我添加了“不安全烫发”选项以继续:
npm install -g firebase-tools@latest --unsafe-perm

关于firebase - 部署functions.pubsub.schedule时如何修复创建函数失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56364108/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com