node.js - 从工件中删除旧文件后无法部署云功能

标签 node.js firebase google-cloud-functions

由于 us.artifacts.<project-id>,自今年年初以来,托管在 Firebase 上的我的 Angular 网站开始收取云存储费用。桶。

昨天,我检查了存储使用情况,发现云存储中存储了约 800MB 以上的数据。默认存储桶是空的,我没有在上面存储任何东西。因此,所有这 800MB 的存储空间都被函数构建使用了。

我在项目中有 2 个 Node 10 函数(和 2 个 Node 8 函数)。 Node 8 功能已弃用,但已于去年部署。它不会使用 us.artifacts桶。

正在关注 Doug's answer和评论,

The dates of the files correspond to the dates of deployment. It should not be hard to figure out which ones are old enough to delete. – Doug Stevenson Sep 15 '20 at 3:56

我昨天部署了这两个功能,并从存储桶中删除了之前日期的文件。从那以后,我无法同时部署这两个功能。

这是我到目前为止尝试过的方法。

  1. 等待 8-10 小时并尝试重新部署 - 失败。
  2. 从 Firebase 功能仪表板中删除了这两个功能并再次部署 - 失败。
  3. 从 firebase 仪表板中删除了这两个函数,确认它不存在于 Google Cloud 函数列表中,同时删除了这两个函数 us.artifacts<project-id>gcf-sources-<id>来自谷歌云的桶。然后将功能部署为新功能 - 失败。
  4. 完成第 3 步中的所有操作(部署除外),然后重命名这两个函数并再次尝试部署 - 失败。
  5. 从头开始在 CircleCI 上重新运行之前成功的工作流程 - 失败。

这是部署日志

functions: Finished running predeploy script. functions: ensuring

required API cloudfunctions.googleapis.com is enabled... 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

functions: preparing functions directory for uploading... functions:

packaged functions (39.63 KB) for uploading functions: functions

folder uploaded successfully functions: current functions in project:

sendEnquiryMessage(us-central1), ssr(us-central1) functions: uploading

functions in project: api(us-central1) functions: creating Node.js 10

function api(us-central1)... functions[api(us-central1)]: Deployment
error. Function failed on loading user code. This is likely due to a
bug in the user code. Error message: Error: please examine your
function logs to see the error cause:
https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs.
Additional troubleshooting documentation can be found at
https://cloud.google.com/functions/docs/troubleshooting#logging.
Please visit https://cloud.google.com/functions/docs/troubleshooting
for in-depth troubleshooting documentation.

Functions deploy had errors with the following functions:
api

Firebase 控制台上的错误显示无法加载用户代码。

enter image description here

我将 CircleCI 用于 CI/CD,甚至重新运行以前成功的工作流程也无法引发此错误。

这是 CircleCI 重新运行之前工作流程的屏幕截图

enter image description here

注意:我将 TypeScript 用于云功能。

最佳答案

问题已解决。这是我遵循的步骤。

  1. 在 functions/package.json 中将 Node 版本从 10 更改为 12
  2. 从 firebase 仪表板中删除了函数(即使部署失败,您也可以在仪表板中看到名称)。
  3. 已删除 us.artifacts.<project-id>gcf-sources-<id>来自存储的桶。
  4. 再次部署。

Node 版本变更后功能部署成功

关于node.js - 从工件中删除旧文件后无法部署云功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67353157/

相关文章:

javascript - Node.js Touchless (XCOPY) 在 Windows 上安装

typescript - 是否可以在服务器发送的事件之间添加延迟?

firebase函数:shell onWrite property undefined

javascript - 为什么 es6 中的 import 在这里不起作用?

javascript - 使用 Strongloop 环回实现 Q

javascript - SPA - Firebase 和 .Net WebApi 2 身份验证

android - 通知图标应用程序背景android

node.js - 通过云函数将数据从firebase数据库写入文件?

node.js - 如何在 Node.js 中编写同步函数

java - 在应用程序本身中实现 Firebase 安全规则有什么问题?