diff --git a/src/Runtime/Handlers/FpmHandler.php b/src/Runtime/Handlers/FpmHandler.php index aa42bb4..8bdc652 100644 --- a/src/Runtime/Handlers/FpmHandler.php +++ b/src/Runtime/Handlers/FpmHandler.php @@ -12,7 +12,6 @@ class FpmHandler implements LambdaEventHandler /** * Handle an incoming Lambda event. * - * @param array $event * @return \Laravel\Vapor\Contracts\LambdaResponse */ public function handle(array $event) diff --git a/stubs/fpmRuntime.php b/stubs/fpmRuntime.php index 06c921c..9f04bb9 100644 --- a/stubs/fpmRuntime.php +++ b/stubs/fpmRuntime.php @@ -1,10 +1,13 @@ nextInvocation(function ($invocationId, $event) { - return FpmHttpHandlerFactory::make($event) - ->handle($event) - ->toApiGatewayFormat(); + try { + return FpmHttpHandlerFactory::make($event) + ->handle($event) + ->toApiGatewayFormat(); + } catch (WriteFailedException $e) { + if (Str::contains($e->getMessage(), 'Failed to write request to socket [broken pipe]')) { + function_exists('__vapor_debug') && __vapor_debug($e->getMessage()); + + return (new LambdaResponse(403, [], '')) + ->toApiGatewayFormat(); + } + + throw $e; + } }); $fpm->ensureRunning();