karatelabs/karate · warning
Error closing driver
Error message
Error closing driver: {} What it means
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.
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
Example fix
# karate-config.js: pin driver versions to browser
karate.configure('driver', { type: 'chromedriver', webDriverUrl: 'http://localhost:9515' })
// and in CI: pkill -f chromedriver || true (post-job cleanup) Defensive patterns
Strategy: try-catch
Try / catch
try { driver.quit(); } catch (Exception e) { logger.warn("Error closing driver: {}", e.getMessage()); } Prevention
- Keep chromedriver/browser versions aligned
- Avoid scenarios outliving remote session timeouts
- Add CI-level cleanup of orphan browser processes
When it happens
Trigger: 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.
Common situations: Browser OOM-killed or crashed earlier in the scenario; force-stopped containers; long scenarios exceeding remote session timeouts; platform-specific driver crashes.
Related errors
- driver.stop=false — leaving browser running, scenario will…
- Error releasing driver to provider
- configure driver = } — bypassing driver pool; browser will…
- screenshotOnFailure: capture failed, continuing
- append() needs at least two arguments
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/dd8d537a6eb5968b.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java:2404
// Release back to provider
io.karatelabs.driver.DriverProvider provider = null;
if (featureRuntime != null && featureRuntime.getSuite() != null) {
provider = featureRuntime.getSuite().getDriverProvider();
}
if (provider != null) {
try {
provider.release(this, driver);
logger.debug("Released driver to provider for scenario: {}", scenario.getName());
} catch (Exception e) {
logger.warn("Error releasing driver to provider: {}", e.getMessage());
}
}
} else {
// Close directly
try {
driver.quit();
} catch (Exception e) {
logger.warn("Error closing driver: {}", e.getMessage());
}
}
driver = null;
}
/**
* Get the driver without initializing it.
* Returns null if driver has not been initialized.
* Used for checking if driver exists without side effects.
*/
public Driver getDriverIfPresent() {
return driver;
}
/**
* Get the driver scope ("scenario" or "caller").
*/
public String getDriverScope() {View on GitHub (pinned to a22eb90246)