diff --git a/src/Timeout/Timeout.php b/src/Timeout/Timeout.php index 8bbd9a582..275fbdf4f 100644 --- a/src/Timeout/Timeout.php +++ b/src/Timeout/Timeout.php @@ -10,7 +10,9 @@ final class Timeout { /** @var bool */ private static $initialized = false; - private static $stackTrace; + + /** @var string|null */ + private static $stackTrace = null; /** * Automatically setup a timeout (based on the AWS Lambda timeout). @@ -70,7 +72,7 @@ private static function init(): void if (Timeout::$stackTrace !== null) { // we already thrown an exception. error_log('Lambda timed out'); - error_log((new LambdaTimeout())->getTraceAsString()); + error_log((new LambdaTimeout)->getTraceAsString()); error_log('Original stack trace'); error_log(Timeout::$stackTrace); Timeout::$stackTrace = null; diff --git a/tests/Timeout/TimeoutTest.php b/tests/Timeout/TimeoutTest.php index f52774172..4bc06085e 100644 --- a/tests/Timeout/TimeoutTest.php +++ b/tests/Timeout/TimeoutTest.php @@ -60,6 +60,7 @@ public function test timeouts are interrupted in time() } catch (LambdaTimeout $e) { $time = 1000 * (microtime(true) - $start); $this->assertEqualsWithDelta(2000, $time, 200, 'We must wait about 1 second'); + Timeout::reset(); } catch (\Throwable $e) { $this->fail('It must throw a LambdaTimeout.'); }