mirror of https://github.com/sbt/sbt.git
Increase JS requests timeout
This commit is contained in:
parent
4e0094f12d
commit
91e39421d2
|
|
@ -19,13 +19,19 @@ object Fetch {
|
||||||
|
|
||||||
lazy val jsonpAvailable = !js.isUndefined(g.jsonp)
|
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 */
|
/** Available if we're running on node, and package xhr2 is installed */
|
||||||
lazy val xhr = g.require("xhr2")
|
lazy val xhr = g.require("xhr2")
|
||||||
def xhrReq() =
|
def xhrReq() =
|
||||||
js.Dynamic.newInstance(xhr)().asInstanceOf[XMLHttpRequest]
|
js.Dynamic.newInstance(xhr)().asInstanceOf[XMLHttpRequest]
|
||||||
|
|
||||||
def fetchTimeout(target: String, p: Promise[_]) =
|
def fetchTimeout(target: String, p: Promise[_]) =
|
||||||
setTimeout(5000) {
|
setTimeout(timeout) {
|
||||||
if (!p.isCompleted) {
|
if (!p.isCompleted) {
|
||||||
p.failure(new Exception(s"Timeout when fetching $target"))
|
p.failure(new Exception(s"Timeout when fetching $target"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue