mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
## ℹ️ Description This PR fixes intermittent login detection failures where the bot fails to detect existing login sessions and unnecessarily re-logins, potentially causing IP blocks. - Link to the related issue(s): Issue #701 - Describe the motivation and context for this change: Users reported that the bot sometimes fails to detect existing login sessions (50/50 behavior), especially for browser profiles that haven't been used for 20+ days. This appears to be a race condition where: 1. `web_open()` completes when `document.readyState == 'complete'` 2. But kleinanzeigen.de's client-side JavaScript hasn't yet rendered user profile elements 3. The login detection timeout (5s default) is too short for slow networks or sessions requiring server-side validation ## 📋 Changes Summary - **Add dedicated `login_detection` timeout** to `TimeoutConfig` (default: 10s, previously used generic 5s timeout) - **Apply timeout to both DOM checks** in `is_logged_in()`: `.mr-medium` and `#user-email` elements - **Add debug logging** to track which element detected login or if no login was found - **Regenerate JSON schema** to include new timeout configuration - **Effective total timeout**: ~22.5s (10s base × 1.0 multiplier × 1.5 backoff × 2 retries) vs previous ~11.25s ### Benefits: - Addresses race condition between page load completion and client-side rendering - Provides sufficient time for sessions requiring server-side validation (20+ days old) - User-configurable via `timeouts.login_detection` in `config.yaml` - Follows established pattern of dedicated timeouts (`sms_verification`, `gdpr_prompt`, etc.) ### ⚙️ Type of Change - [x] 🐞 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (adds new functionality without breaking existing usage) - [ ] 💥 Breaking change (changes that might break existing user setups, scripts, or configurations) ## ✅ Checklist - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a configurable login-detection timeout (default 10s, min 1s) to tune session detection. * **Bug Fixes** * More reliable login checks using a timeout-aware, two-step detection sequence. * Improved diagnostic logging for login attempts, retry behavior, detection outcomes, and timeout events. * **Documentation** * Added troubleshooting guidance explaining the login-detection timeout and when to adjust it. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -403,6 +403,13 @@
|
||||
"title": "Gdpr Prompt",
|
||||
"type": "number"
|
||||
},
|
||||
"login_detection": {
|
||||
"default": 10.0,
|
||||
"description": "Timeout for detecting existing login session via DOM elements.",
|
||||
"minimum": 1.0,
|
||||
"title": "Login Detection",
|
||||
"type": "number"
|
||||
},
|
||||
"publishing_result": {
|
||||
"default": 300.0,
|
||||
"description": "Timeout for publishing result checks.",
|
||||
|
||||
Reference in New Issue
Block a user