Skip to content
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

FIRESTORE (10.12.0) INTERNAL ASSERTION FAILED: Unexpected state #8250

Open
luke-rogers opened this issue May 16, 2024 · 7 comments
Open

FIRESTORE (10.12.0) INTERNAL ASSERTION FAILED: Unexpected state #8250

luke-rogers opened this issue May 16, 2024 · 7 comments

Comments

@luke-rogers
Copy link

luke-rogers commented May 16, 2024

Operating System

iOS 17.4.1

Browser Version

Mobile Safari UI/WKWebView (AppleWebKit/605.1.15)

Firebase SDK Version

10.12.0

Firebase SDK Product:

Firestore

Describe your project's tooling

Angular web app running on iOS via Capacitor
Firestore offline persistence enabled with unlimited cache size

Describe the problem

For a long time now we have been plagued by this iOS-only issue and have received many reports from users that it's causing the app to stop working and forcing them to restart.

We have captured some Firebase debug logs of this error which I am happy to share privately.

This seems similar to the following issues:

Example Errors

  • UnknownError: Attempt to get a record from database without an in-progress transaction
  • UnknownError: Attempt to get all index records from database without an in-progress transaction
  • UnknownError: Connection to Indexed Database server lost. Refresh the page to try again
  • FIRESTORE (10.12.0) INTERNAL ASSERTION FAILED: Unexpected state

Example Stack Trace

Error: FIRESTORE (10.12.0) INTERNAL ASSERTION FAILED: Unexpected state
  at fail(node_modules/@firebase/firestore/dist/index.esm2017.js:197:36)
  at __PRIVATE_AsyncQueueImpl.Pu(node_modules/@firebase/firestore/dist/index.esm2017.js:18775:16)
  at __PRIVATE_AsyncQueueImpl.enqueue(node_modules/@firebase/firestore/dist/index.esm2017.js:18691:14)
  at __PRIVATE_AsyncQueueImpl.enqueueAndForget(node_modules/@firebase/firestore/dist/index.esm2017.js:18676:10)
  at n(node_modules/@firebase/firestore/dist/index.esm2017.js:14564:15)
  at <anonymous>(node_modules/@firebase/firestore/dist/index.esm2017.js:14540:7)
  at __PRIVATE_StreamBridge.yo(node_modules/@firebase/firestore/dist/index.esm2017.js:13897:10)
  at n(node_modules/@firebase/firestore/dist/index.esm2017.js:14145:81)
  at <anonymous>(node_modules/@firebase/firestore/dist/index.esm2017.js:14094:13)
  at ab(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:548:22)
  at F(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:516:9)
  at Z.prototype.ta(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:2162:5)
  at Rb(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:1035:129)
  at M.prototype.Y(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:904:50)
  at M.prototype.ca(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:832:35)
  at ab(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:548:22)
  at F(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:516:9)
  at Wc(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:1582:128)
  at h.bb(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:1579:5)
  at h.Ea(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:1576:61)
  at Lc(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:1474:50)
  at h.Pa(node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js:1440:27)
  at {_ZoneImpl#2}.run(node_modules/zone.js/fesm2015/zone.js:111:37)
  at <anonymous>(node_modules/zone.js/fesm2015/zone.js:2299:30)
  at {_ZoneImpl#2}.runTask(node_modules/zone.js/fesm2015/zone.js:157:39)
  at drainMicroTaskQueue(node_modules/zone.js/fesm2015/zone.js:529:23)

Steps and code to reproduce issue

Steps currently unknown but possibly related to the app going between the background and the foreground over time.

@luke-rogers luke-rogers added new A new issue that hasn't be categoirzed as question, bug or feature request question labels May 16, 2024
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels May 16, 2024
@wu-hui wu-hui self-assigned this May 16, 2024
@luke-rogers
Copy link
Author

Looking into the Firebase logs, the error seems to occur after updateClientMetadataAndTryBecomePrimary is called.

Our app uses persistentSingleTabManager(undefined) for the tabManager config in the Capacitor environments as there can never be more than 1 tab. I assume this tab manager is the cause of the many PUT clientMetadata and SimpleDb GET owner owner logs.

I wonder if there would be any legs in not having a tab manager if that will result in no calls to updateClientMetadataAndTryBecomePrimary etc.

This is also similar to what is described by another GitHub user here

I don't know a lot about the internals of the tab management so might be completely wrong here.

Sample Log

[2024-05-16T13:03:08.238Z] Firestore (10.12.0): SimpleDb PUT clientMetadata <auto-key> {"clientId":"jtQjaM2I0v6CbepACBf7","updateTimeMs":1715864588238,"networkEnabled":true,"inForeground":false}
[2024-05-16T13:03:08.242Z] Firestore (10.12.0): SimpleDb GET owner owner {"ownerId":"jtQjaM2I0v6CbepACBf7","allowTabSynchronization":false,"leaseTimestampMs":1715864584009}
[2024-05-16T13:03:08.244Z] Firestore (10.12.0): SimpleDb GET owner owner {"ownerId":"jtQjaM2I0v6CbepACBf7","allowTabSynchronization":false,"leaseTimestampMs":1715864584009}
[2024-05-16T13:03:08.244Z] Firestore (10.12.0): IndexedDbPersistence Client 'jtQjaM2I0v6CbepACBf7' is not zombied in LocalStorage
[2024-05-16T13:03:08.244Z] Firestore (10.12.0): SimpleDb PUT owner owner {"ownerId":"jtQjaM2I0v6CbepACBf7","allowTabSynchronization":false,"leaseTimestampMs":1715864588244}
[2024-05-16T13:03:25.878Z] Firestore (10.12.0): IndexedDbPersistence Starting transaction: updateClientMetadataAndTryBecomePrimary
[2024-05-16T13:03:48.787Z] Firestore (10.12.0): SimpleDb Aborting transaction: Attempt to get a record from database without an in-progress transaction
[2024-05-16T13:03:48.787Z] Firestore (10.12.0): SimpleDb Transaction failed with error: Attempt to get a record from database without an in-progress transaction Retrying: true
[2024-05-16T13:03:48.787Z] Firestore (10.12.0): SimpleDb Opening database: firestore/[DEFAULT]/insite-teams/main
[2024-05-16T13:03:48.802Z] Firestore (10.12.0): WebChannelConnection RPC 'Listen' stream 0x7d7f4c65 received: {"targetChange":{"resumeToken":"CgkIic7l5p2ShgM=","readTime":"2024-05-16T13:03:34.823689Z"}}
[2024-05-16T13:03:56.239Z] Firestore (10.12.0): SimpleDb Aborting transaction: Attempt to get a record from database without an in-progress transaction
[2024-05-16T13:03:56.239Z] Firestore (10.12.0): SimpleDb Transaction failed with error: Attempt to get a record from database without an in-progress transaction Retrying: true
[2024-05-16T13:03:56.239Z] Firestore (10.12.0): SimpleDb Opening database: firestore/[DEFAULT]/insite-teams/main
[2024-05-16T13:03:56.243Z] Firestore (10.12.0): SimpleDb GET owner owner {"ownerId":"jtQjaM2I0v6CbepACBf7","allowTabSynchronization":false,"leaseTimestampMs":1715864588244}
[2024-05-16T13:03:56.243Z] Firestore (10.12.0): SimpleDb PUT clientMetadata <auto-key> {"clientId":"jtQjaM2I0v6CbepACBf7","updateTimeMs":1715864636243,"networkEnabled":true,"inForeground":false}
[2024-05-16T13:03:56.244Z] Firestore (10.12.0): SimpleDb GET owner owner {"ownerId":"jtQjaM2I0v6CbepACBf7","allowTabSynchronization":false,"leaseTimestampMs":1715864588244}
[2024-05-16T13:03:56.245Z] Firestore (10.12.0): SimpleDb GET owner owner {"ownerId":"jtQjaM2I0v6CbepACBf7","allowTabSynchronization":false,"leaseTimestampMs":1715864588244}
[2024-05-16T13:04:02.786Z] Firestore (10.12.0): SimpleDb Aborting transaction: Attempt to get records from database without an in-progress transaction
[2024-05-16T13:04:02.786Z] Firestore (10.12.0): SimpleDb Transaction failed with error: Attempt to get records from database without an in-progress transaction Retrying: false
[2024-05-16T13:04:02.788Z] Firestore (10.12.0): INTERNAL UNHANDLED ERROR:  Attempt to get records from database without an in-progress transaction
[2024-05-16T13:04:19.979Z] Firestore (10.12.0): WebChannelConnection RPC 'Listen' stream 0x7d7f4c65 received: {"targetChange":{"resumeToken":"CgkIrpqg/J2ShgM=","readTime":"2024-05-16T13:04:19.823918Z"}}
[2024-05-16T13:04:19.989Z] Firestore (10.12.0): FIRESTORE (10.12.0) INTERNAL ASSERTION FAILED: Unexpected state

@wu-hui I would be Happy to share the full log with you privately if you could let me know the best way to do that.

@vojto
Copy link

vojto commented May 17, 2024

This has gotten really bad for us over the past few days. We didn't deploy anything.

Edit: This is on desktop.

@luke-rogers
Copy link
Author

@vojto Perhaps that's a different issue, this has always been limited to just iOS for us.

@wu-hui
Copy link
Contributor

wu-hui commented May 21, 2024

I think the multitab log might be unrelated, this seems to stem from a underlying webchannal message.

@luke-rogers
Copy link
Author

Fair enough, not an area I've dug too deep into.

@wu-hui what steps can I take to help try and move this forward?

@MarkDuckworth MarkDuckworth self-assigned this May 24, 2024
@luke-rogers
Copy link
Author

Still seeing this issue on the latest version. I have logs I can share if that would be useful?

@MarkDuckworth
Copy link
Contributor

@luke-rogers I would like to review the logs. You can share the logs through a private GitHub repo (shared with me), through a Cloud support ticket, or through a Firebase support ticket. If creating a ticket with either Google support channel, please reference this GitHub issue so the support staff knows to route the ticket to my team. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants