Increase JS requests timeout

This commit is contained in:
Alexandre Archambault 2015-06-26 18:15:55 +02:00
parent 4e0094f12d
commit 91e39421d2
1 changed files with 7 additions and 1 deletions

View File

@ -19,13 +19,19 @@ object Fetch {
lazy val jsonpAvailable = !js.isUndefined(g.jsonp)
val timeout =
if (jsonpAvailable)
10000 // Browser - better to have it > 5000 for complex resolutions
else
4000 // Node - tests crash if not < 5000
/** Available if we're running on node, and package xhr2 is installed */
lazy val xhr = g.require("xhr2")
def xhrReq() =
js.Dynamic.newInstance(xhr)().asInstanceOf[XMLHttpRequest]
def fetchTimeout(target: String, p: Promise[_]) =
setTimeout(5000) {
setTimeout(timeout) {
if (!p.isCompleted) {
p.failure(new Exception(s"Timeout when fetching $target"))
}