Skip to content

Commit

Permalink
CLI-1286: [app:task-wait] typeerror for invalid notification uuid (#1703
Browse files Browse the repository at this point in the history
)
  • Loading branch information
danepowell authored Mar 15, 2024
1 parent b3e3455 commit f865c67
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ protected function waitForNotificationToComplete(Client $acquiaCloudClient, stri
$this->writeCompletedMessage($notification);
};
}
LoopHelper::getLoopy($this->output, $this->io, $this->logger, $message, $checkNotificationStatus, $success);
LoopHelper::getLoopy($this->output, $this->io, $message, $checkNotificationStatus, $success);
return $notification->status === 'completed';
}

Expand Down
4 changes: 2 additions & 2 deletions src/Command/Ide/IdeCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function waitForDnsPropagation(string $ideUrl): int {
$checkIdeStatus = function () use (&$ideCreated, $ideUrl) {
// Ideally we'd set $ideUrl as the Guzzle base_url, but that requires creating a client factory.
// @see https://stackoverflow.com/questions/28277889/guzzlehttp-client-change-base-url-dynamically
$response = $this->httpClient->request('GET', "$ideUrl/health");
$response = $this->httpClient->request('GET', "$ideUrl/health", ['http_errors' => FALSE]);
// Mutating this will result in an infinite loop and timeout.
// @infection-ignore-all
if ($response->getStatusCode() === 200) {
Expand All @@ -119,7 +119,7 @@ private function waitForDnsPropagation(string $ideUrl): int {
$this->writeIdeLinksToScreen();
};
$spinnerMessage = 'Waiting for the IDE to be ready. This usually takes 2 - 15 minutes.';
LoopHelper::getLoopy($this->output, $this->io, $this->logger, $spinnerMessage, $checkIdeStatus, $doneCallback);
LoopHelper::getLoopy($this->output, $this->io, $spinnerMessage, $checkIdeStatus, $doneCallback);

return Command::SUCCESS;
}
Expand Down
19 changes: 6 additions & 13 deletions src/Helpers/LoopHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace Acquia\Cli\Helpers;

use Acquia\Cli\Output\Spinner\Spinner;
use Exception;
use Psr\Log\LoggerInterface;
use React\EventLoop\Loop;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
Expand All @@ -16,7 +14,7 @@ class LoopHelper {
/**
* @param callable $statusCallback A TRUE return value will cause the loop to exit and call $doneCallback.
*/
public static function getLoopy(OutputInterface $output, SymfonyStyle $io, LoggerInterface $logger, string $spinnerMessage, callable $statusCallback, callable $doneCallback): void {
public static function getLoopy(OutputInterface $output, SymfonyStyle $io, string $spinnerMessage, callable $statusCallback, callable $doneCallback): void {
$timers = [];
$spinner = new Spinner($output, 4);
$spinner->setMessage($spinnerMessage);
Expand All @@ -28,16 +26,11 @@ public static function getLoopy(OutputInterface $output, SymfonyStyle $io, Logge
$timers = [];
$spinner->finish();
};
$periodicCallback = static function () use ($logger, $statusCallback, $doneCallback, $cancelTimers): void {
try {
// @infection-ignore-all
if ($statusCallback()) {
$cancelTimers();
$doneCallback();
}
}
catch (Exception $e) {
$logger->debug($e->getMessage());
$periodicCallback = static function () use ($statusCallback, $doneCallback, $cancelTimers): void {
// @infection-ignore-all
if ($statusCallback()) {
$cancelTimers();
$doneCallback();
}
};

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Ide/IdeCreateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testCreate(): void {
/** @var \Prophecy\Prophecy\ObjectProphecy|\GuzzleHttp\Psr7\Response $guzzleResponse */
$guzzleResponse = $this->prophet->prophesize(Response::class);
$guzzleResponse->getStatusCode()->willReturn(200);
$this->httpClientProphecy->request('GET', 'https://215824ff-272a-4a8c-9027-df32ed1d68a9.ides.acquia.com/health')->willReturn($guzzleResponse->reveal())->shouldBeCalled();
$this->httpClientProphecy->request('GET', 'https://215824ff-272a-4a8c-9027-df32ed1d68a9.ides.acquia.com/health', ['http_errors' => FALSE])->willReturn($guzzleResponse->reveal())->shouldBeCalled();

$inputs = [
// Would you like Acquia CLI to search for a Cloud application that matches your local git config?
Expand Down

0 comments on commit f865c67

Please sign in to comment.