Repository navigation
Conversation
default_socket_timeout and mysqlnd.net_read_timeout are lowered to the time left in the invocation minus 2 seconds, in the function, FPM and console runtimes: a network call that never answers fails with an error the application can log and report, instead of being stopped by Lambda.
The layers now set max_execution_time=0 (brefphp/aws-lambda-layers#365).
2 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A network call that never answers (an HTTP API, Redis, a MySQL query) keeps waiting until Lambda stops the invocation: no exception, nothing for Sentry, the framework's error handling never runs. PHP's defaults don't help:
default_socket_timeoutis 60 seconds andmysqlnd.net_read_timeoutis 1 day.Bref now lowers both settings to the time left in the invocation minus 2 seconds, so the call fails with a timeout error the application can handle:
ini_set()before the handler, restored after the invocation,PHP_VALUEon every request (PHP-FPM keeps the values of a request for the next ones),-doptions on the command.They are never raised: a lower value configured in
php.iniis kept. 2 seconds because Bref stops PHP-FPM 1 second before the timeout, which leaves 1 second to handle the error.Signals (
pcntl_alarm(), like #895) can't do this: I tested PHP 8.4 in FPM and in the CLI, and the handler only runs once a blocked connect/curl/PDO call returns.Not covered: curl and Guzzle (including the Laravel HTTP client and the AWS SDK) and PostgreSQL queries, which ignore both settings. The v4 upgrade guide says so, and documents the 20 second database connect timeout added to the bridges in brefphp/laravel-bridge#232 and brefphp/symfony-bridge#87.
Behaviour change, hence v4 only.
The
max_execution_timeTODO inFpmHandleris removed: the layers now setmax_execution_time=0(brefphp/aws-lambda-layers#365), and Bref's own timeout already covers FPM requests, counting the time spent waiting.