-
Notifications
You must be signed in to change notification settings - Fork 151
Description
Based on recent testing and deployment observations, I have identified a critical challenge regarding the stability of Gemini authentication. The Google Gemini cookies, specifically the __Secure-1PSIDTS token, appear to rotate and expire with high frequency. The current implementation faces the following limitations:
- Static Extraction vs. Dynamic Rotation: The current reliance on browser_cookie3 for static extraction is insufficient for frequent cookie rotations. Once Google updates the session tokens in the background, the API server loses authentication, resulting in persistent 503 Service Unavailable errors.
- SQLite WAL Latency in Docker: In containerized environments, Firefox frequently holds updated cookies in memory or Write-Ahead Logging (WAL) files. The API container cannot access these updates until the Firefox process is manually terminated, causing a synchronization lag.
- Maintenance Overhead on Headless Servers: For users deploying on headless Linux environments, any authentication failure requires manual intervention via a GUI (e.g., noVNC), which significantly hinders the project's reliability for production-level API services.
I propose the integration of Playwright as an optional "Automated Cookie Refresher" component to manage credentials programmatically:
- Background Refreshing: When an authentication failure is detected by the API, the system should automatically launch a headless browser instance using the existing shared profile.
- Direct Memory Extraction: Playwright can extract the latest cookies directly from the browser's execution context. This bypasses the reliance on physical SQLite files and resolves the WAL synchronization issue.
- Transparent Retry Mechanism: By integrating this logic within GeminiClient, the system can implement an "Identify Failure -> Auto-refresh -> Retry Request" cycle, ensuring zero downtime for the end-user.
I am a beginner developer and have spent considerable time debugging Docker volume behaviors and SQLite synchronization while exploring this project. If my technical assessment is inaccurate or if there are more efficient architectural approaches, I welcome your guidance. I am eager to learn and contribute to the robustness of this project.