diff --git a/src/applications/doorkeeper/bridge/DoorkeeperBridge.php b/src/applications/doorkeeper/bridge/DoorkeeperBridge.php --- a/src/applications/doorkeeper/bridge/DoorkeeperBridge.php +++ b/src/applications/doorkeeper/bridge/DoorkeeperBridge.php @@ -5,6 +5,16 @@ private $viewer; private $context = array(); private $throwOnMissingLink; + private $timeout; + + public function setTimeout($timeout) { + $this->timeout = $timeout; + return $this; + } + + public function getTimeout() { + return $this->timeout; + } public function setThrowOnMissingLink($throw_on_missing_link) { $this->throwOnMissingLink = $throw_on_missing_link; diff --git a/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php b/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php --- a/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php +++ b/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php @@ -62,6 +62,11 @@ $template = id(new PhutilAsanaFuture()) ->setAccessToken($token); + $timeout = $this->getTimeout(); + if ($timeout !== null) { + $template->setTimeout($timeout); + } + $futures = array(); foreach ($id_map as $key => $id) { $futures[$key] = id(clone $template) diff --git a/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php b/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php --- a/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php +++ b/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php @@ -47,12 +47,20 @@ // (by querying all instances). For now, just query the one instance. $account = head($accounts); + $timeout = $this->getTimeout(); + $futures = array(); foreach ($id_map as $key => $id) { - $futures[$key] = $provider->newJIRAFuture( + $future = $provider->newJIRAFuture( $account, 'rest/api/2/issue/'.phutil_escape_uri($id), 'GET'); + + if ($timeout !== null) { + $future->setTimeout($timeout); + } + + $futures[$key] = $future; } $results = array(); diff --git a/src/applications/doorkeeper/controller/DoorkeeperTagsController.php b/src/applications/doorkeeper/controller/DoorkeeperTagsController.php --- a/src/applications/doorkeeper/controller/DoorkeeperTagsController.php +++ b/src/applications/doorkeeper/controller/DoorkeeperTagsController.php @@ -26,6 +26,7 @@ $refs = id(new DoorkeeperImportEngine()) ->setViewer($viewer) ->setRefs($refs) + ->setTimeout(15) ->execute(); $results = array(); diff --git a/src/applications/doorkeeper/engine/DoorkeeperImportEngine.php b/src/applications/doorkeeper/engine/DoorkeeperImportEngine.php --- a/src/applications/doorkeeper/engine/DoorkeeperImportEngine.php +++ b/src/applications/doorkeeper/engine/DoorkeeperImportEngine.php @@ -8,6 +8,7 @@ private $localOnly; private $throwOnMissingLink; private $context = array(); + private $timeout; public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; @@ -43,6 +44,15 @@ return $this; } + public function setTimeout($timeout) { + $this->timeout = $timeout; + return $this; + } + + public function getTimeout() { + return $this->timeout; + } + /** * Configure behavior if remote refs can not be retrieved because an * authentication link is missing. @@ -98,10 +108,16 @@ ->setFilterMethod('isEnabled') ->execute(); + $timeout = $this->getTimeout(); foreach ($bridges as $key => $bridge) { - $bridge->setViewer($viewer); - $bridge->setThrowOnMissingLink($this->throwOnMissingLink); - $bridge->setContext($this->context); + $bridge + ->setViewer($viewer) + ->setThrowOnMissingLink($this->throwOnMissingLink) + ->setContext($this->context); + + if ($timeout !== null) { + $bridge->setTimeout($timeout); + } } $working_set = $refs;