diff --git a/src/functions/Workers.ts b/src/functions/Workers.ts index c519a6c..6de56ff 100644 --- a/src/functions/Workers.ts +++ b/src/functions/Workers.ts @@ -248,16 +248,16 @@ export class Workers { private async executeActivity(page: Page, activity: PromotionalItem | MorePromotion, selector: string, throttle: AdaptiveThrottler, retry: Retry): Promise { this.bot.log(this.bot.isMobile, 'ACTIVITY', `Found activity type: "${this.bot.activities.getTypeLabel(activity)}" title: "${activity.title}"`) - // IMPROVED: Smart wait replaces fixed 5s timeout with adaptive 2s+5s detection + // IMPROVED: Fast-fail for unavailable activities (1s+3s instead of 2s+5s) const elementResult = await waitForElementSmart(page, selector, { - initialTimeoutMs: 2000, - extendedTimeoutMs: TIMEOUTS.NETWORK_IDLE, + initialTimeoutMs: 1000, + extendedTimeoutMs: 3000, state: 'attached', logFn: (msg) => this.bot.log(this.bot.isMobile, 'ACTIVITY', msg) }) if (!elementResult.found) { - this.bot.log(this.bot.isMobile, 'ACTIVITY', `Activity selector not found (might be completed or unavailable): ${selector}`, 'warn') + this.bot.log(this.bot.isMobile, 'ACTIVITY', `[SKIP] Activity not available: "${activity.title}" (already completed or not offered today)`) return // Skip this activity gracefully } diff --git a/src/util/browser/SmartWait.ts b/src/util/browser/SmartWait.ts index 9557263..ac023ec 100644 --- a/src/util/browser/SmartWait.ts +++ b/src/util/browser/SmartWait.ts @@ -134,9 +134,7 @@ export async function waitForElementSmart( return { found: true, timeMs: elapsed, element } } catch (firstError) { - // Element not found quickly - try extended wait - logFn('Element not immediate, extending timeout...') - + // Element not found quickly - try extended wait (silent until result known) try { const element = page.locator(selector) await element.waitFor({ state, timeout: extendedTimeoutMs }) @@ -147,8 +145,8 @@ export async function waitForElementSmart( } catch (extendedError) { const elapsed = Date.now() - startTime - const errorMsg = extendedError instanceof Error ? extendedError.message : String(extendedError) - logFn(`✗ Element not found after ${elapsed}ms: ${errorMsg}`) + // IMPROVED: Concise failure message without full Playwright error stack + logFn(`Element not found after ${elapsed}ms (expected if activity unavailable)`) return { found: false, timeMs: elapsed, element: null } } }