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

[Bref] Added support for handle timeouts #95

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Oct 6, 2021

We want to give the application some time to cleanup and write logs.

This feature was originally suggested in brefphp/bref#895, but it has not been merged because it did not work with the PHP-FPM layer. We are not using PHP-FPM so we are good to go.

@Nyholm Nyholm marked this pull request as ready for review October 6, 2021 04:09
@Nyholm
Copy link
Member Author

Nyholm commented Oct 6, 2021

After #94 is merged, we should add a version of the following test in LambdaClientTest:

public function testLambdaTimeoutsCanBeAnticipated()
    {
        $this->givenAnEvent([]);

        $start = microtime(true);
        $this->runtime->processNextEvent(function () {
            // This 10s sleep should be interrupted
            sleep(10);
        });

        $elapsedTime = microtime(true) - $start;
        // The Lambda timeout was 2 seconds, we expect the Bref timeout to trigger 1 second before that: 1 second
        $this->assertEqualsWithDelta(1, $elapsedTime, 0.2);
        Timeout::reset();

        $this->assertInvocationErrorResult(LambdaTimeout::class, 'Maximum AWS Lambda execution time reached');
        $this->assertErrorInLogs(LambdaTimeout::class, 'Maximum AWS Lambda execution time reached');
    }

@Nyholm
Copy link
Member Author

Nyholm commented Oct 7, 2021

I reverted some functionality. See ceb19a5. This should be fixed or we need to update the docs.

I get a segfault (9 and 10) in PHP when symfony trying to invoke the error_controller. Im not sure why. It may be related to that we throw an exception in a pcntl_signal-handler. It got randomly (not always) better when I removed the stack trace from the exception.

When I test a small app (as in the current docs) then it works perfectly.. hm..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant