Skip to content

Commit

Permalink
Make sure second alarm is not triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed Mar 30, 2021
1 parent 9824f8a commit 5f322a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Timeout/Timeout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/Timeout/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down

0 comments on commit 5f322a7

Please sign in to comment.