firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

IINTERNAL 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.

Open InputNeuron opened this issue 6 years ago • 8 comments

[REQUIRED] Describe your environment

  • Operating System version: __ ubuntu
  • Browser version: _ electron 7.1.2
  • Firebase SDK version: __7.6.1
  • Firebase Product: __ firestore (auth, database, storage, etc)

[REQUIRED] Describe the problem

Steps to reproduce:

We're getting this exception constantly in the wild, but I can't actually duplicate it locally.

We have about 5k uses and receive this error about 9200 times per month.

Relevant Code:

I don't have a reduction unfortunately. Is there a better way to reproduce this?

InputNeuron avatar Jan 20 '20 05:01 InputNeuron

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

google-oss-bot avatar Jan 20 '20 05:01 google-oss-bot

Sorry to hear about your issues, @burtonator. I haven't encountered this error yet. Based from the error message, it's more likely related to (https://github.com/firebase/firebase-js-sdk/issues/1436) multi-tab synchronization support, and was addressed in v5.7.2.

  • Are you using experimentalTabSynchronization?
  • Can you try running the app on multiple tabs to reproduce it (as mentioned in the issue)?

rommelpe avatar Jan 20 '20 12:01 rommelpe

Thanks @rommelpe ... appreciate your help as this might be a huge bug for us.

Are you using experimentalTabSynchronization?

I'm not but I am running synchronizeTabs.

Can you try running the app on multiple tabs to reproduce it (as mentioned in the issue)?

Electron doesn't really have 'tabs' but it does have windows. I've tried to duplicate this and I can't ... I might try to disable synchronizeTabs.

What would be the downside of using enablePersistence () without synchronizeTabs? I assume this means the second 'tab' or window wouldn't have persistence?

InputNeuron avatar Jan 20 '20 17:01 InputNeuron

@burtonator

What would be the downside of using enablePersistence () without synchronizeTabs? I assume this means the second 'tab' or window wouldn't have persistence?

Without synchronizeTabs, only the first tab that is opened will have persistence, so subsequently opened tabs will fall back to memory persistence. In web browsers, multiple tabs share a single instance of IndexedDB, and the synchronizeTabs setting allows multiple Firestore instances to share access to IndexedDB.

thebrianchen avatar Jan 21 '20 20:01 thebrianchen

Hey @burtonator. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jan 29 '20 02:01 google-oss-bot

We've also been seeing this error on and off for several months. We are not on electron, just your typical web app.

We are using firebase.firestore().enablePersistence({ synchronizeTabs:true });

I've only now just discovered experimentalTabSynchronization, thanks to this thread. We'll give that a try too.

The error pretty consistently happens when both a) you have multiple tabs of the same app open, and b) you close the lid and put the laptop to sleep for the night (macbook in all our cases). We suspect macbooks must periodically and briefly wake up from its sleep state throughout the night, and we see errors throughout the night. The error continues occurring after the computer is in a wake state, and will do so until you refresh the tab.

Here is a timeline I constructed from some of the error logging:

Close lid and pack up laptop at ~18:05:00. Remains closed for the rest of the night.

(At dinner. Connecting to wifi in restaurant parking lot while lid is closed?)
20:33:50 - Client lost connectivity
20:34:31 - Client gained connectivity

(Back home at this point, connecting to home wifi? Laptop still in bag.)
21:01:32 - Client list connectivity
21:01:42 - Client gained connectivity

21:45:11 - POST https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=…
22:21:33 - GET https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=…

22:39:43.923 - [2020-01-31T05:39:43.921Z]  @firebase/firestore: Firestore (7.6.0): 
Failed to obtain primary lease for action 'maybeGarbageCollectMultiClientState'.

22:39:44.041 - [2020-01-31T05:39:44.041Z]  @firebase/firestore: Firestore (7.6.0): 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.

22:39:44.917 - [2020-01-31T05:39:44.917Z]  @firebase/firestore: Firestore (7.6.0): FIRESTORE (7.6.0) 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.
"../src/../src/util/error.ts" line 166 col 11 in new t
"../src/../src/local/indexeddb_persistence.ts" line 799 col 23 in [anonymous]
"../src/../src/local/persistence_promise.ts" line 136 col 42 in [anonymous]
"../src/../src/local/persistence_promise.ts" line 120 col 22 in e.wrapUserFunction
"../src/../src/local/persistence_promise.ts" line 136 col 19 in e.wrapSuccess
"../src/../src/local/persistence_promise.ts" line 101 col 16 in e.r.nextCallback
"../src/../src/local/persistence_promise.ts" line 65 col 16 in [anonymous]
"../src/../src/local/persistence_promise.ts" line 136 col 42 in [anonymous]
"../src/../src/local/persistence_promise.ts" line 120 col 22 in e.wrapUserFunction
"../src/../src/local/persistence_promise.ts" line 136 col 19 in e.wrapSuccess
"../src/../src/util/assert.ts" line 39 col 9 in y
"../src/../src/util/async_queue.ts" line 351 col 7 in e.verifyNotFailed
"../src/../src/util/async_queue.ts" line 274 col 10 in e.enqueue
"../src/../src/util/async_queue.ts" line 228 col 10 in e.enqueueAndForget
"../src/../src/remote/remote_store.ts" line 140 col 18 in [anonymous]
"../src/../src/platform_browser/browser_connectivity_monitor.ts" line 57 col 24 in e.onNetworkAvailable
"../src/../src/platform_browser/browser_connectivity_monitor.ts" line 32 col 10 in networkAvailableListener

That last error starts spamming thousands of instances once I open the lid back up in the morning.

Failed to obtain primary lease for action 'maybeGarbageCollectMultiClientState'. is notable, as that's the initial error.

cmditch avatar Jan 31 '20 17:01 cmditch

@cmditch "experimentalTabSynchronization" and "synchronizeTabs" are equivalent.

It looks like there is indeed an issue with maybeGarbageCollectMultiClientState. We should be able to recover gracefully from that. I will fix this shortly and it should go out with the next release.

schmidt-sebastian avatar Jan 31 '20 18:01 schmidt-sebastian

Excellent, thanks!

cmditch avatar Jan 31 '20 18:01 cmditch