{"record":{"id":"02353a179d555a43","repo":"karatelabs/karate","slug":"readystate-check-exception","errorCode":null,"errorMessage":"readyState check exception: {}","messagePattern":"readyState check exception: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java","lineNumber":1684,"sourceCode":"                    .send();\n            if (response.isError()) {\n                // Log the error so we can diagnose CI failures\n                logger.warn(\"readyState check CDP error: {}\", response.getErrorMessage());\n                return false;\n            }\n            String readyState = response.getResultAsString(\"result.value.r\");\n            logger.trace(\"readyState check returned: {}\", readyState); // keep trace, this is success path\n            boolean ready = \"complete\".equals(readyState) || \"interactive\".equals(readyState);\n            if (ready && requireUrl != null) {\n                ready = urlsEquivalent(requireUrl, response.getResultAsString(\"result.value.u\"));\n            }\n            return ready;\n        } catch (Exception e) {\n            String msg = e.getMessage();\n            if (msg != null && msg.contains(\"websocket not open\")) {\n                logger.trace(\"readyState check skipped: websocket not open\");\n            } else {\n                logger.warn(\"readyState check exception: {}\", msg);\n            }\n            return false;\n        }\n    }\n\n    /**\n     * Whether a requested navigation/history URL and the document's live\n     * {@code location.href} name the same resource, tolerating a lone trailing-slash\n     * difference (a request for {@code …/path} commonly settles as {@code …/path/}).\n     * Exact otherwise — this gates accepting a readyState=complete read as the target\n     * document, so it must not treat genuinely different URLs as equal.\n     */\n    static boolean urlsEquivalent(String requested, String actual) {\n        if (requested == null || actual == null) {\n            return false;\n        }\n        if (requested.equals(actual)) {\n            return true;","sourceCodeStart":1666,"sourceCodeEnd":1702,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/cdp/CdpDriver.java#L1666-L1702","documentation":"The readyState probe (used during page-load waits) wraps any exception and logs this warning before returning false. A 'websocket not open' message is demoted to trace level; anything else — e.g. an evaluation error because the execution context was destroyed mid-navigation — is logged at warn. The wait loop treats it as 'not ready yet' and keeps polling, so this is non-fatal by itself.","triggerScenarios":"The periodic readyState evaluation during driver.get()/loadUrl() throws — typically a Runtime exception from script evaluation on a context destroyed by navigation, or a websocket send after the CDP connection dropped.","commonSituations":"Navigation swapping execution contexts while the probe runs, browser tab closed/crashed mid-load (websocket gone), or CI races during frame detach.","solutions":["If the load then completes, no action is needed — the probe recovered.","If cdpOpen=false and the wait times out, the browser/websocket died: check browser crash logs and resources.","Retry the navigation; transient context churn usually settles.","Ensure the page isn't navigating itself (redirect loops) that keeps destroying contexts."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify the browser connection is alive before heavy navigation work\nboolean open = driver.driverOptions != null; // use driver health/config checks available in your harness","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prevent browser crashes: adequate memory, no zombie Chrome processes","Avoid closing/switching tabs mid-navigation","Check for redirect loops that repeatedly destroy contexts","Retry navigation when this warning appears without a subsequent load"],"tags":["cdp","readystate","websocket","navigation"],"backgroundTag":"websocket-not-open","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"}