Skip to content

Commit

Permalink
Fixed ScrapeAppReviews total being resolved twice in the case where a…
Browse files Browse the repository at this point in the history
…n unrelated exception occurs after successful resoltion.
  • Loading branch information
Bilge committed Jan 19, 2020
1 parent 94496e6 commit 3afef84
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Resource/ScrapeAppReviews.php
Expand Up @@ -47,9 +47,10 @@ public function getProviderClassName(): string
public function fetchAsync(ImportConnector $connector): Iterator
{
$total = new Deferred();
$resolved = false;

return new AsyncGameReviewsRecords(
new Producer(function (\Closure $callable) use ($connector, $total): \Generator {
new Producer(function (\Closure $callable) use ($connector, $total, $resolved): \Generator {
do {
try {
/** @var HttpResponse $response */
Expand All @@ -63,9 +64,14 @@ public function fetchAsync(ImportConnector $connector): Iterator

if (isset($json['review_score'])) {
$total->resolve($this->parseResultsTotal($json['review_score']));
$resolved = true;
}
} catch (\Throwable $throwable) {
$total->fail($throwable);
if (!$resolved) {
$total->fail($throwable);
}

throw $throwable;
}

if ($json['recommendationids']) {
Expand Down

0 comments on commit 3afef84

Please sign in to comment.