-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Neither then() nor catch() executed when request timeout in Safari #294
Comments
Thanks for bringing this to our attention. This seems to be a limitation of XMLHttpRequest in Safari. I'm not sure if there's something we can do about this, but on your end you can definitely install an ad-hoc timeout like suggested here. This will at least ensure that non-routable requests eventually get rejected. |
Thanks for the quick response Mislav, I've gone ahead and filed a bug report for the Safari team at Apple and in the mean time will implement the timeout as you suggested. |
@mislav I think this is asking for: xhr.ontimeout = function() {
reject(new Error('timeout'))
} so that the promise is not trapped in the pending state. @fabioberger What is the |
@dgraham The error returned from the catch in Chrome is:
Full console output: |
Firefox and Chrome trigger the request's `onerror` handler when a timeout occurs. Safari triggers the `ontimeout` handler. This can be observed by making a request to an unroutable address: var xhr = new XMLHttpRequest() xhr.onload = console.log.bind(console, 'loaded') xhr.onerror = console.log.bind(console, 'errored') xhr.ontimeout = console.log.bind(console, 'timeout') xhr.open('GET', 'http://10.255.255.1') xhr.send() Fixes #294.
Firefox and Chrome trigger the request's `onerror` handler when a timeout occurs. Safari triggers the `ontimeout` handler. This can be observed by making a request to an unroutable address: var xhr = new XMLHttpRequest() xhr.onload = console.log.bind(console, 'loaded') xhr.onerror = console.log.bind(console, 'errored') xhr.ontimeout = console.log.bind(console, 'timeout') xhr.open('GET', 'http://10.255.255.1') xhr.send() Fixes #294.
In Safari V9.0.3 (10601.4.4), neither
then()
norcatch()
is called when a request timeout occurs. Instead, Safari prints out the following error to the console:In Chrome V49.0.2623.87 (64-bit), the
catch()
callback is properly executes as expected.Test Script Used:
Without either
then()
orcatch()
being called on timeout, how are we supposed to handle this type of request failure for Safari browsers?The text was updated successfully, but these errors were encountered: