"Error: There was an error deploying functions" with no other info

I'm getting the error "There was an error deploying functions" when trying to deploy a newly created function. There is no other error info in the output:
i functions: updating Node.js 22 (2nd Gen) function helloWorld(us-central1)...
Functions deploy had errors with the following functions:
helloWorld(us-central1)
Error: There was an error deploying functions
firebase functions:log
gives me nothing. The debug log has a not-very-helpful local stack trace at the end:
[2025-04-18T19:12:27.812Z] Functions deploy failed.
[2025-04-18T19:12:27.812Z] {}
[2025-04-18T19:12:27.849Z] Error: Precondition failed
at Fabricator.updateV2Function (/home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:382:19)
at Fabricator.updateEndpoint (/home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:155:24)
at /home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:110:71
at handle (/home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:89:23)
at Fabricator.applyChangeset (/home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:110:26)
at /home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:69:40
at Array.map (<anonymous>)
at Fabricator.applyPlan (/home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:68:54)
at release (/home/aldel/.nvm/versions/node/v20.15.1/lib/node_modules/firebase-tools/lib/deploy/functions/release/index.js:76:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: There was an error deploying functions
This is the first function in a new project, and it is literally just the helloWorld
function that firebase init
sets up (commented out; I just uncommented it):
import {onRequest} from "firebase-functions/v2/https";
import * as logger from "firebase-functions/logger";
export const helloWorld = onRequest((request, response) => {
logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
The function works fine in the emulator.
How can I figure out what's wrong?
Answer
I think this started with a previous failed attempt to deploy the function. The deploy was happening in a GitHub Action, so it could not be interactive, and it failed with this error:
i functions: creating Node.js 22 (2nd Gen) function helloWorld(us-central1)...
Could not build the function.
Functions deploy had errors with the following functions:
helloWorld(us-central1)
⚠ functions: No cleanup policy detected for repositories in us-central1. This may result in a small monthly bill as container images accumulate over time.
Error: Functions successfully deployed but could not set up cleanup policy in location us-central1. Pass the --force option to automatically set up a cleanup policy or run 'firebase functions:artifacts:setpolicy' to manually set up a cleanup policy.
Error: Process completed with exit code 1.
Apparently now you have to set up that policy before you can deploy. If you do the first deploy manually from the command line, it will ask you how long to keep images before they're deleted. But it can't do that in a non-interactive CI environment. So it fails.
After this, the function existed in the Firebase console, but it didn't work, and further attempts to deploy it failed as described in the question.
The solution was to manually delete the function with firebase functions:delete helloWorld
. Then when I tried to deploy again, it succeeded.
I don't know if this is the only way a function can get into this non-deployable state, but if you are getting the same error (without any more helpful messages), it's probably worth a try to delete the function and try again.
Enjoyed this article?
Check out more content on our blog or follow us on social media.
Browse more articles