{"record":{"id":"abc5331fc20f44ec","repo":"karatelabs/karate","slug":"retry-started-max-attempts-ms-interval","errorCode":null,"errorMessage":"retry started: {} (max {} attempts, {}ms interval)","messagePattern":"retry started: (.+?) \\(max (.+?) attempts, (.+?)ms interval\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java","lineNumber":4270,"sourceCode":"\n    /**\n     * Centralized retry mechanism with warning logging.\n     * Use this for all retry operations to ensure consistent behavior and logging.\n     *\n     * @param description what we're waiting for (used in warning logs)\n     * @param condition   returns true when the condition is met\n     * @param maxAttempts maximum number of retry attempts (0 means try once)\n     * @param interval    milliseconds between retries\n     * @return true if condition was met, false if all retries exhausted\n     */\n    private boolean retry(String description, Supplier<Boolean> condition, int maxAttempts, int interval) {\n        // First attempt (not a retry)\n        if (Boolean.TRUE.equals(condition.get())) {\n            return true;\n        }\n\n        // Log that we're starting retries (helps diagnose flaky tests)\n        logger.warn(\"retry started: {} (max {} attempts, {}ms interval)\", description, maxAttempts, interval);\n\n        // Retry loop\n        for (int attempt = 1; attempt <= maxAttempts; attempt++) {\n            // Abort on interruption instead of degrading into a busy spin: sleep()\n            // preserves the interrupt flag, so every later sleep would return\n            // instantly and the remaining attempts would hammer CDP back-to-back.\n            if (Thread.currentThread().isInterrupted()) {\n                logger.warn(\"retry aborted (thread interrupted): {}\", description);\n                return false;\n            }\n            sleep(interval);\n            if (Boolean.TRUE.equals(condition.get())) {\n                logger.warn(\"retry succeeded after {} attempt(s): {}\", attempt, description);\n                return true;\n            }\n            logger.warn(\"retry attempt {}/{} failed for: {}\", attempt, maxAttempts, description);\n        }\n","sourceCodeStart":4252,"sourceCodeEnd":4288,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java#L4252-L4288","documentation":"This is a WARN log emitted by the CDP driver's centralized retry helper when it exhausts the first (non-retry) condition check and begins polling a condition. It indicates a condition passed to the retry mechanism (element wait, page readiness, etc.) did not hold on the first attempt, so Karate is entering a sleep-and-recheck loop up to maxAttempts with the given interval. It is diagnostic, not thrown: the condition may still succeed or fail later.","triggerScenarios":"Any call into CdpDriver's public retry path where the Supplier<Boolean> condition returns false or null on the very first evaluation — e.g. waiting for a DOM element, navigation state, or driver readiness that is not yet satisfied.","commonSituations":"Slow page loads or SPA hydration on first navigation; flaky CI environments where Chrome is slow to attach; waiting on async UI rendered after a click; an overly short initial condition check.","solutions":["Treat as diagnostic; wait for the subsequent 'retry succeeded' or 'retry FAILED' log to know the outcome.","If retries consistently trigger, increase waits/timeouts in the test or reduce page slowness rather than polling.","If it never succeeds, inspect the condition's target (selector, URL, frame) — the retry loop is only masking a real failure.","Check the thread is not being interrupted; interrupted threads abort retries early."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expect this log on slow pages; pre-warm the app or add explicit waits before actions.","Keep an eye on whether retries consistently fire — repeated lines indicate systematic slowness.","Ensure test threads are not interrupted (shutdown hooks, executor cancels) so retries aren't aborted."],"tags":["cdp","retry","logging","driver"],"backgroundTag":"request-timeout","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}