{"record":{"id":"dd8d537a6eb5968b","repo":"karatelabs/karate","slug":"error-closing-driver","errorCode":null,"errorMessage":"Error closing driver: {}","messagePattern":"Error closing driver: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java","lineNumber":2404,"sourceCode":"            // Release back to provider\n            io.karatelabs.driver.DriverProvider provider = null;\n            if (featureRuntime != null && featureRuntime.getSuite() != null) {\n                provider = featureRuntime.getSuite().getDriverProvider();\n            }\n            if (provider != null) {\n                try {\n                    provider.release(this, driver);\n                    logger.debug(\"Released driver to provider for scenario: {}\", scenario.getName());\n                } catch (Exception e) {\n                    logger.warn(\"Error releasing driver to provider: {}\", e.getMessage());\n                }\n            }\n        } else {\n            // Close directly\n            try {\n                driver.quit();\n            } catch (Exception e) {\n                logger.warn(\"Error closing driver: {}\", e.getMessage());\n            }\n        }\n        driver = null;\n    }\n\n    /**\n     * Get the driver without initializing it.\n     * Returns null if driver has not been initialized.\n     * Used for checking if driver exists without side effects.\n     */\n    public Driver getDriverIfPresent() {\n        return driver;\n    }\n\n    /**\n     * Get the driver scope (\"scenario\" or \"caller\").\n     */\n    public String getDriverScope() {","sourceCodeStart":2386,"sourceCodeEnd":2422,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java#L2386-L2422","documentation":"When no pool provider is configured, Karate closes the driver directly with `driver.quit()` at teardown. If quit throws, this warning is logged and teardown continues (`driver = null`). The browser process may be left running.","triggerScenarios":"Direct driver close path where the browser session is already dead/invalid so `quit()` throws — e.g. chromedriver process killed, WebSocket to browser broken, or session id expired.","commonSituations":"Browser OOM-killed or crashed earlier in the scenario; force-stopped containers; long scenarios exceeding remote session timeouts; platform-specific driver crashes.","solutions":["Verify browser/driver logs to find why the session was already dead","Ensure driver binaries match the browser version","Add timeouts/stability fixes for the underlying step failure that preceded teardown","Clean up orphan browser processes at the CI job level"],"exampleFix":"# karate-config.js: pin driver versions to browser\nkarate.configure('driver', { type: 'chromedriver', webDriverUrl: 'http://localhost:9515' })\n// and in CI: pkill -f chromedriver || true  (post-job cleanup)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { driver.quit(); } catch (Exception e) { logger.warn(\"Error closing driver: {}\", e.getMessage()); }","preventionTips":["Keep chromedriver/browser versions aligned","Avoid scenarios outliving remote session timeouts","Add CI-level cleanup of orphan browser processes"],"tags":["karate","driver","teardown","webdriver"],"backgroundTag":"resource-release-failed","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}