From 6ce36e7a2476151dec6ef31f6997bc5fa593a8fa Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 10 Dec 2025 21:04:38 +0530 Subject: [PATCH] removed retry block for realtime startup collection check infite loop --- app/realtime.php | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index 734dcd70bb..422b0b3092 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -296,26 +296,34 @@ $server->onStart(function () use ($stats, $register, $containerId, &$statsDocume go(function () use ($register, $containerId, &$statsDocument) { $attempts = 0; $database = getConsoleDB(); + $document = new Document([ + '$id' => ID::unique(), + '$collection' => ID::custom('realtime'), + '$permissions' => [], + 'container' => $containerId, + 'timestamp' => DateTime::now(), + 'value' => '{}' + ]); + try { + $statsDocument = Authorization::skip(fn () => $database->createDocument('realtime', $document)); + } catch (\Exception $e) { + $logger = $register->get('realtimeLogger'); + if ($logger) { + $log = new Log(); + $log->setNamespace("http"); + $log->setServer(System::getEnv('_APP_LOGGING_SERVICE_IDENTIFIER', \gethostname())); + $log->setVersion(System::getEnv('_APP_VERSION', 'UNKNOWN')); + $log->setType(Log::TYPE_ERROR); - do { - try { - $attempts++; - $document = new Document([ - '$id' => ID::unique(), - '$collection' => ID::custom('realtime'), - '$permissions' => [], - 'container' => $containerId, - 'timestamp' => DateTime::now(), - 'value' => '{}' - ]); + $log->setMessage($e->getMessage()); - $statsDocument = Authorization::skip(fn () => $database->createDocument('realtime', $document)); - break; - } catch (Throwable) { - Console::warning("Collection not ready. Retrying connection ({$attempts})..."); - sleep(DATABASE_RECONNECT_SLEEP); + $log->addExtra('file', $e->getFile()); + $log->addExtra('line', $e->getLine()); + $log->addExtra('trace', $e->getTraceAsString()); + + $logger->addLog($log); } - } while (true); + } }); /**