question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Neither then() nor catch() executed when request timeout in Safari

See original GitHub issue

In Safari V9.0.3 (10601.4.4), neither then() nor catch() is called when a request timeout occurs. Instead, Safari prints out the following error to the console:

screen shot 2016-03-11 at 3 43 22 pm

In Chrome V49.0.2623.87 (64-bit), the catch() callback is properly executes as expected.

Test Script Used:

fetch('http://10.255.255.1') // a non-routable IP address
    .then(function(response) {
        console.log("response.ok", response.ok);
    }).catch(function(error) {
        console.log('Failed: ', error)
    });

Without either then() or catch() being called on timeout, how are we supposed to handle this type of request failure for Safari browsers?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fabiobergercommented, Mar 12, 2016

@dgraham The error returned from the catch in Chrome is:

TypeError: Failed to fetch
    at TypeError (native)

Full console output:

screen shot 2016-03-12 at 1 03 38 pm
0reactions
dgrahamcommented, Mar 12, 2016

@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 error object returned by Chrome and Firefox in your catch example?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TimeoutError: Timed out waiting fo… | Apple Developer Forums
I have come across this issue too for me the fix was by closing Xcode and opening it again. then change the ios...
Read more >
jQuery .ajax() does not work in Safari when it takes seconds to ...
Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the...
Read more >
How to Fix the ERR_CONNECTION_TIMED_OUT Error - Kinsta
Right click on your current connection, this will either be Local Area Connection or Wireless Network Connection based on how you're connecting.
Read more >
setTimeout() - Web APIs | MDN
The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
Read more >
Error handling with async/await and promises, n² ... - CatchJS
Will not catch errors thrown in another call stack via a setTimeout() or ... Then we fixed that mess with Promises, and found...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found