Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$http promise does not settle when the connection attempt times out on current Safari #14969

Closed
ceckerle opened this issue Jul 30, 2016 · 0 comments

Comments

@ceckerle
Copy link

When using $http to connect to a server which does no react to the TCP connection attempts at all on a current Safari browser, the promise never gets settled. On other browsers it gets rejected after some time as expected.

It can be reproduced using angular 1.5.8 and the following code on Safari 9.1.2, OS X 10.11.6:

$http({
  method: "GET",
  url: "http://github.com:12345/"
}).finally(function (result) {
  console.log("settled");
});

The cause seems to be that the current Safari version invokes the ontimeout handler on the XHR object in this case even though no timeout has been set on it. (https://xhr.spec.whatwg.org/#the-timeout-attribute). Attaching the ontimeout handler in addition to onerror and onabort in $httpBackend fixes the issue.

@gkalpak gkalpak added this to the Backlog milestone Jul 31, 2016
gkalpak added a commit to gkalpak/angular.js that referenced this issue Jul 31, 2016
When using the [timeout attribute](https://xhr.spec.whatwg.org/#the-timeout-attribute) and an XHR
request times out, browsers trigger the `timeout` event (and execute the XHR's `ontimeout`
callback). Additionally, Safari 9 handles timed-out requests in the same way, even if no `timeout`
has been explicitly set on the XHR.
In the above cases, `$httpBackend` would fail to capture the XHR's completing (with an error), so
the corresponding `$http` promise would never get fulfilled.

Fixes angular#14969
@gkalpak gkalpak closed this as completed in fdf8e0f Aug 8, 2016
gkalpak added a commit that referenced this issue Aug 8, 2016
When using the [timeout attribute](https://xhr.spec.whatwg.org/#the-timeout-attribute) and an XHR
request times out, browsers trigger the `timeout` event (and execute the XHR's `ontimeout`
callback). Additionally, Safari 9 handles timed-out requests in the same way, even if no `timeout`
has been explicitly set on the XHR.
In the above cases, `$httpBackend` would fail to capture the XHR's completing (with an error), so
the corresponding `$http` promise would never get fulfilled.

Note that using `$http`'s `timeout` configuration option does **not** rely on the XHR's `timeout`
property (or its `ontimeout` callback).

Fixes #14969
Closes #14972
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants