Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Oct 29, 2024
1 parent c1a2e53 commit bd70ea8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -1272,26 +1272,20 @@ function (string $runtimeId, ?string $payload, string $path, string $method, mix

// Execute function
$executionRequest = $version === 'v4' ? $executeV4 : $executeV2;

do {
$executionResponse = \call_user_func($executionRequest);
if ($executionResponse['errNo'] === CURLE_OK) {
break;
}

// Retryable errors, runtime not ready
if (in_array($executionResponse['errNo'], [CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT])) {
continue;
}

break;
} while (\microtime(true) - $startTime < $timeout);
} while (
\in_array($executionResponse['errNo'], [CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT]) &&
(\microtime(true) - $startTime < $timeout)
);

// Error occurred
if ($executionResponse['errNo'] !== CURLE_OK) {
$log->addExtra('activeRuntime', $activeRuntimes->get($runtimeName));
$log->addExtra('error', $executionResponse['error']);
$log->addTag('hostname', $hostname);

// Intended timeout error for v2 functions
if ($version === 'v2' && $executionResponse['errNo'] === SOCKET_ETIMEDOUT) {
throw new Exception($executionResponse['error'], 400);
}
Expand Down

0 comments on commit bd70ea8

Please sign in to comment.