After an error-response from the server my app does not send any further requests.
I'm sending a request with:
getMachineRules(rules: Array<string>): Observable<RulesResults> {
return this.http.post<RulesResults>('/rules', { nodes: rules })
.pipe(
catchError(this.handleError)
);
}
My errorHandler:
handleError(error) {
if (error.error instanceof ErrorEvent) {
console.error('An error occurred:', error.error.message);
} else {
console.error(
`Backend returned code ${error.status}, ` +
`body was: ${JSON.stringify(error.error)}`);
}
return throwError('Something bad happened; please try again later.');
}
And my pipeline looks like this:
ngAfterViewInit() {
this.rulesChanged
.pipe(
startWith({}),
switchMap(() => {
this.isLoadingResults = true;
return this.settings.getMachineRules(this.currentRules);
}),
map(data => {
this.isLoadingResults = false;
this.resultsLength = data.inputs?.length || 0;
return data;
}),
catchError(e => {
console.log("Error caught");
this.isLoadingResults = false;
this.resultsLength = 0;
return observableOf({ inputs: [] } as RulesResults);
})
).subscribe(
data => { return this.updateRules(data); },
);
}
I can see the "Error caught" message in the console and the method updateRules() seems to work properly even in the error case.
However after a 404-Error-Response the ngAfterViewInit() method is
not called anymore. The UI steel reacts on interactions.
ngAfterViewInitwill not re-trigger thethis.rulesChanged's Observable stream to start again, i think (though i do not know whatthis.rulesChangedlooks like).