Introduce execution sync timeout

This commit is contained in:
Matej Bačo 2023-09-30 11:54:54 +02:00
parent c27d5cb721
commit d9f2f1c37b
3 changed files with 8 additions and 3 deletions

View file

@ -1708,7 +1708,8 @@ App::post('/v1/functions/:functionId/executions')
path: $path,
method: $method,
headers: $headers,
runtimeEntrypoint: $command
runtimeEntrypoint: $command,
requestTimeout: 15
);
$headersFiltered = [];

View file

@ -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, 15);
$executionResponse = \curl_exec($ch);
$statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE);

View file

@ -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) {