这是indexloc提供的服务,不要输入任何密码
Skip to content

Firestore enablePersistence(): “Error enabling offline persistence. Falling back to persistence disabled” #2404

@kebarvid

Description

@kebarvid

Describe your environment

  • Operating System version: All tested (Win10, OSX El capitain)
  • Browser version: Latest Chrome 6 Firefox
  • Firebase SDK version: 7.5.0
  • Firebase Product: Firestore

Describe the problem

I'm making a PWA app with Ionic 4 (angular) and Firebase Cloud Firestore as database. And it was working fine until just now when i wanted to enable offline persistance. Using AngularFire and the docs is not hard to follow. This is is how i enable it in my app-module.ts

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule,
    ComponentsModule,
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFirestoreModule.enablePersistence(), // <- Trying to enable here
    AngularFireAuthModule,
  ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
  ],
  providers: [
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
    GlobalService
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

When i run the app i get this warning in Chrome Developer Tools:

Error enabling offline persistence. Falling back to persistence disabled: TypeError: Cannot read property 'USE_MOCK_PERSISTENCE' of undefined

and a similar one in Firefox:

Error enabling offline persistence. Falling back to persistence disabled: TypeError: process.env is undefined

Steps to reproduce:

enable it in app.module.ts with:

AngularFirestoreModule.enablePersistence()

Relevant Code:

You can se the error live @ https://cubetrainer.nu

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions