Skip to content

Update the JSDoc for enableIndexedDbPersistence #7852

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

Merged
merged 8 commits into from
Dec 21, 2023

Conversation

milaGGL
Copy link
Contributor

@milaGGL milaGGL commented Dec 11, 2023

In some situations, enableIndexedDbPersistence and enableMultiTabIndexedDbPersistence throw an error instead of rejecting a promise. Rejected promise is documented as the way the error will be surfaced.

it('fails with code unimplemented', () => {

it('cannot mix enableIndexedDbPersistence() and settings.cache', async () => {

Updated the documentation accordingly.

@milaGGL milaGGL requested review from a team as code owners December 11, 2023 16:52
Copy link

changeset-bot bot commented Dec 11, 2023

⚠️ No Changeset found

Latest commit: 9130397

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 11, 2023

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (07a65d3)Merge (dd5459a)Diff
    browser375 kB375 kB-48 B (-0.0%)
    esm5360 kB360 kB-48 B (-0.0%)
    module375 kB375 kB-48 B (-0.0%)
    react-native375 kB375 kB-48 B (-0.0%)
  • @firebase/firestore-lite

    TypeBase (07a65d3)Merge (dd5459a)Diff
    browser109 kB109 kB-2 B (-0.0%)
    esm5106 kB106 kB-2 B (-0.0%)
    module109 kB109 kB-2 B (-0.0%)
    react-native109 kB109 kB-2 B (-0.0%)
  • bundle

    TypeBase (07a65d3)Merge (dd5459a)Diff
    firestore (Persistence)302 kB302 kB-11 B (-0.0%)
    firestore (Query Cursors)238 kB238 kB-56 B (-0.0%)
    firestore (Query)236 kB236 kB-56 B (-0.0%)
    firestore (Read data once)224 kB224 kB-56 B (-0.0%)
    firestore (Read Write w Persistence)321 kB321 kB-46 B (-0.0%)
    firestore (Realtime updates)226 kB226 kB-56 B (-0.0%)
    firestore (Transaction)204 kB204 kB-9 B (-0.0%)
    firestore (Write data)204 kB204 kB-7 B (-0.0%)
    firestore-lite (Transaction)86.5 kB86.5 kB-2 B (-0.0%)
  • firebase

    TypeBase (07a65d3)Merge (dd5459a)Diff
    firebase-compat.js779 kB779 kB-48 B (-0.0%)
    firebase-firestore-compat.js341 kB341 kB-48 B (-0.0%)
    firebase-firestore-lite.js117 kB117 kB-2 B (-0.0%)
    firebase-firestore.js434 kB434 kB-48 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/IBkznChMka.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 11, 2023

Size Analysis Report 1

Affected Products

  • @firebase/firestore

    • addDoc

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size123 kB123 kB-7 B (-0.0%)
      size-with-ext-deps194 kB194 kB-7 B (-0.0%)
    • clearIndexedDbPersistence

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size26.5 kB26.5 kB+10 B (+0.0%)
      size-with-ext-deps96.6 kB96.6 kB+10 B (+0.0%)
    • deleteDoc

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size114 kB114 kB-7 B (-0.0%)
      size-with-ext-deps185 kB185 kB-7 B (-0.0%)
    • disableNetwork

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size102 kB102 kB-7 B (-0.0%)
      size-with-ext-deps173 kB173 kB-7 B (-0.0%)
    • enableIndexedDbPersistence

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size186 kB186 kB+3 B (+0.0%)
      size-with-ext-deps258 kB258 kB+3 B (+0.0%)
    • enableMultiTabIndexedDbPersistence

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size221 kB221 kB-11 B (-0.0%)
      size-with-ext-deps294 kB294 kB-11 B (-0.0%)
    • enableNetwork

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size102 kB102 kB-7 B (-0.0%)
      size-with-ext-deps173 kB173 kB-7 B (-0.0%)
    • executeWrite

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size113 kB113 kB-7 B (-0.0%)
      size-with-ext-deps184 kB184 kB-7 B (-0.0%)
    • getAggregateFromServer

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size110 kB110 kB-7 B (-0.0%)
      size-with-ext-deps180 kB180 kB-7 B (-0.0%)
    • getCountFromServer

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size110 kB110 kB-7 B (-0.0%)
      size-with-ext-deps180 kB180 kB-7 B (-0.0%)
    • getDoc

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size143 kB143 kB-56 B (-0.0%)
      size-with-ext-deps214 kB214 kB-56 B (-0.0%)
    • getDocFromServer

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size143 kB143 kB-56 B (-0.0%)
      size-with-ext-deps214 kB214 kB-56 B (-0.0%)
    • getDocs

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size145 kB145 kB-56 B (-0.0%)
      size-with-ext-deps215 kB215 kB-56 B (-0.0%)
    • getDocsFromServer

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size145 kB145 kB-56 B (-0.0%)
      size-with-ext-deps215 kB215 kB-56 B (-0.0%)
    • loadBundle

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size112 kB112 kB-7 B (-0.0%)
      size-with-ext-deps182 kB182 kB-7 B (-0.0%)
    • memoryLocalCache

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size99.5 kB99.5 kB-7 B (-0.0%)
      size-with-ext-deps170 kB170 kB-7 B (-0.0%)
    • onSnapshot

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size145 kB145 kB-56 B (-0.0%)
      size-with-ext-deps216 kB216 kB-56 B (-0.0%)
    • onSnapshotsInSync

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size135 kB135 kB-21 B (-0.0%)
      size-with-ext-deps206 kB206 kB-21 B (-0.0%)
    • persistentLocalCache

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size183 kB183 kB+3 B (+0.0%)
      size-with-ext-deps255 kB255 kB+3 B (+0.0%)
    • persistentMultipleTabManager

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size218 kB218 kB-11 B (-0.0%)
      size-with-ext-deps290 kB290 kB-11 B (-0.0%)
    • persistentSingleTabManager

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size183 kB183 kB+3 B (+0.0%)
      size-with-ext-deps255 kB255 kB+3 B (+0.0%)
    • runTransaction

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size123 kB123 kB-9 B (-0.0%)
      size-with-ext-deps194 kB194 kB-9 B (-0.0%)
    • setDoc

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size122 kB122 kB-7 B (-0.0%)
      size-with-ext-deps193 kB193 kB-7 B (-0.0%)
    • updateDoc

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size123 kB123 kB-7 B (-0.0%)
      size-with-ext-deps193 kB193 kB-7 B (-0.0%)
    • waitForPendingWrites

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size103 kB103 kB-7 B (-0.0%)
      size-with-ext-deps173 kB173 kB-7 B (-0.0%)
    • writeBatch

      Size

      TypeBase (07a65d3)Merge (dd5459a)Diff
      size125 kB125 kB-7 B (-0.0%)
      size-with-ext-deps195 kB195 kB-7 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/0lKDJtIFex.html

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code, I don't think the documentation updates are correct. It appears that both the enableIndexedDbPersistence() and enableMultiTabIndexedDbPersistence() functions directly throw exceptions for some problems, and return a promise that is ultimately rejected for other problems.

Specifically, it looks like they throw an exception when misused and return a promise that eventually gets rejected if some problem out of the programmer's control prevents persistence from being set (e.g. indexeddb is not available).

So I'd recommend to revert your changes in this PR, then, just add some information, to indicate that an exception is thrown if persistence has already been enabled or if it is too late to enable persistence. Of course, verify that this is indeed correct. I'm just concerned that the updated documentation is still not fully correct.

@milaGGL milaGGL requested a review from dconeybe December 15, 2023 16:56
@milaGGL milaGGL assigned dconeybe and milaGGL and unassigned dconeybe Dec 15, 2023
@milaGGL milaGGL assigned dconeybe and unassigned milaGGL Dec 18, 2023
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor nits. Please take my comments as suggestions, rather than orders.

@dconeybe dconeybe assigned milaGGL and unassigned dconeybe Dec 19, 2023
@milaGGL milaGGL requested a review from dconeybe December 19, 2023 18:33
@milaGGL milaGGL merged commit 537d399 into master Dec 21, 2023
@milaGGL milaGGL deleted the mila/fixit-enableIndexedDbPersistence-throws branch December 21, 2023 15:05
@firebase firebase locked and limited conversation to collaborators Jan 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants