diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index d491b7d75..8293da16b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -960,6 +960,9 @@ App::post('/v1/functions/:functionId/executions') $execution->setAttribute('stderr', $executionResponse['stderr']); $execution->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { + $endtime = \time(); + $time = $endtime - $execution->getAttribute('dateCreated'); + $execution->setAttribute('time', $time); $execution->setAttribute('status', 'failed'); $execution->setAttribute('statusCode', $th->getCode()); $execution->setAttribute('stderr', $th->getMessage()); diff --git a/app/executor.php b/app/executor.php index 7948a73fe..d96e86f7d 100644 --- a/app/executor.php +++ b/app/executor.php @@ -470,7 +470,7 @@ App::post('/v1/execution') case $statusCode >= 500: $stderr = $executorResponse ?? 'Internal Runtime error.'; break; - case $statusCode >= 200: + case $statusCode >= 100: $stdout = $executorResponse; break; default: diff --git a/app/workers/functions.php b/app/workers/functions.php index 2d4cdb2e5..41e685a4d 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -307,6 +307,9 @@ class FunctionsV1 extends Worker $execution->setAttribute('stderr', $executionResponse['stderr']); $execution->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { + $endtime = \time(); + $time = $endtime - $execution->getAttribute('dateCreated'); + $execution->setAttribute('time', $time); $execution->setAttribute('status', 'failed'); $execution->setAttribute('statusCode', $th->getCode()); $execution->setAttribute('stderr', $th->getMessage()); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e26f93ad3..274a9f07b 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -761,7 +761,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($executions['body']['executions'][0]['$id'], $executionId); $this->assertEquals($executions['body']['executions'][0]['trigger'], 'http'); $this->assertEquals($executions['body']['executions'][0]['status'], 'failed'); - $this->assertEquals($executions['body']['executions'][0]['statusCode'], 124); + $this->assertEquals($executions['body']['executions'][0]['statusCode'], 500); $this->assertGreaterThan(2, $executions['body']['executions'][0]['time']); $this->assertLessThan(3, $executions['body']['executions'][0]['time']); $this->assertEquals($executions['body']['executions'][0]['stdout'], '');