INTERNAL ASSERTION FAILED:AsyncQueue已经失败

时间:2017-12-08 08:51:53

标签: angular rxjs ionic3 angularfire2 google-cloud-firestore

我在promise中使用了subscribe/observable,如下所示。但它会给出错误。你能告诉我如何在这里正确构建或设计code吗?

async loginWithGoogle(): Promise<void> {
    const result = await this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
    const userId: string = result.additionalUserInfo.profile.id;
    const userProfile: AngularFirestoreDocument<UserProfile> = this.fireStore.doc(`userProfile/${userId}`);
    const userProfiles: AngularFirestoreCollection<UserProfile> = this.fireStore.collection('userProfile/', ref => ref.where('email', '==', result.additionalUserInfo.profile.email));
    const userProfiles$: Observable<UserProfile[]> = userProfiles.valueChanges();

    userProfiles$.subscribe(async res => { // problem is here
      if (res.length == 0) {
        await userProfile.set({
          id: userId,
          email: result.additionalUserInfo.profile.email,
          creationTime: moment().format(),
          lastSignInTime: moment().format()
        });
      }
    });
  }

筹码1:

core.js:1350 ERROR Error: FIRESTORE (4.7.0) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: The transaction was aborted, so the request cannot be fulfilled.
    at fail (assert.js:33)
    at AsyncQueue.schedule (async_queue.js:50)
    at dispatchIfStillActive (persistent_stream.js:303)
    at StreamBridge.wrappedOnClose (persistent_stream.js:325)
    at StreamBridge.callOnClose (stream_bridge.js:54)
    at webchannel_connection.js:220
    at X.<anonymous> (webchannel_connection.js:195)
    at Bb (index.js:22)
    at X.g.dispatchEvent (index.js:20)
    at Pe.Ca (index.js:94)

筹码2:

core.js:1350 ERROR Error: Uncaught (in promise): AbortError: The transaction was aborted, so the request cannot be fulfilled.
    at c (polyfills.js:3)
    at c (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4617)
    at t.invokeTask (polyfills.js:3)
    at r.runTask (polyfills.js:3)
    at o (polyfills.js:3)
    at e.invokeTask (polyfills.js:3)
    at i.isUsingGlobalCallback.invoke (polyfills.js:3)

0 个答案:

没有答案