Skip to content

Schedule everything on the AsyncQueue #3701

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 2 commits into from
Sep 9, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

This PR fixes a scheduling problem in the firestore-exp client. Before this change, most methods looked like this:

getComponent().then(() => enqueueOp())

That meant that getComponent() did not run on the AsyncQueue. During a test I noticed that the following did not issue a write:

setDoc(docRef, {});
terminate(firestore);

This was because terminate did not use getComponent() and hence was able to schedule its task on the async queue before setDoc().

This is a large PR but I am out next week so take your time :)

@changeset-bot
Copy link

changeset-bot bot commented Aug 28, 2020

💥 No Changeset

Latest commit: 94c0d82

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, 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 Aug 28, 2020

Size Analysis Report

Affected Products

No changes between base commit (cc16b4a) and head commit (1060664).

Test Logs

@google-oss-bot
Copy link
Contributor

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (cc16b4a) Head (1060664) Diff
    browser 248 kB 248 kB -238 B (-0.1%)
    esm2017 196 kB 196 kB -40 B (-0.0%)
    main 482 kB 482 kB -212 B (-0.0%)
    module 246 kB 246 kB -194 B (-0.1%)
    react-native 196 kB 196 kB -40 B (-0.0%)
  • @firebase/firestore/exp

    Type Base (cc16b4a) Head (1060664) Diff
    browser 189 kB 189 kB +261 B (+0.1%)
    main 474 kB 477 kB +2.72 kB (+0.6%)
    module 189 kB 189 kB +261 B (+0.1%)
    react-native 189 kB 190 kB +261 B (+0.1%)
  • @firebase/firestore/lite

    Type Base (cc16b4a) Head (1060664) Diff
    main 142 kB 142 kB +2 B (+0.0%)
  • @firebase/firestore/memory

    Type Base (cc16b4a) Head (1060664) Diff
    browser 186 kB 186 kB -238 B (-0.1%)
    esm2017 147 kB 147 kB -40 B (-0.0%)
    main 356 kB 356 kB -212 B (-0.1%)
    module 184 kB 184 kB -194 B (-0.1%)
    react-native 147 kB 147 kB -40 B (-0.0%)
  • firebase

    Type Base (cc16b4a) Head (1060664) Diff
    firebase-firestore.js 286 kB 286 kB -189 B (-0.1%)
    firebase-firestore.memory.js 226 kB 226 kB -189 B (-0.1%)
    firebase.js 821 kB 821 kB -193 B (-0.0%)

Test Logs

@@ -325,7 +337,7 @@ export function terminate(
}

function verifyNotInitialized(firestore: Firestore): void {
if (firestore._initialized) {
if (firestore._initialized || firestore._terminated) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: what's the reason to check for _terminated? Can an instance be terminated without being initialized? If yes, consider adding this bit to the error message below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a user calls "terminate()" on an uninitialized Firestore, we should also not initialize it. The error message is actually shared between the new SDK and the old SDK and hence, I would rather not touch it.

@schmidt-sebastian schmidt-sebastian merged commit 565004d into master Sep 9, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/queueeverything branch September 9, 2020 22:18
@firebase firebase locked and limited conversation to collaborators Oct 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants