-
Notifications
You must be signed in to change notification settings - Fork 27.1k
HttpClient doesn't throw on observable if Chrome cancels a request #22324
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
Current behavior
If Google Chrome cancels a request the HttpClient.get() observable never finishes. This happens for example when you put your computer to sleep (or in our concrete use-case close a laptop).
Expected behavior
The observable should throw just like any other network related request error would.
Minimal reproduction of the problem with instructions
To cancel a request in chrome you have to put your windows into sleep mode (E.g. close laptop). I don't know enough about the pipeline to simulate a request cancelation by hand, so I created a stackblitz where you can simulate a request which takes at least 5s so you have time to put your computer to sleep. You can also provoke a cancelation by simply pressing ctrl+s.
https://stackblitz.com/edit/angular-request-cancelation?file=app/app.component.ts
What is the motivation / use case for changing the behavior?
We have a request which rerstarts itself once it finishes. As a user might close his laptop (put it to sleep) and keep the site open, this request is never restarted. The only feasible workaround for this would be to either detect a browser sleep (unrealiable) or add a timeout to the request (delayed reaction).
Miscellaneous
- The same sleep-problem doesn't seem to exist in other browsers (tested IE11 & FF58) as they don't cancel the request like Chrome does.
- I couldn't find an existing issue talking about this concrete problem, but it might also be related to:
- The sleep of windows (7)
- Google Chrome handling of cancelation
- RxJS
- I also tried these steps to fix this issue, sadly without any success:
- Use new RxJS
pipe()instead of the "old-school" methods (E.g.finally()=>finalize()) - Specify observe: 'response'
- Use new RxJS
- Using my provided stackblitz I got the following warning from Chrome itself:
The FetchEvent for "..." resulted in a network error response: an object that was not a Response was passed to respondWith().Maybe it's a Chrome issue?
Environment
Angular version: 4.4.6 & 5.2.5 & 6.0.2 tested
Browser:
- [x] Chrome (desktop) version 66
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version 58
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version 11
- [ ] Edge version XX
For Tooling issues:
- Node version: 8.9.4
- Platform: Windows
Others:
Windows 7