Skip to content

Deleted App's Firestore Database Never Released #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
basememara opened this issue Jan 19, 2018 · 6 comments · Fixed by #809
Closed

Deleted App's Firestore Database Never Released #683

basememara opened this issue Jan 19, 2018 · 6 comments · Fixed by #809

Comments

@basememara
Copy link

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.

@ryanwilson
Copy link
Member

Thanks for investigating and having the steps to reproduce @basememara! You're right, we're not currently deleting the Firestore instance. It's related to #160 but that was an issue with Firebase Database, not Firestore. I'll get a fix in shortly for it and it should be ready for the next release.

@ryanwilson
Copy link
Member

I think we're leaving Issues open until they're publicly shipped (in case someone else creates an Issue about it). I'll close this again once it ships next version!

@wilhuff
Copy link
Contributor

wilhuff commented Feb 16, 2018

Argh. That's annoying: all I did on the other side was merge the PR that fixed this.

@morganchen12
Copy link
Contributor

It's a GitHub feature that goes against our workflow. 😭

To workaround it, you can write "This addresses $(issue number)" instead of "This fixes $(issue number)" in your pull requests.

@wilhuff
Copy link
Contributor

wilhuff commented Feb 16, 2018

I've added this as a proposed discussion topic in go/firebase-ios-weekly. This is the third issue I've seen go by in a week where we've accidentally done the close/reopen dance.

@ryanwilson
Copy link
Member

The fix is now live version 0.10.2!

@firebase firebase locked and limited conversation to collaborators Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants