I make an HTTP call using the Angular HttpClient. The request takes ca. 8 minutes to complete and works fine without service worker. But when activating the Angular service worker, the request is canceled after 5 minutes with the following error object:
HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: 'Unknown Error', url: 'https://app.dbal.dbmc.comp.db.de/frequent/platformservice/10518/lezel/commands/shipmentImport', ok: false, …}
error: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: 'error', …}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)}
message: "Http failure response for https://app.dbal.dbmc.comp.db.de/frequent/platformservice/10518/lezel/commands/shipmentImport: 0 Unknown Error"
name: "HttpErrorResponse"
ok: false
status: 0
statusText: "Unknown Error"
url: "https://app.dbal.dbmc.comp.db.de/frequent/platformservice/10518/lezel/commands/shipmentImport"
In the Chrome network panel, I see two requests, one targeting the service worker (the one which is canceled) and a second one executed by the service worker (this one is not canceled, it has an HTTP 401 error, but that's expected):
I wonder if there is some implicit timeout of 5 minutes concerning HTTP requests done with service workers. Does anyone know how to increase that timeout or what else could be the problem?
The solution for me was to bypass the service worker by adding a special header in an HttpInterceptor:
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const newRequest = request.clone({ headers: request.headers.append('ngsw-bypass', 'true') });
return next.handle(newRequest);
}