Firebase CF 仪表板中出现“某些功能无法加载”错误消息

问题描述 投票:0回答:1

以下 typescript 函数根据 Firebase CLI 部署成功,但根据仪表板部署失败。

import * as functions from 'firebase-functions';

export const helloWorld = functions.https.onRequest((request, response) => {
  response.send("hello world");
});

这是我的控制台日志:

filippo@MacBook-Air-di-Filippo Cloud Functions % firebase deploy --only functions

=== Deploying to 'my-project-00000'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> lint
> eslint --ext .js,.ts .

Running command: npm --prefix "$RESOURCE_DIR" run build

> build
> tsc

✔  functions: Finished running predeploy script.
i  functions: preparing codebase default for deployment
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: Loading and analyzing source code for codebase default to determine what to deploy
Serving at port 8313

i  functions: cleaning up build files...

✔  Deploy complete!

我主要遵循这些教程:https://youtu.be/2u6Zb36OQjM?si=qxZd8G2hyIFYNRjqhttps://firebase.google.com/docs/functions/get-started?gen=2nd

诚然,我的打字稿代码可能是问题所在。

环境

Visual Studio 代码 1.88.1

节点20.12.0

ESLint 9.0.0

Firebase CLI 13.7.3

Safari 17.4.1 (macOS 14.4.1) 还有 Chrome 122.0.6261.94

MacBook Air M1 8GB

编辑

注意:我已联系 Firebase 支持人员,但他们可能已停止回复。

问这个问题没有问题,因为它总是包含对代码本身的担忧,如果问题得到解决,它可以为拥有该问题的人和 Firebase 支持人员节省时间。

在部署函数之前,我尝试从函数目录中运行 npm install,我还尝试登录和退出 Firebase CLI。

无论如何,如果我按照 Firebase 支持人员的建议运行

firebase --debug --only functions deploy
,以下内容会引起我的注意:

  1. [功能]服务帐户 IAM 检查错误,部署可能失败:HTTP 错误:404,未知服务帐户
  2. 已部署0个功能

但许多其他人也可能如此。如果您好奇的话,这是完整的控制台日志:

filippo@MacBook-Air-di-Filippo Cloud Functions % firebase --debug --only functions deploy
[2024-04-23T08:29:34.687Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2024-04-23T08:29:34.688Z] > authorizing via signed-in user ([email protected])
[2024-04-23T08:29:34.688Z] [iam] checking project my-project-00000 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2024-04-23T08:29:34.688Z] > refreshing access token with scopes: []
[2024-04-23T08:29:34.689Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[2024-04-23T08:29:34.689Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2024-04-23T08:29:35.398Z] <<< [apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 200
[2024-04-23T08:29:35.398Z] <<< [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2024-04-23T08:29:35.406Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project-00000:testIamPermissions [none]
[2024-04-23T08:29:35.406Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project-00000:testIamPermissions x-goog-quota-user=projects/my-project-00000
[2024-04-23T08:29:35.407Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project-00000:testIamPermissions {"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]}
[2024-04-23T08:29:35.557Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200
[2024-04-23T08:29:35.558Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000}
[2024-04-23T08:29:36.541Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project-00000:testIamPermissions 200
[2024-04-23T08:29:36.542Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project-00000:testIamPermissions {"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]}
[2024-04-23T08:29:36.543Z] >>> [apiv2][query] POST https://iam.googleapis.com/v1/projects/my-project-00000/serviceAccounts/[email protected]:testIamPermissions [none]
[2024-04-23T08:29:36.543Z] >>> [apiv2][body] POST https://iam.googleapis.com/v1/projects/my-project-00000/serviceAccounts/[email protected]:testIamPermissions {"permissions":["iam.serviceAccounts.actAs"]}
[2024-04-23T08:29:37.095Z] <<< [apiv2][status] POST https://iam.googleapis.com/v1/projects/my-project-00000/serviceAccounts/[email protected]:testIamPermissions 404
[2024-04-23T08:29:37.095Z] <<< [apiv2][body] POST https://iam.googleapis.com/v1/projects/my-project-00000/serviceAccounts/[email protected]:testIamPermissions {"error":{"code":404,"message":"Unknown service account","status":"NOT_FOUND"}}
[2024-04-23T08:29:37.096Z] [functions] service account IAM check errored, deploy may fail: HTTP Error: 404, Unknown service account {"name":"FirebaseError","children":[],"context":{"body":{"error":{"code":404,"message":"Unknown service account","status":"NOT_FOUND"}},"response":{"statusCode":404}},"exit":1,"message":"HTTP Error: 404, Unknown service account","status":404}

=== Deploying to 'my-project-00000'...

i  deploying functions 
Running command: npm --prefix "$RESOURCE_DIR" run lint

> lint
> eslint --ext .js,.ts .

Running command: npm --prefix "$RESOURCE_DIR" run build

> build
> tsc

✔  functions: Finished running predeploy script. 
[2024-04-23T08:29:42.019Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/my-project-00000 [none]
[2024-04-23T08:29:42.669Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/my-project-00000 200
[2024-04-23T08:29:42.669Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/my-project-00000 {"projectId":"my-project-00000","projectNumber":"849399059679","displayName":"Hello Pizza","name":"projects/my-project-00000","resources":{"hostingSite":"my-project-00000"},"state":"ACTIVE","etag":"1_8d259d27-e405-4f7a-9cfa-87297ca89976"}
i  functions: preparing codebase default for deployment 
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled... 
i  functions: ensuring required API cloudbuild.googleapis.com is enabled... 
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled... 
[2024-04-23T08:29:42.673Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudfunctions.googleapis.com [none]
[2024-04-23T08:29:42.673Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudfunctions.googleapis.com x-goog-quota-user=projects/my-project-00000
[2024-04-23T08:29:42.675Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/runtimeconfig.googleapis.com [none]
[2024-04-23T08:29:42.676Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/runtimeconfig.googleapis.com x-goog-quota-user=projects/my-project-00000
[2024-04-23T08:29:42.677Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudbuild.googleapis.com [none]
[2024-04-23T08:29:42.677Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudbuild.googleapis.com x-goog-quota-user=projects/my-project-00000
[2024-04-23T08:29:42.678Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/artifactregistry.googleapis.com [none]
[2024-04-23T08:29:42.678Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/artifactregistry.googleapis.com x-goog-quota-user=projects/my-project-00000
[2024-04-23T08:29:44.092Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/runtimeconfig.googleapis.com 200
[2024-04-23T08:29:44.093Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/runtimeconfig.googleapis.com [omitted]
[2024-04-23T08:29:44.094Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/artifactregistry.googleapis.com 200
[2024-04-23T08:29:44.094Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/artifactregistry.googleapis.com [omitted]
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled 
[2024-04-23T08:29:44.111Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudfunctions.googleapis.com 200
[2024-04-23T08:29:44.111Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudfunctions.googleapis.com [omitted]
✔  functions: required API cloudfunctions.googleapis.com is enabled 
[2024-04-23T08:29:44.187Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudbuild.googleapis.com 200
[2024-04-23T08:29:44.187Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project-00000/services/cloudbuild.googleapis.com [omitted]
✔  functions: required API cloudbuild.googleapis.com is enabled 
[2024-04-23T08:29:44.188Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/my-project-00000/adminSdkConfig [none]
[2024-04-23T08:29:44.478Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/my-project-00000/adminSdkConfig 200
[2024-04-23T08:29:44.478Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/my-project-00000/adminSdkConfig {"projectId":"my-project-00000","storageBucket":"my-project-00000.appspot.com"}
[2024-04-23T08:29:44.478Z] >>> [apiv2][query] GET https://runtimeconfig.googleapis.com/v1beta1/projects/my-project-00000/configs [none]
[2024-04-23T08:29:45.120Z] <<< [apiv2][status] GET https://runtimeconfig.googleapis.com/v1beta1/projects/my-project-00000/configs 200
[2024-04-23T08:29:45.120Z] <<< [apiv2][body] GET https://runtimeconfig.googleapis.com/v1beta1/projects/my-project-00000/configs {}
[2024-04-23T08:29:45.123Z] Validating nodejs source
[2024-04-23T08:29:45.853Z] > [functions] package.json contents: {
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "18"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^11.8.0",
    "firebase-functions": "^4.3.1"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^3.1.0",
    "typescript": "^4.9.0"
  },
  "private": true
}
[2024-04-23T08:29:45.853Z] Building nodejs source
i  functions: Loading and analyzing source code for codebase default to determine what to deploy 
[2024-04-23T08:29:45.854Z] Could not find functions.yaml. Must use http discovery
[2024-04-23T08:29:45.861Z] Found firebase-functions binary at '/Users/filippo/Library/Mobile Documents/com~apple~CloudDocs/Cloud Functions/functions/node_modules/.bin/firebase-functions'
Serving at port 8882

[2024-04-23T08:29:45.999Z] Got response from /__/functions.yaml {"endpoints":{},"specVersion":"v1alpha1","requiredAPIs":[]}
[2024-04-23T08:29:51.017Z] >>> [apiv2][query] GET https://cloudfunctions.googleapis.com/v1/projects/my-project-00000/locations/-/functions [none]
[2024-04-23T08:29:51.932Z] <<< [apiv2][status] GET https://cloudfunctions.googleapis.com/v1/projects/my-project-00000/locations/-/functions 200
[2024-04-23T08:29:51.932Z] <<< [apiv2][body] GET https://cloudfunctions.googleapis.com/v1/projects/my-project-00000/locations/-/functions {}
[2024-04-23T08:29:51.935Z] >>> [apiv2][query] GET https://cloudfunctions.googleapis.com/v2/projects/my-project-00000/locations/-/functions filter=environment%3D%22GEN_2%22
[2024-04-23T08:29:53.026Z] <<< [apiv2][status] GET https://cloudfunctions.googleapis.com/v2/projects/my-project-00000/locations/-/functions 200
[2024-04-23T08:29:53.027Z] <<< [apiv2][body] GET https://cloudfunctions.googleapis.com/v2/projects/my-project-00000/locations/-/functions {}
[2024-04-23T08:29:53.037Z] Total Function Deployment time: 0
[2024-04-23T08:29:53.037Z] 0 Functions Deployed
[2024-04-23T08:29:53.037Z] 0 Functions Errored
[2024-04-23T08:29:53.037Z] 0 Function Deployments Aborted
[2024-04-23T08:29:53.037Z] Average Function Deployment time: NaN
i  functions: cleaning up build files... 

✔  Deploy complete! 

Project Console: https://console.firebase.google.com/project/my-project-00000/overview

如何查明问题?

google-cloud-functions
1个回答
2
投票

将此作为社区维基共享以造福他人

正如@Doug Stevenson 提到的

右上角的控制台屏幕截图上有一条错误消息。这似乎掩盖了根本问题。如果您遇到不理解的控制台问题,请直接联系 Firebase 支持人员,因为这里的志愿者对此无能为力。

此外,您还可以执行以下故障排除选项:

  • 查看 Firebase 日志。您也可以通过控制台、Cloud Logging UI 或 firebase CLI 查看日志

  • 查看此Stackoverflow 帖子。您可以在部署函数之前在函数目录中运行

    npm install

  • 您可以联系 Firebase 支持进一步调查您的案例。

© www.soinside.com 2019 - 2024. All rights reserved.