diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 2861ae40c3..4c41c8bd34 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1708,7 +1708,8 @@ App::post('/v1/functions/:functionId/executions') path: $path, method: $method, headers: $headers, - runtimeEntrypoint: $command + runtimeEntrypoint: $command, + requestTimeout: 30 ); $headersFiltered = []; diff --git a/app/controllers/general.php b/app/controllers/general.php index b2b3d37471..bc21da50dd 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -139,6 +139,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // \curl_setopt($ch, CURLOPT_HEADER, true); \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + \curl_setopt($ch, CURLOPT_TIMEOUT, 30); $executionResponse = \curl_exec($ch); $statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE); diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index d81a4048c2..4b68cc5233 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -177,6 +177,7 @@ class Executor string $method, array $headers, string $runtimeEntrypoint = null, + int $requestTimeout = null ) { if (empty($headers['host'])) { $headers['host'] = App::getEnv('_APP_DOMAIN', ''); @@ -204,9 +205,11 @@ class Executor // Safety timeout. Executor has timeout, and open runtime has soft timeout. // This one shouldn't really happen, but prevents from unexpected networking behaviours. - $timeout = $timeout + 15; + if ($requestTimeout == null) { + $requestTimeout = $timeout + 15; + } - $response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout); + $response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $requestTimeout); $status = $response['headers']['status-code']; if ($status >= 400) {