-
Notifications
You must be signed in to change notification settings - Fork 830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add networkTimeoutSeconds to NetworkOnly strategy #2030
Comments
Fair enough—and in that scenario, you'd be fine with a |
@jeffposnick Yes. Imho it's better to let the user know something went wrong in a reasonable time than just keep some progress indicator spinning forever :-) Example:
|
Just to be clear, though, there really should be a reasonable timeout imposed by the user agent by default. If the current per-browser defaults aren't reasonable, that's good feedback to pass along to browsers that wait too long. I'm happy to have folks turn to Workbox to give them more control when they want to override those defaults for specific types of requests, but obviously not everyone is going to use Workbox, and a service worker will likely not be in control during the user's first visit to a site. |
@jeffposnick In case of PWA, a service worker intercepts all network calls (including old fashioned XHRs), which means Fetch API (that has no timeout support - unlike XHR) cannot be easily avoided. Therefore |
Here's an example of more proper implementation - which aborts timeouted requests, if possible:
|
Chrome on mobile takes 5 minutes(!) to display the offline dino when mobile data is off or flight mode is on. This is probably good as it allows to test for poor connection. The fetch call does not throw in this case though. This makes Network My specific use case is about POST requests. Being able to cancel the request if the timeout occurred is crucial. According to caniuse.com Safari 11-12 is the only browser supporting ServieWorkers that has issues with AbortController. Not sure what a solution would be in this case. Also navigation requests have special handling in workbox currently (see #1796 and #1862) which would make the use of the AbortController fail silently in this case. |
At present, it is possible to set timeout only for
NetworkFirst
strategy:When
NetworkOnly
strategy is used to retrieve non-cacheable data, it keeps waiting indefinitely in case of a network issue.Suggested implementation: JakeChampion/fetch#175 (comment)
The text was updated successfully, but these errors were encountered: