{"record":{"id":"eb42f6396b25f3ee","repo":"karatelabs/karate","slug":"retry-succeeded-after-attempt-s-eval","errorCode":null,"errorMessage":"retry succeeded after {} attempt(s): eval {}","messagePattern":"retry succeeded after (.+?) attempt\\(s\\): eval (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java","lineNumber":1926,"sourceCode":"                    // Safety net only: the readiness future (getFrameContext awaits it)\n                    // normally guarantees a live context here. A context can still die\n                    // between the await and the send (e.g. a click triggered a navigation);\n                    // the navigation's executionContextsCleared event invalidates the\n                    // future, so the retry's getFrameContext() blocks for the replacement\n                    // context on its own. We deliberately do NOT invalidate from here: a\n                    // -32000 that is NOT a navigation would otherwise strand the future\n                    // incomplete (no new executionContextCreated would ever arrive) and\n                    // make every later eval wait out the full timeout.\n                    logger.warn(\"transient context error, retry {}/{}: {}\", attempt + 1, maxRetries, truncate(expression, 100));\n                    sleep(transientInterval);\n                    continue;\n                }\n                logger.warn(\"retry exhausted for transient context error: {}\", truncate(expression, 100));\n            }\n\n            // Success or non-transient error\n            if (attempt > 0 && !response.isError()) {\n                logger.warn(\"retry succeeded after {} attempt(s): eval {}\", attempt, truncate(expression, 50));\n            }\n            return response;\n        }\n\n        // Should not reach here, but return last response if somehow we do\n        throw new RuntimeException(\"eval retry logic error for: \" + expression);\n    }\n\n    /**\n     * Check if a CDP response indicates a transient execution context error\n     * that should be retried.\n     *\n     * DESIGN NOTES:\n     * - CDP error code -32000 is a generic \"server error\" used for ALL execution context issues\n     * - Chrome uses this code for: context destroyed, context not found, target navigated, etc.\n     * - Rather than matching specific messages (which may vary by Chrome version), we retry\n     *   all -32000 errors since they're all related to transient context state\n     * - This is more robust than Puppeteer's message-matching approach and handles edge cases","sourceCodeStart":1908,"sourceCodeEnd":1944,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java#L1908-L1944","documentation":"This informational warning confirms that a transient-error retry loop for Runtime.evaluate succeeded on a non-first attempt: after 'attempt' failed tries (context not found, context destroyed, etc.), the CDP message finally succeeded. It is logged only when attempt > 0 and the response is not an error, and is purely diagnostic — no failure occurred. Its purpose is to make retry flakiness visible in CI logs.","triggerScenarios":"script()/eval where the evalRetry loop caught a transient CDP context error on earlier attempt(s), then message.send() returned a successful response.","commonSituations":"Evaluations racing navigation-driven context swaps, CI load delaying execution-context registration, tests reading DOM right after frame switches or redirects.","solutions":["No action needed on success — this is the retry mechanism working as designed.","If it fires frequently for the same expression, add an explicit wait (waitFor/url transitions) before evaluating to reduce churn.","Track frequency; a rising rate suggests environmental slowness or pages that swap contexts aggressively."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add explicit waits before DOM reads to reduce retry churn","Monitor warning frequency as a CI-health signal","Stabilize pages that swap execution contexts aggressively","Pin Chrome version in CI to reduce context-race variability"],"tags":["cdp","eval","retry","success"],"backgroundTag":"transient-context-error","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"}