【问题标题】:Firebase Hosting Deploy Error: Task 5fc... failed: retries exhausted after 6 attemptsFirebase 托管部署错误:任务 5fc... 失败:6 次尝试后重试已用尽
【发布时间】:2020-06-27 04:52:00
【问题描述】:

我正在尝试为生产和开发环境设置 2 个全新的 Firebase 项目,其中包含 Firestore、Functions、Storage 和 Hosting。我首先删除了对旧 firebase 项目的引用:firebase.json.firebaserc。然后我运行$ firebase init 以使用test Firebase 项目设置托管、功能、存储和Firestore。然后,我使用 $ firebase use --add 设置 Firebase 别名,以便在一个 React.js 项目中的两个项目之间切换。我 npm 构建并尝试使用:$ firebase deploy --project:test 进行部署,但主机不断尝试相同的最后一个文件并失败:Error: Task 5fcd... failed: retries exhausted after 6 attempts.

我已经看到一些与服务器暂时关闭有关的 Stackoverflow 答案,但我没有看到他们方面的任何服务器问题 (https://status.firebase.google.com/),而且这种情况以前一直存在。在我从事的另一个项目中,我试图在同一个 Firebase 项目上部署到 2 个托管目标,但是一个失败,另一个工作正常,我遇到了同样的错误(我从来没有找到另一个解决方案而不是不使用多个目标。)

我还可以测试什么来使其正常工作?它在我的 React.js 代码库中吗? (我最近部署到我过去的项目中)也许这与我的 Firebase 设置过程有关?还是与旧的 Firebase 项目仍有联系?我不知道接下来该看什么来解决这个问题。任何方向都会很棒,谢谢!

Ps:可能无法连接的奇怪之处在于,如果我只运行$ firebase deploy,它不会部署firebaserc 中定义的默认测试环境,而是部署实时测试环境?

.firebaserc:

{
  "projects": {
    "default": "test-app-tech",
    "test": "test-app-tech",
    "live": "live-app-tech"
  }
}

firebase.json:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build"
  },
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "storage": {
    "rules": "storage.rules"
  }
}

完整的控制台日志: (不知道比控制台更长的日志文件在哪里)

   === Deploying to 'test-app-tech'...

i  deploying storage, firestore, functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build C:\Users\me\Documents\GitHub\react.app.tech\functions
> tsc

+  functions: Finished running predeploy script.
i  firebase.storage: checking storage.rules for compilation errors...
+  firebase.storage: rules file storage.rules compiled successfully
i  firestore: reading indexes from firestore.indexes.json...
i  cloud.firestore: checking firestore.rules for compilation errors...
+  cloud.firestore: rules file firestore.rules compiled successfully
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  storage: latest version of storage.rules already up to date, skipping upload...
i  firestore: uploading rules firestore.rules...
+  firestore: deployed indexes in firestore.indexes.json successfully
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (80.39 KB) for uploading
+  functions: functions folder uploaded successfully
i  hosting[test-app-tech]: beginning deploy...
i  hosting[test-app-tech]: found 32 files in build
⠸  hosting: uploading new files [0/1] (0%)
Error: Task 5fcd5c559ded0c02b3ed7840ca3ee77e95b798730af98d9f18bc627ac898071e failed: retries exhausted after 6 attempts

【问题讨论】:

  • 如果您在使用 CLI 部署时遇到问题,并且错误消息不可操作,请联系 Firebase 支持。 support.google.com/firebase/contact/support
  • @DougStevenson 我会试一试,谢谢!
  • 网络不好的时候发生在我身上

标签: reactjs firebase google-cloud-firestore firebase-hosting firebase-cli


【解决方案1】:

对我来说,问题是每隔几分钟就会断开连接。我能够通过重复上传过程来上传我的文件。坐在电脑前手动重复是行不通的,所以在我的根文件夹中添加了一个 bash 脚本以循环重试错误。

创建文件 deploy_staging.sh 或 deploy_production.sh 等:

#!/bin/bash
trap "exit" INT
firebase use my_project_name
until firebase deploy  --only hosting:my_project; do
  echo Transfer disrupted, retrying in 3 seconds...
  sleep 3
done

(*trap "exit" INT 允许在需要时通过 ctrl-c 中断循环)

在文件所在目录下,在终端命令行,运行chmod +x my_file_name.sh,使文件可执行。

在终端中使用./my_file_name.sh 运行文件。它将重新运行firebase deploy:production,直到文件上传完毕。

【讨论】:

    【解决方案2】:

    发生这种情况有两个原因。

    1. 通过删除根文件夹中的 .firebase 文件夹将解决问题。 如果这不起作用,
    2. 您的 Internet 连接速度可能会变慢,并且项目中的文件大小可能会更大。所以请尝试使用快速的互联网连接。

    在网络速度较慢的情况下,如果您一次又一次地尝试部署,您会看到控制台上上传的文件数量减少了。这意味着您的文件正在上传,但花费了太多时间,并且 firebase 已经耗尽。

    【讨论】:

    • 并非如此,文件总数根本没有变化。删除 firebase 文件夹也不起作用。这个问题也在回购中,目前还没有机构有确切的解决方案。
    【解决方案3】:

    删除 .firebase 文件夹中的内容并尝试重新部署。

    【讨论】:

    • 这个方法真的可以部署我的站点。谢谢
    【解决方案4】:

    角度 道格拉斯回答的是解决方案,在 angular.json 中,您将“托管:”dist “”更改为“托管:”公共“”。 然后你再次运行firebase deploy,这会给你一个错误,但别担心,去改变你在angular.json中修改的内容,然后再次运行firebase deploy,瞧!对我有用

    【讨论】:

      【解决方案5】:

      通过附加--debug 后缀进行更深入的探索,这给了我:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined。探索了这个,并试图修复,但没有奏效。我删除了/node_modules/package-lock.json/build/,重新安装了软件包,部署了它,它工作了。不知道是什么修复了它,因为我之前删除了这些文件无济于事。我做了其他一些看似无关的小改动,谁知道可能已经连接,但它现在可以工作了!

      更新:我必须真正找到这个错误,因为我的生产环境也有同样的问题,并将其缩小到我探索TypeError [ERR_INVALID_ARG_TYPE] 的步骤。跟着this post有点变化:

      "hosting": {
          "public": "build",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "rewrites": [
            {
              "source": "**",
              "destination": "/index.html"
            }
          ]
        },
      

      "hosting": {
          "public": "public",
          "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
          ],
          "rewrites": [
            {
              "source": "**",
              "destination": "/index.html"
            }
          ]
        },
      

      然后部署并通过,但实时服务器上没有显示任何内容,因为它当然没有查看构建文件夹。所以我把它改回指向构建而不是公共,然后再次部署并且它工作。奇怪的解决方案,发送给 Firebase 团队看看这里到底发生了什么。

      【讨论】:

      • 哇!多谢!你从几个小时的研究中拯救了我!
      猜你喜欢
      • 2019-06-08
      • 2020-01-14
      • 2019-08-26
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 2018-06-13
      • 1970-01-01
      相关资源
      最近更新 更多