Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Expose the Lambda context in LAMBDA_INVOCATION_CONTEXT in the function runtime" #1685

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/FunctionRuntime/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Bref\FunctionRuntime;

use Bref\Bref;
use Bref\Context\Context;
use Bref\LazySecretsLoader;
use Bref\Runtime\LambdaRuntime;
use Throwable;
Expand Down Expand Up @@ -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) {
Expand Down
Loading