Skip to content

experimentalTabSynchronization broken in 5.7.0 (Failed to obtain primary lease for action 'Collect garbage') #1436

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
varung opened this issue Dec 19, 2018 · 6 comments

Comments

@varung
Copy link

varung commented Dec 19, 2018

[REQUIRED] Describe your environment

  • Operating System version: OS X Mojave
  • Browser version: Version 71.0.3578.98 (Official Build) (64-bit)
  • Firebase SDK version: 5.5.9
  • Firebase Product: FireStore (auth, database, storage, etc)

[REQUIRED] Describe the problem

I had a react project that used firebase and worked well for several months. I then updated the code to the newest firebase sdk and to use multi-tab persistence. For the first time I saw the following console errors. (It's possible these occurred earlier and I did not notice, but I know for sure I did not get errors before October 2018. The app had been developed several months before October and ran well without problems.)

Steps to reproduce:

It seems to happen when multiple tabs are used, and multi-tab persistence is enabled. When it happens, it happens many times. (sometimes 100s).

index.cjs.js:151 Uncaught Error: FIRESTORE (5.5.9) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: FirebaseError: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.
at new t (index.cjs.js:346)
at index.cjs.js:11746
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
at e.r.nextCallback (index.cjs.js:8225)
at index.cjs.js:8195
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
at u (index.cjs.js:151)
at e.verifyNotFailed (index.cjs.js:7763)
at e.enqueue (index.cjs.js:7715)
at e.enqueueAndForget (index.cjs.js:7707)
at e.handleDelayElapsed (index.cjs.js:7669)
at index.cjs.js:7645
at Worker.worker.onmessage (HackTimer.js:134)
u @ index.cjs.js:151
e.verifyNotFailed @ index.cjs.js:7763
e.enqueue @ index.cjs.js:7715
e.enqueueAndForget @ index.cjs.js:7707
e.handleDelayElapsed @ index.cjs.js:7669
(anonymous) @ index.cjs.js:7645
worker.onmessage @ HackTimer.js:134

Relevant Code:

// Code that sets up firebase

import firebase from 'firebase'

firebase.initializeApp(config)
export default firebase;
export const provider = new firebase.auth.GoogleAuthProvider();
export const auth = firebase.auth();

export let db = firebase.firestore();
const settings = {/* your settings... */ timestampsInSnapshots: true};
db.settings(settings);

db.enablePersistence({experimentalTabSynchronization:true}).then(() => {
console.log("Woohoo! Multi-Tab Persistence!");
})
.catch(function(err) {
console.log("failed to enable persistence:" + err.code)
});

// as an example, this is the method of a react object that uses firebase
// example is handling when the user leaves a form element with onBlur
handleChangeAndSave = (e) => {
const t = e.target;
const value = (t.type === 'checkbox')?t.checked:t.value;
this.fbref().set({ [t.name]: value, _updated : new Date() }, {merge: true})
}

@google-oss-bot
Copy link
Contributor

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

@mikelehen
Copy link
Contributor

Thanks for the report! This is very possibly a bug in the experimental multi-tab synchronization support.

In order to track this down, we will likely need a way to reproduce the problem so that we can debug what is going wrong. Failing that, it would be helpful if you can see if there is an earlier error being logged. The error you've reported suggests that the "The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab." error happened earlier, and hopefully it was logged with a more accurate callstack, that could help us track this down. Thanks!

@varung
Copy link
Author

varung commented Dec 21, 2018

index.esm.js:77 [2018-12-21T10:18:05.142Z] @firebase/firestore: Firestore (5.5.9): Failed to obtain primary lease for action 'Collect garbage'.
s @ index.esm.js:77
index.esm.js:77 [2018-12-21T10:18:05.142Z] @firebase/firestore: Firestore (5.5.9): INTERNAL UNHANDLED ERROR: FirebaseError: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.
at new t (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:738041)
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:874855
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833120
at e.wrapUserFunction (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832962)
at e.wrapSuccess (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833085)
at e.nextCallback (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832730)
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832285
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833120
at e.wrapUserFunction (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832962)
at e.wrapSuccess (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833085)
s @ index.esm.js:77
index.cjs.js:346 Uncaught (in promise) Error: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.
at new t (index.cjs.js:346)
at index.cjs.js:11768
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
at e.nextCallback (index.cjs.js:8225)
at index.cjs.js:8195
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
21:1 Uncaught (in promise) Error: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.
at new t (index.cjs.js:346)
at index.cjs.js:11768
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
at e.nextCallback (index.cjs.js:8225)
at index.cjs.js:8195
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
index.cjs.js:7729 Uncaught Error: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.
at new t (index.cjs.js:346)
at index.cjs.js:11768
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
at e.nextCallback (index.cjs.js:8225)
at index.cjs.js:8195
at index.cjs.js:8255
at e.wrapUserFunction (index.cjs.js:8241)
at e.wrapSuccess (index.cjs.js:8255)
index.esm.js:77 [2018-12-21T10:18:05.205Z] @firebase/firestore: Firestore (5.5.9): FIRESTORE (5.5.9) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: FirebaseError: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.
at new t (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:738041)
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:874855
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833120
at e.wrapUserFunction (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832962)
at e.wrapSuccess (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833085)
at e.nextCallback (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832730)
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832285
at https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833120
at e.wrapUserFunction (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:832962)
at e.wrapSuccess (https://firepomo.firebaseapp.com/static/js/main.d51247b3.js:1:833085)

@varung
Copy link
Author

varung commented Dec 21, 2018

Not sure if the above helps.

@mikelehen
Copy link
Contributor

mikelehen commented Dec 21, 2018

@varung Thanks! That definitely helps. I believe I know what the cause is and we'll work on getting a fix into an upcoming release.

In the meantime I believe you could avoid the issue by disabling garbage collection with:

firebase.firestore().settings({
  ...
  cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED
});

mikelehen pushed a commit that referenced this issue Dec 21, 2018
Only schedule garbage collections on the primary tab and gracefully ignore
if they fail.
@mikelehen mikelehen changed the title INTERNAL ASSERTION FAILED: AsyncQueue is already failed: FirebaseError: The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab. experimentalTabSynchronization broken in 5.7.0 (Failed to obtain primary lease for action 'Collect garbage') Dec 22, 2018
@mikelehen
Copy link
Contributor

This should be fixed in the 5.7.2 release that went out last week. Thanks!

@firebase firebase locked and limited conversation to collaborators Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants