Skip to content

Commit 574622a

Browse files
committed
update
1 parent a3f82bd commit 574622a

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/bref/tests/Lambda/LambdaClientTest.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,26 @@ class LambdaClientTest extends TestCase
2222
protected function setUp(): void
2323
{
2424
ob_start();
25-
sleep(5);
26-
Server::start();
25+
26+
$maxRetries = 5;
27+
$attempt = 0;
28+
while ($attempt < $maxRetries) {
29+
try {
30+
Server::start();
31+
break;
32+
} catch (\RuntimeException $runtimeException) {
33+
if ('Unable to contact node.js server' !== $runtimeException->getMessage()) {
34+
throw $runtimeException;
35+
}
36+
37+
++$attempt;
38+
if ($attempt >= $maxRetries) {
39+
throw $runtimeException;
40+
}
41+
\usleep(500000);
42+
}
43+
}
44+
2745
$this->lambda = new LambdaClient('localhost:8126', 'phpunit');
2846
}
2947

0 commit comments

Comments
 (0)