From 3ed275a711a755380ca2bc960dde1c72dc5aa97f Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Wed, 8 Nov 2023 10:00:22 +0100 Subject: [PATCH] Revert "Expose the Lambda context in `LAMBDA_INVOCATION_CONTEXT` in the function runtime" --- src/FunctionRuntime/Main.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/FunctionRuntime/Main.php b/src/FunctionRuntime/Main.php index 11739b958..f6925ca06 100644 --- a/src/FunctionRuntime/Main.php +++ b/src/FunctionRuntime/Main.php @@ -3,7 +3,6 @@ namespace Bref\FunctionRuntime; use Bref\Bref; -use Bref\Context\Context; use Bref\LazySecretsLoader; use Bref\Runtime\LambdaRuntime; use Throwable; @@ -35,17 +34,7 @@ public static function run(): void if (++$loops > $loopMax) { exit(0); } - - $success = $lambdaRuntime->processNextEvent(function ($event, Context $context) use ($handler) { - // Expose the context in an environment variable - // Used for example to retrieve the context in Laravel Queues jobs - $jsonContext = json_encode($context, JSON_THROW_ON_ERROR); - $_SERVER['LAMBDA_INVOCATION_CONTEXT'] = $_ENV['LAMBDA_INVOCATION_CONTEXT'] = $jsonContext; - putenv("LAMBDA_INVOCATION_CONTEXT=$jsonContext"); - - return $handler($event, $context); - }); - + $success = $lambdaRuntime->processNextEvent($handler); // In case the execution failed, we force starting a new process regardless of BREF_LOOP_MAX // Why: an exception could have left the application in a non-clean state, this is preventive if (! $success) {