提交 35896c51 编写于 作者: D David Graham 提交者: Mislav Marohnić

Reject promise on request timeout

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.
上级 8deb8296
......@@ -368,6 +368,10 @@
reject(new TypeError('Network request failed'))
}
xhr.ontimeout = function() {
reject(new TypeError('Network request failed'))
}
xhr.open(request.method, request.url, true)
if (request.credentials === 'include') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册