Firebase 托管部署错误:任务 5fc ... 失败:6 次尝试后重试用尽

dou*_*mes 4 firebase reactjs firebase-hosting google-cloud-firestore firebase-cli

我正在尝试为生产和开发环境使用 Firestore、Functions、Storage 和 Hosting 设置 2 个全新的 Firebase 项目。我首先删除对旧 firebase 项目的引用: both firebase.json& .firebaserc。然后我跑去$ firebase init使用testFirebase 项目设置 Hosting、Functions、Storage 和 Firestore 。然后我设置 Firebase 别名以$ firebase use --add 在一个 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"
  }
}
Run Code Online (Sandbox Code Playgroud)

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"
  }
}

Run Code Online (Sandbox Code Playgroud)

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

   === 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
Run Code Online (Sandbox Code Playgroud)

小智 7

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


dou*_*mes 2

--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]. 在这篇文章之后,我做了一些改变:

"hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
Run Code Online (Sandbox Code Playgroud)

"hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
Run Code Online (Sandbox Code Playgroud)

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