Skip to content

Deleted App's Firestore Database Never Released #683

Closed
@basememara

Description

@basememara

This is related to issue #160 which I believe was not fixed.

After getting a database reference and deleting the associated app, Firebase will always return the same instance to the initial database for an app's lifecycle. The instances array will hold an outdated reference of the database. This causes the database's authentication chain to break and the user will not be able to use the database even though it was created after deletion.

  • Xcode version: Version 9.2 (9C40b)
  • Swift version: Swift 4
  • Firebase SDK version: 4.8.0
  • Firestore version: 0.9.4
  • Firebase Product: Firestore

Steps to Reproduce
1.) Create a Firebase app with a specific name.
2.) Print Firebase database reference.
3.) Delete the Firebase app.
4.) Wait until deletion completes
5.) Create a Firebase app using the same name used in step 1.
6.) Print Firebase database reference which will match step 2 but should be different.
7.) Try authenticating against database in step 5 and fails permissions.

Code to Reproduce

DispatchQueue.main.async {
  FirebaseApp.configure(name: "abc123", options: options)
  let app = FirebaseApp.app(name: "abc123")
  print("Firebase app: \(app!)") //<FIRApp: 0x600000a42760> **GOOD
  print("Firebase database: \(Firestore.firestore(app: app!))") //<FIRFirestore: 0x6040008880c0> **GOOD
  app!.delete { _ in print("Done delete") }
}
        
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
  FirebaseApp.configure(name: "abc123", options: options)
  let app = FirebaseApp.app(name: "abc123")
  print("Firebase app: \(app!)") //<FIRApp: 0x600000456e60> **GOOD
  print("Firebase database: \(Firestore.firestore(app: app!))") //<FIRFirestore: 0x6040008880c0> **BAD!!
}

Notice the Firebase database memory location printed before and after deletion is the same, even though it was recreated. The database isn't usable again until the app is killed and restarted.

After running app.delete, it should remove the database reference so it will be recreated fresh the next time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions