-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Angular: 11
Firebase: 8.2.1
AngularFire: 6.1.4
How to reproduce these conditions
This works as expected in NON-SSR mode, to query once a given collection:
this.firestore.collection<T>('collection', ref => ref.limit(5))
.get()
.pipe(
map((qs: firebase.firestore.QuerySnapshot) => qs.empty ? [] : qs.docs.map(d => d.data() as T)),
);
When switching to SSR, the above code leads to the express server hanging, and the client see a 'pending' query that never completes, or hits a timeout and leaves the page partially rendered (i.e. without the results of that query).
This is the best workaround I found:
this.firestore.collection<T>('collection', ref => ref.limit(5))
.valueChanges() <<<<
.pipe(
take(2), <<<<
);
Though this more sane workaround also fails:
this.firestore.collection<T>('collection', ref => ref.limit(5))
.valueChanges()
.pipe(
take(1), <<<<
);
More details about exact version used here:
https://stackoverflow.com/questions/65388261/angular-11-firebase-server-side-rendering-infinite-loading-pending/65388376#65388376
Expected behavior
The first version should work without the workaround, without and with SSR.
Actual behavior
Without the workaround, the express server hangs indefinitely.
Related issues:
firebase/firebase-js-sdk#3541
firebase/firebase-js-sdk#3542
angular/universal#1711