From 04933e525515acf2c3c26309bb6cb0da0ffd5b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 4 Jun 2024 21:29:56 +0200 Subject: [PATCH] Retry rendering markdown when hitting rate limit / abuse limit --- config/berti.config.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/config/berti.config.php b/config/berti.config.php index 451d36cb..cd33b429 100644 --- a/config/berti.config.php +++ b/config/berti.config.php @@ -120,12 +120,23 @@ return $cacheItem->get(); } - $html = $renderer( - $content, - $document, - $documentCollection, - $assetCollection - ); + try { + $html = $renderer( + $content, + $document, + $documentCollection, + $assetCollection + ); + } catch (\Exception $e) { + echo 'Temporary error, will retry in 60s: ' . $e->getMessage() . PHP_EOL; + sleep(60); + $html = $renderer( + $content, + $document, + $documentCollection, + $assetCollection + ); + } $cacheItem->set($html); $cache->save($cacheItem);