angular / angular/angularfire

Attempt to get a record from database without an in-progress transaction

Open
#3,342 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.8k
Forks
2.2k
Avg merge
22h 28m
Merged PRs (30d)
6

Description

### Version info

**Angular:** 14.2.8

**Firestore:** 9.15.0

**AngularFire:** 7.5.0

**Ionic:** 6.1.9

**iOS:** 16.1.1 iPhoneSE (error also happens on newer versions)

### How to reproduce these conditions

**Steps to set up and reproduce**

* Setup of `app.module.ts`:
```typescript
// ...
import { initializeApp, provideFirebaseApp } from '@angular/fire/app';
import { AngularFireAuthModule } from '@angular/fire/compat/auth';
import { FirestoreService } from './services/firestore.service';
import { AngularFireModule } from '@angular/fire/compat';
import { AngularFirestoreModule } from '@angular/fire/compat/firestore';

@NgModule({
declarations: [
AppComponent // ...
],
imports: [
// ...
IonicModule.forRoot(),
// ...
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule,
AngularFirestoreModule.enablePersistence(),
provideFirebaseApp(() => initializeApp(environment.firebase)),
],
providers: [
FirestoreService,
// ...
],
bootstrap: [AppComponent],
})
export class AppModule {}

```
* sync build to ios device
* lock screen (it's hard to actually reproduce)

### Debug output

```
[Error] [2023-04-25T07:19:43.604Z] @firebase/firestore: – "Firestore (9.15.0): INTERNAL UNHANDLED ERROR: " – "Attempt to get a record from database without an in-progress transaction"

error
defaultLogHandler (vendor.js:231226)
error (vendor.js:231332)
x (vendor.js:40775)
(anonymous function) (vendor.js:62299)
(anonymous function) (polyfills.js:300)
(anonymous function) (polyfills.js:1720)
(anonymous function) (polyfills.js:357)
drainMicroTaskQueue (polyfills.js:827)
(anonymous function) (polyfills.js:705)
invokeTask (polyfills.js:2220)
globalCallback (polyfills.js:2257)

[Error] [2023-04-25T07:20:21.926Z] @firebase/firestore: – "Firestore (9.15.0): FIRESTORE (9.15.0) INTERNAL ASSERTION FAILED: Unexpected state"

error
defaultLogHandler (vendor.js:231226)
error (vendor.js:231332)
x (vendor.js:40775)
O (vendor.js:40859)
zc (vendor.js:62312)
enqueue (vendor.js:62217)
enqueueAndForget (vendor.js:62200)
handleDelayElapsed (vendor.js:58208)
timer (polyfills.js:3714)
onInvokeTask (vendor.js:197041)
(anonymous function) (polyfills.js:357)
(anonymous function) (polyfills.js:702)
```

### Actual behavior

After the screen gets locked on an iOS device, Firestore gets into an unexpected state and none of the Angular routes that use firebase queries can be accessed anymore. We only query data of our firebase instance, so there shouldn't be transaction issues.

Contributor guide

Open the contributing guide

Research direction

Start with the app.module.ts setup, especially AngularFirestoreModule.enablePersistence(), and reproduce on an iOS device by locking the screen. Compare the Firestore 9.15.0 errors with the affected Angular routes and FirestoreService usage; done means the internal errors no longer leave Firebase queries and routes unusable after unlocking.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, firebase, ios, typescript
Domain
database, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.