firebase-tools
firebase-tools copied to clipboard
Nextjs deployments are not turning off old cloud run revisions (for SSR)
We use the nextjs framework integration for firebase. When we deploy our app, it creates a new cloud run revision for the SSR backend, but the old revision stays active. Rarely will the old one be 'deactivated'. Our snippet below gives the historical revisions for cloud run instances and you can see that one of them was deactivated successfully.
This matters because those old revisions are costing us a lot of money (which we recently discovered through billing and deleting many of the old revisions that were still active).
firebase-tools:12.7.0
[REQUIRED] Expected behavior
When we deploy a nextjs app, the old ssr cloud run revision should be deactivated when the new one is active.
[REQUIRED] Actual behavior
The old revisions are staying active.
This issue does not seem to follow the issue template. Make sure you provide all the required information.
For anyone experiencing similar issues, we are cleaning up our revisions with the following gcloud commands:
gcloud run revisions list --filter="status.conditions.type:Active AND metadata.creationTimestamp<'$(date --date=' 1 days ago' '+%Y%d%m')'" --format='value(metadata.name)' | xargs -r -L1 gcloud run revisions delete --quiet --region us-central1
Would be great to fix whatever is causing this issue with firebase deploy.
Same here, thanks for the script!
Are there any updates on this issue?
Unfortunately this is WAI on the backend... minInstances will be respected in Cloud Functions gen2, so long as the revision is routable—this includes the tags made by the Firebase CLI so Hosting (SSG/CSR) and Functions (SSR) content can be deployed and rolled back atomically. In the next version of the CLI we will add guardrails to prevent minInstances from being configured alongside pinTags, #6684.
If you have any addition questions/concerns please reach out to Firebase support, sorry that we missed this in testing.
We'll add information on this to Web Frameworks' preview docs
We use NextJs with Firebase Hosting with the web frameworks integration.
Previously we where using both pinTags
and minInstances
at the same time since we required both functionalities, pinTags
to do safe and quick rollbacks for the hosting (keeping in sync the Hosting and the "pinned" Cloud Function) , and minInstances
to prevent a cold start when the hosting uses the Cloud Function to generate pages using Server Side Rendering.
Specifically, the cold start doesn't happen with static pages, only when using SSR or pages with dynamic routes.
I understand the dangers of having both features configured at once, is there any way that we can use both at the same time? Maybe adding a warning that needs to be accepted or something like that.
Thanks!
Just got burned by this. 3.4k USD later...
this one deletes everything except one with a given name (in my case the one serving traffic)
gcloud run revisions list --filter="-metadata.name:funcname-XXXXX-XXX" --format='value(metadata.name)' | xargs -r -L1 gcloud run revisions delete --quiet --region us-central1