I have a long-living QueryRef with its valueChanges observable and periodically refetch it with new filter conditions (variables). In default configuration any server error results in that observable to error out and stop. To recover from server errors I use {errorPolicy: ‘all’}. Then I split the stream into data and errors like that:
const [lItems, lErrors] =
partition(this.query.valueChanges,
x=> x?.errors === undefined && x?.error === undefined)
this.items$ = lItems.pipe(
map(({ data }) => data[this.dataName])
);
this.errors$ = lErrors.pipe(
map(({ error, errors }) =>
[... error?.message ?? [], ...errors.map(e => e.message)])
)
Then the former stream updates the UI with new data (if any) and the latter shows messages using “toasts” (it’s Angular Ionic mobile app).
But when a network error occurs than I don’t get any value in the valueChanges observable, it just errors out and stops.
How can I catch that network errors and continue to use the same valueChanges observable?
Looking in the source code reveals that logical errors can be passed using the policy but network errors are just always throw (see here).