Firebase Hosting Deploy Error: Task 5fc... failed: retries exhausted after 6 attempts
Asked Answered
S

8

12

I am trying to setup a 2 brand new Firebase projects with Firestore, Functions, Storage, and Hosting for both Production and Development environments. I started with deleting the references to the old firebase project: both firebase.json & .firebaserc. I then ran $ firebase init to setup Hosting, Functions, Storage, and Firestore using the test Firebase project. I then setup Firebase aliases with $ firebase use --add to switch between the two projects within one React.js project. I npm built and am attempting to deploy with: $ firebase deploy --project:test, but the hosting keeps trying the same last file and fails with: Error: Task 5fcd... failed: retries exhausted after 6 attempts..

I've seen some Stackoverflow answers that relate to the servers being down temporarily, but I do not see any server problems on their side (https://status.firebase.google.com/) and this has persisted before. On another project I have worked on, I was trying to deploy to 2 hosting targets on the same Firebase project, but one was failing and the other was working fine, and I was getting this same error (I never found a solution to that other than not using multiple targets.)

What else can I test to get this working? Is it something inside my React.js code base? (I recently deployed to my past project) Maybe it has to do with my Firebase setup process? Or there is still a connection to the old Firebase project? I don't know what to look at next to fix this. Any direction would be great, thanks!

Ps: Something weird that might not be connected is that if I run just $ firebase deploy, it doesn't deploy the default test env defined in firebaserc, but the live test env?

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

Full console log: (not sure where a longer log file is than just the console)

   === 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
Sinful answered 16/3, 2020 at 3:0 Comment(3)
If you're having problems deploying with CLI, and the error message is not actionable, contact Firebase support. support.google.com/firebase/contact/supportCynosure
@DougStevenson I'll give that a shot, thanks!Sinful
it happend for me when internet is badSchaffner
S
2

Explored a bit deeper by appending --debug suffix, which gave me: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined. Explored this, and tried to fix, but didn't work. I deleted /node_modules/, package-lock.json, and /build/, reinstalled packages, deployed and it worked. Not sure what fixed it because I deleted those files before to no avail. I did a few other small, seemingly unrelated changed, which who knows might have been connected, but its working now!

UPDATE: I had to truly find the error with this since my production environment was having the same issue, and narrowed it down to the steps I took exploring the TypeError [ERR_INVALID_ARG_TYPE]. Following this post somewhat, I changed:

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

to

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

then deployed and it went through, but nothing is shown on the live server, because it isn't looking at the build folder of course. So I changed it back to point to build instead of public, and deployed again and it worked. Weird solution, sending to Firebase team to see what really happened here.

Sinful answered 17/3, 2020 at 5:40 Comment(2)
Wow! thanks a lot! You saved my from some hours of research!Badr
doesn't work for meLinea
J
51

Remove the content in .firebase folder and try to redeploy.

Johnnajohnnie answered 16/12, 2020 at 23:34 Comment(4)
This method really allowed to deploy my site. ThanksBrinn
this worked for me! anyone know why?Bartz
It's work, try this solution guys.Misgive
worked for me as wellJaffa
S
4

There are two reasons to happen this.

  1. by deleting .firebase folder in your root folder will solve problem. if this dosen't work,
  2. your internet connection may slow and size of files in your project may be bigger. so try with fast internet connection.

with slow internet, if you try deploying again and again, you will see that number of files uploading decreases on console. that means your files are getting uploaded, but it taking too much time, and firebase is getting exhausted.

Sectionalism answered 23/4, 2021 at 5:14 Comment(1)
Not really, the total number of files doesn't change at all. Deleting firebase folder does not work as well. This issue is in repo as well and no body has a exact solution as of now.Tandie
S
2

Explored a bit deeper by appending --debug suffix, which gave me: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined. Explored this, and tried to fix, but didn't work. I deleted /node_modules/, package-lock.json, and /build/, reinstalled packages, deployed and it worked. Not sure what fixed it because I deleted those files before to no avail. I did a few other small, seemingly unrelated changed, which who knows might have been connected, but its working now!

UPDATE: I had to truly find the error with this since my production environment was having the same issue, and narrowed it down to the steps I took exploring the TypeError [ERR_INVALID_ARG_TYPE]. Following this post somewhat, I changed:

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

to

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

then deployed and it went through, but nothing is shown on the live server, because it isn't looking at the build folder of course. So I changed it back to point to build instead of public, and deployed again and it worked. Weird solution, sending to Firebase team to see what really happened here.

Sinful answered 17/3, 2020 at 5:40 Comment(2)
Wow! thanks a lot! You saved my from some hours of research!Badr
doesn't work for meLinea
A
2

The problem for me was the connection dropping every few minutes. I was able to upload my files by repeating the upload process. It was not tenable to sit at the computer and repeat by hand, so in my root folder I added a bash script to retry on error in a loop.

Create file deploy_staging.sh or deploy_production.sh etc.:

#!/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

(*the trap "exit" INT allows interruption of the loop by ctrl-c if needed)

In the directory of the file, on the terminal command line, run chmod +x my_file_name.sh to make the file executable.

Run the file with ./my_file_name.sh in the terminal. It will rerun firebase deploy:production until the files are uploaded.

Allspice answered 9/9, 2021 at 12:3 Comment(0)
D
2

enter image description here

Delete file firebase cache and firebase deploy again

Divvy answered 19/6, 2022 at 11:52 Comment(0)
G
1

In ANGULAR What Douglas answered has been the solution, in angular.json you change the "hosting:" dist "" for "hosting:" public "". Then you run the firebase deploy again and that will give you an error, but don't worry, go change what you modified in angular.json and then run firebase deploy again and voila! that worked for me

Gagger answered 18/11, 2020 at 0:3 Comment(0)
L
1
 $env:FIREBASE_HOSTING_UPLOAD_CONCURRENCY=3

That's your ticket.

Linea answered 26/11, 2023 at 18:40 Comment(0)
P
0

If you have previously deployed the app to different firebase hosting site:

Quite likely the deployment failure was caused by the caching of previous hosting settings stored in the hosting.---.cache file that lives inside .firebase folder in the root level of your app folder.

the solution for the issue above is to simply remove the .cache file or entire .firebase folder

then go to firebase.json file, and locate the the following json

{
  "hosting": {
    "site": "[old firebase site name => REPLACE THIS]",
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

replace the [old firebase site name] with your new one.

run the hosting deploy command again in the terminal

firebase deploy --only hosting:[enter your new firebase hosting site name]

hopefully the error will go away, and new .cache file will be generated.

Wish you a successful deployment!

Platinum answered 13/9, 2023 at 4:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.