diff --git a/app/config/collections.php b/app/config/collections.php index ecbe92c33..f1ea8fed9 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2386,6 +2386,17 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => 'stdout', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 1000000, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => 'statusCode', 'type' => Database::VAR_INTEGER, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 21b827042..bc0edc02d 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -945,6 +945,7 @@ App::post('/v1/functions/:functionId/executions') $execution->setAttribute('status', $executionResponse['status']); $execution->setAttribute('statusCode', $executionResponse['statusCode']); $execution->setAttribute('response', $executionResponse['response']); + $execution->setAttribute('stdout', $executionResponse['stdout']); $execution->setAttribute('stderr', $executionResponse['stderr']); $execution->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { diff --git a/app/executor.php b/app/executor.php index 22d855263..8d4bf9a00 100644 --- a/app/executor.php +++ b/app/executor.php @@ -488,6 +488,7 @@ App::post('/v1/execution') $executionStart = \microtime(true); $stdout = ''; $stderr = ''; + $res = ''; $statusCode = 0; $errNo = -1; $executorResponse = ''; @@ -538,13 +539,16 @@ App::post('/v1/execution') switch (true) { case $statusCode >= 500: - $stderr = $executorResponse ?? 'Internal Runtime error.'; + $stderr = ($executorResponse ?? [])['stderr'] ?? 'Internal Runtime error.'; + $stdout = ($executorResponse ?? [])['stdout'] ?? 'Internal Runtime error.'; break; case $statusCode >= 100: - $stdout = $executorResponse; + $stdout = $executorResponse['stdout']; + $res = $executorResponse['response']; break; default: - $stderr = $executorResponse ?? 'Execution failed.'; + $stderr = ($executorResponse ?? [])['stderr'] ?? 'Execution failed.'; + $stdout = ($executorResponse ?? [])['stdout'] ?? ''; break; } @@ -557,7 +561,8 @@ App::post('/v1/execution') $execution = [ 'status' => $functionStatus, 'statusCode' => $statusCode, - 'response' => \mb_strcut($stdout, 0, 1000000), // Limit to 1MB + 'response' => \mb_strcut($res, 0, 1000000), // Limit to 1MB + 'stdout' => \mb_strcut($stdout, 0, 1000000), // Limit to 1MB 'stderr' => \mb_strcut($stderr, 0, 1000000), // Limit to 1MB 'time' => $executionTime, ]; diff --git a/app/workers/functions.php b/app/workers/functions.php index 55d71ef36..8c0716665 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -293,6 +293,7 @@ class FunctionsV1 extends Worker ->setAttribute('status', $executionResponse['status']) ->setAttribute('statusCode', $executionResponse['statusCode']) ->setAttribute('response', $executionResponse['response']) + ->setAttribute('stdout', $executionResponse['stdout']) ->setAttribute('stderr', $executionResponse['stderr']) ->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) {