The following changes were made by the replace_file_content tool to: /root/MayaXSenderbot/bridge.py. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -2222,6 +2222,7 @@ async def _watch_firebase(self, user_id: str) -> None: poll_interval = self.default_poll_interval + consecutive_errors = 0 while True: try: @@ -2234,6 +2234,13 @@ continue fb = normalize_firebase_url(ws.firebase_url) + if not fb: + log(f"[fb poll {user_id}] Invalid or empty Firebase URL ({ws.firebase_url}). Auto-pausing.") + ws.active = False + self.save_workspace(ws) + await self.send(user_id, fmt_msg("Firebase Paused", "⚠️ **Firebase URL is invalid.** Setup paused automatically to prevent server errors.", error=True)) + break + url = f"{fb}/messages/{ws.device_id}.json" if ws.firebase_auth: url += f"?auth={ws.firebase_auth}" @@ -2251,6 +2251,13 @@ ws.last_processed_ts = max(0, cutoff_ts - 5000) self.save_workspace(ws) elif seed.status in (401, 403, 404, 423): + consecutive_errors += 1 + if consecutive_errors >= 6: + log(f"[fb poll {user_id}] Seed HTTP {seed.status} repeated. Auto-pausing.") + ws.active = False + self.save_workspace(ws) + await self.send(user_id, fmt_msg("Firebase Paused", f"⚠️ Database returned HTTP {seed.status}. Paused automatically.", error=True)) + break await asyncio.sleep(20) continue await asyncio.sleep(poll_interval) @@ -2257,7 +2257,14 @@ async with self.http.get(url, timeout=10) as r: if r.status != 200: + consecutive_errors += 1 if r.status in (401, 403, 404, 423): + if consecutive_errors >= 6: + log(f"[fb poll {user_id}] Persistent HTTP {r.status} error ({consecutive_errors} times). Auto-pausing.") + ws.active = False + self.save_workspace(ws) + await self.send(user_id, fmt_msg("Firebase Paused", f"⚠️ Database returned HTTP {r.status} repeatedly. Paused automatically.", error=True)) + break await asyncio.sleep(20) else: await asyncio.sleep(poll_interval) @@ -2272,6 +2272,7 @@ await asyncio.sleep(poll_interval) continue + consecutive_errors = 0 changed = False for ts_str in sorted(data.keys()): try: @@ -2307,8 +2307,15 @@ except asyncio.CancelledError: break except Exception as exc: + consecutive_errors += 1 err_text = str(exc).lower() if "name or service not known" in err_text or "cannot connect to host" in err_text or "nodename" in err_text: + if consecutive_errors >= 5: + log(f"[fb poll {user_id}] Persistent host failure. Auto-pausing.") + ws.active = False + self.save_workspace(ws) + await self.send(user_id, fmt_msg("Firebase Paused", "⚠️ Host domain could not be reached repeatedly. Paused automatically.", error=True)) + break log(f"[fb poll {user_id}] Host connection/lookup failed: {exc}. Backing off 30s...") await asyncio.sleep(30) else: [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.