Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Ephemeral/EphemeralHypernodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function waitForAvailability(string $ephemeralHypernode, int $timeout = 9
$latest = microtime(true);
$timeElapsed = 0;
$resolved = false;
$interval = 3;
$allowedErrorWindow = 3;

while ($timeElapsed < $timeout && !$resolved) {
$now = microtime(true);
Expand All @@ -76,10 +78,19 @@ public function waitForAvailability(string $ephemeralHypernode, int $timeout = 9
// Otherwise, there's an error, and it should be propagated.
if ($e->getCode() !== 404) {
throw $e;
} elseif ($timeElapsed < $allowedErrorWindow) {
// Sometimes we get an error where the logbook is not yet available, but it will be soon.
// We allow a small window for this to happen, and then we throw an exception.
sprintf(
'Got an expected exception during the allowed error window of HTTP code %d, waiting for %s to become available',
$e->getCode(),
$ephemeralHypernode
);
continue;
}
}

sleep(5);
sleep($interval);
}

if (!$resolved) {
Expand Down