Skip to content

Commit 8705084

Browse files
committed
Retry rendering markdown when hitting rate limit / abuse limit
1 parent 0baac1d commit 8705084

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/data.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ function components(Client $client, CacheItemPoolInterface $markdownCache): arra
4343
if ($cacheItem->isHit()) {
4444
$html = $cacheItem->get();
4545
} else {
46-
$html = $client->markdown()->render(
47-
$release['body'],
48-
'gfm',
49-
$component['repository']
50-
);
46+
try{
47+
$html = $client->markdown()->render(
48+
$release['body'],
49+
'gfm',
50+
$component['repository']
51+
);
52+
} catch (\Exception $e) {
53+
echo 'Temporary error, will retry in 60s: ' . $e->getMessage() . PHP_EOL;
54+
sleep(60);
55+
$html = $client->markdown()->render(
56+
$release['body'],
57+
'gfm',
58+
$component['repository']
59+
);
60+
}
5161

5262
$cacheItem->set($html);
5363
$markdownCache->save($cacheItem);

0 commit comments

Comments
 (0)