INNER CODE UNIT · TypeScript

startBackgroundSync

Beever-AI/beever-atlas · bot/src/index.ts:800

function startBackgroundSync(chatManager: ChatManager): void {
  if (backgroundSyncTimer) return;

  backgroundSyncTimer = setInterval(async () => {
    // Skip if a sync is already in progress
    if (backgroundSyncRunning) return;

    // Only sync when the bot has no adapters (self-healing) or backend may have
    // new connections. Always attempt when adapter count is 0.
    if (chatManager.adapterCount() > 0) {
      // Still attempt periodically to pick up new connections, but only if
      // the backend is healthy (cheap check avoids unnecessary errors in logs)
      const healthy = await isBackendHealthy();
      if (!healthy) return;
    }

    backgroundSyncRunning = true;
    try {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…