diff --git a/src/FpmRuntime/FpmHandler.php b/src/FpmRuntime/FpmHandler.php index c1b0049fd..8c1befdf3 100644 --- a/src/FpmRuntime/FpmHandler.php +++ b/src/FpmRuntime/FpmHandler.php @@ -148,7 +148,9 @@ public function handleRequest(HttpRequestEvent $event, Context $context): HttpRe $response = $this->client->readResponse($socketId, $timeoutDelayInMs); } catch (TimedoutException) { $invocationId = $context->getAwsRequestId(); - echo "$invocationId The PHP script timed out. Bref will now restart PHP-FPM to start from a clean slate and flush the PHP logs.\nTimeouts can happen for example when trying to connect to a remote API or database, if this happens continuously check for those.\nIf you are using a RDS database, read this: https://bref.sh/docs/environment/database.html#accessing-the-internet\n"; + echo "$invocationId The PHP script timed out. Bref will now restart PHP-FPM to start from a clean slate and flush the PHP logs. " + . 'Timeouts can happen for example when trying to connect to a remote API or database, if this happens continuously check for those. ' + . "If you are using a RDS database, read this: https://bref.sh/docs/environment/database#vpc-databases-private-network\n"; /** * Restart FPM so that the blocked script is 100% terminated and that its logs are flushed to stderr. diff --git a/tests/FpmRuntime/FpmHandlerTest.php b/tests/FpmRuntime/FpmHandlerTest.php index 840e8ba0a..f3e143f7e 100644 --- a/tests/FpmRuntime/FpmHandlerTest.php +++ b/tests/FpmRuntime/FpmHandlerTest.php @@ -1221,6 +1221,9 @@ public function test FPM timeouts are recovered from() ], $this->fakeContext); $this->fail('No exception was thrown'); } catch (Timeout $e) { + // A single line starting with the request ID: Lambda turns each line into a separate log event + self::assertMatchesRegularExpression('/^abc The PHP script timed out\. [^\n]+\n$/', ob_get_contents()); + // PHP-FPM should work after that $statusCode = $this->fpm->handle([ 'version' => '1.0',