Skip to content

Commit 5f322a7

Browse files
committed
Make sure second alarm is not triggered
1 parent 9824f8a commit 5f322a7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Timeout/Timeout.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ final class Timeout
1010
{
1111
/** @var bool */
1212
private static $initialized = false;
13-
private static $stackTrace;
13+
14+
/** @var string|null */
15+
private static $stackTrace = null;
1416

1517
/**
1618
* Automatically setup a timeout (based on the AWS Lambda timeout).
@@ -70,7 +72,7 @@ private static function init(): void
7072
if (Timeout::$stackTrace !== null) {
7173
// we already thrown an exception.
7274
error_log('Lambda timed out');
73-
error_log((new LambdaTimeout())->getTraceAsString());
75+
error_log((new LambdaTimeout)->getTraceAsString());
7476
error_log('Original stack trace');
7577
error_log(Timeout::$stackTrace);
7678
Timeout::$stackTrace = null;

tests/Timeout/TimeoutTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function test timeouts are interrupted in time()
6060
} catch (LambdaTimeout $e) {
6161
$time = 1000 * (microtime(true) - $start);
6262
$this->assertEqualsWithDelta(2000, $time, 200, 'We must wait about 1 second');
63+
Timeout::reset();
6364
} catch (\Throwable $e) {
6465
$this->fail('It must throw a LambdaTimeout.');
6566
}

0 commit comments

Comments
 (0)