Skip to content

No way to delete/unmap an App #9

Description

@djejaquino

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.

Activity

  1. changed the title [-]No way to delete an App[/-] [+]No way to delete/unmap an App[/+] on Mar 14, 2017
  2. samtstern commented on Mar 14, 2017

    @samtstern
    Contributor

    @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?

  3. djejaquino commented on Mar 14, 2017

    @djejaquino
    Author

    @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.

  4. samtstern commented on Mar 14, 2017

    @samtstern
    Contributor

    @jwngr what do you think about this use case?

  5. jwngr commented on Mar 15, 2017

    @jwngr

    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.

  6. djejaquino commented on Mar 16, 2017

    @djejaquino
    Author

    @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 delete method isn't enough?

  7. samtstern commented on Mar 16, 2017

    @samtstern
    Contributor

    @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!

  8. djejaquino commented on Mar 20, 2017

    @djejaquino
    Author

    @samtstern Thanks. Looking foward to test your solution.

  9. FunkyLambda commented on Dec 17, 2018

    @FunkyLambda

    What's the status on this? Really need this to happen.

  10. djejaquino commented on Jun 4, 2019

    @djejaquino
    Author

    @samtstern hey there mate! Any news on this one?

  11. samtstern commented on Jun 4, 2019

    @samtstern
    Contributor

    This was fixed a long time ago by @hiranya911:
    firebase/firebase-admin-java#5

    If you're still having issues, file them on the firebase-admin-java repository. Thanks for the reminder @djejaquino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions