Skip to content

firestore.enablePersistence().catch is not catching exceptions #608

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
jamesdaniels opened this issue Mar 30, 2018 · 1 comment
Closed

Comments

@jamesdaniels
Copy link
Member

jamesdaniels commented Mar 30, 2018

[REQUIRED] Describe your environment

  • Operating System version: any
  • Firebase SDK version: <= 4.12.1
  • Firebase Product: firestore

Any exceptions with enable persistence raise an uncaught exception, even if you attempt to catch on the Promise.

Steps to reproduce:

Call in two tabs:

firestore.enablePersistence().then(() => {}, () => {})
or firestore.enablePersistence().catch(() => {})

You'll get an uncaught exception RE Firestore persistence already having been initialized.

The exception should have be caught with the Promise's reject argument / catch method and not bubble up further, which raises an uncaught exception. Developers currently need to wrap in a try/catch which isn't great ergo.

This hits us here: https://github.com/angular/angularfire2/blob/e343f137bd0ca9a1d958253b58104c64acbe3944/src/firestore/firestore.ts#L123

@jamesdaniels jamesdaniels changed the title firestore.enablePersistence's promise is not capturing exceptions firestore.enablePersistence's promise/catch is not catching the exceptions Mar 30, 2018
@jamesdaniels jamesdaniels changed the title firestore.enablePersistence's promise/catch is not catching the exceptions firestore.enablePersistence().catch is not catching exceptions Mar 30, 2018
@mikelehen
Copy link
Contributor

I believe this is a dupe of #256 which we'll try to address soon-ish. :-)

@firebase firebase locked and limited conversation to collaborators Oct 22, 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.

3 participants