Repository navigation
No way to delete/unmap an App #9
Description
Activity
- changed the title
[-]No way to delete an App[/-][+]No way to delete/unmap an App[/+]on Mar 14, 2017 @djejaquino can you explain your use case a little further? In what situation do you want the FirebaseApp for a given name to change over time?
@samtstern thanks for the fast response.
We have this dynamic multi-tenant SaaS architecture, on which our relational databases are easily pluggable/detachable. They are mapped by a simple string key. This means that we are able to create a new tenant database, mapping it by its key. If we need to disconnect from it, it is simply detached from the server by the same key.
In order to have the same behavior using Firebase, the tenants are represented by instances of FirebaseApp. The problem is that FirebaseApp takes hold of the app name statically and its not possible to release it programatically. There should be a way to tell FirebaseApp class to forget about some app by its name, releasing it from the memory, making it available again and avoiding memory leak.
@jwngr what do you think about this use case?
This is a totally valid use case and, to be honest, the
FirebaseApp.delete()method was originally proposed to be public, but for some reason when it was implemented, it was not marked as public. I'll follow up with some other people and see if we can go ahead and make this public. Will report back when I have more info.@jwngr I tried invoking
FirebaseApp.delete()using reflection. At first it seemed ok, it recreates the app. But when I try generate a custom token, I get:Caused by: java.lang.IllegalStateException: FirebaseApp was deleted at com.google.firebase.internal.Preconditions.checkState(Preconditions.java:174) at com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:211) at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:72) at com.google.firebase.ImplFirebaseTrampolines.getCredential(ImplFirebaseTrampolines.java:23) at com.google.firebase.auth.FirebaseAuth.createCustomToken(FirebaseAuth.java:97) ...Maybe just exposing
deletemethod isn't enough?@djejaquino thanks for the additional information. For your information @jwngr has been asking around internally to see if we can make this feature request happen. One of us will update this thread once we can share more!
Reacted by Davi Aquino@samtstern Thanks. Looking foward to test your solution.
What's the status on this? Really need this to happen.
Reacted by Zachary Sweigart, Davi Aquino, Olga Korokhina and JasonTheDynamite@samtstern hey there mate! Any news on this one?
This was fixed a long time ago by @hiranya911:
firebase/firebase-admin-java#5If you're still having issues, file them on the
firebase-admin-javarepository. Thanks for the reminder @djejaquinoReacted by Davi Aquino and JasonTheDynamiteReacted by Davi AquinoReacted by Davi Aquino
Hi. Since there is no way to create an issue in the Firebase Admin SDK private repository, I decided that this was the best place to do it (if I am wrong, please, let me know).
The following exception is thrown whenever initializing an app with the same name twice.
java.lang.IllegalStateException: FirebaseApp name {appName} already exists!I understand one should not initialize the same app twice. But there should be a way to update the app settings/options/credentials/etc.
The class com.google.firebase.FirebaseApp statically maps apps to their names, and there is no way to unmap an app. Internally, the class has a delete method, which probably does what is needed in order to initialize another app using new com.google.firebase.FirebaseOptions using a previous name, but the method is not visible. Extending com.google.firebase.FirebaseApp is not an option either, hence its constructor is private.
The only way to re-create an app is killing the JVM and starting the process again, which frees the static instances from memory. But that implies killing our backend servers aswell.
Please, consider making delete method public if that would solve this issue.
Thanks.