firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

Error thrown: Firestore has already been started and persistence can no longer be enabled

Open danielo515 opened this issue 2 years ago • 4 comments

I see you are throwing an error in certain situations when trying to setup firebase offline persistence:

https://github.com/firebase/firebase-js-sdk/blob/f5426a51275bb611a5d9a6df3200d0fe5095afa2/packages/firestore/src/api/database.ts#L561-L565

This is completely unexpected, not documented and I think it is a bad idea. The documentation says that, in case of error you will get a rejected promise, which is what I am coding for and what I a m guarding against, however, to my surprise a plain sync error is just thrown and therefore I am not notified in any way. Please, consider fixing this and adding it to the list of possible rejection values in the returned promise

danielo515 avatar Jul 29 '22 09:07 danielo515

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Jul 29 '22 09:07 google-oss-bot

Hi @danielo515, I believe you are referring to the documentation of enableIndexedDbPersistence or enableMultiTabIndexedDbPersistence. If so, I agree that the documentation seems inconsistent with the implementation. I'm going to review this with the team and get back to you.

MarkDuckworth avatar Jul 29 '22 14:07 MarkDuckworth

Hi @danielo515, I believe you are referring to the documentation of enableIndexedDbPersistence or enableMultiTabIndexedDbPersistence. If so, I agree that the documentation seems inconsistent with the implementation. I'm going to review this with the team and get back to you.

Yes, that's correct, sorry for not being clear. Thank you

danielo515 avatar Jul 29 '22 22:07 danielo515

Hi @danielo515, I have moved this to the backlog for implementation in a future sprint. We will likely have to update the documentation to cover the current behavior, because changing the behavior would be a breaking change and could affect customers. Thanks for bringing it to our attention.

(b/241153576)

MarkDuckworth avatar Aug 02 '22 22:08 MarkDuckworth