I have an environment with Node.js in which I run some cloud functions from Firebase. I wanted to try to migrate them to V2, starting with the simplest of them. After changing a couple of lines of code and trying to deploy them (which failed, because of some packages errors), I went back to everything as normal, just changing back those lines of code, but modifying a Messaging method (from sendToTopic to send, because it got deprecated). After trying to deploy it, it keeps giving me this message:
Error: [onChallengeCompleted(us-central1)] Upgrading from 1st Gen to 2nd Gen is not yet supported. See https://firebase.google.com/docs/functions/2nd-gen-upgrade before migrating to 2nd Gen.
It doesn't make any sense because nothing in my code is from V2, just a failed attempt to deploy, which didn't go through. The only way of getting rid of the error is changing the function's name (my function, the one I'm exporting to the cloud), but then it throws the same error for the next function. Changing the function's name is not ideal because they are referenced in the backend, the Android and the iOS version of the app, which would mean new versions, etc.
I believe there is something stuck that makes it understand that I'm using V2, when I'm actually using V1. I event restarted the whole firebase folder with new installations of node, firebase CLI and firebase tools.
Any ideas?
You've correctly diagnosed the problem—the state of your function is "stuck" on the backend. Your failed 2nd Gen deployment attempt created resources on Google Cloud (specifically a Cloud Run service, which powers 2nd Gen functions) that weren't cleaned up.
Now, when you try to deploy your 1st Gen function with the same name and region, the Firebase CLI sees the existing 2nd Gen resource and interprets your deployment as an unsupported downgrade from Gen 2 to Gen 1.
The solution is to manually delete the function to remove these lingering backend resources before redeploying your 1st Gen code.
The cleanest and most direct way to fix this is to explicitly delete the function using the Firebase CLI. This command will remove the function and all its associated remnant resources from the backend.
Delete the function from your Firebase project by running this command in your terminal. Replace myFunction
and us-central1
with your function's name and region.
Bash
firebase functions:delete myFunction --region us-central1
You may be prompted to confirm the deletion.
Wait for the deletion to complete. You can check the Firebase Console to confirm the function is gone.
Redeploy your original 1st Gen function as you normally would.
Bash
firebase deploy --only functions
This process forces a clean slate for that specific function, resolving the conflict without requiring you to change any names.
If for some reason the CLI command doesn't work, you can achieve the same result by manually deleting the underlying Cloud Run service in the Google Cloud Console.
Navigate to the Cloud Run page in the Google Cloud Console.
Make sure you have selected the correct Firebase project.
Find the service corresponding to your function. The name will typically be the same as your function's name (e.g., myFunction
).
Select the checkbox next to the service and click DELETE.
After the service is deleted, try deploying your 1st Gen function again. The deployment should now succeed as the conflicting 2nd Gen resource has been removed.
This approach should resolve the error and allow you to deploy your 1st Gen functions under their original names.