karatelabs/karate · warning
Failed to initialize JSONL event stream
Error message
Failed to initialize JSONL event stream: {} What it means
When a Suite runs, it initializes a JSONL (JSON Lines) event stream writer in the output directory to record run events. If initializing the writer throws (IO error creating the file, invalid output dir, environment mismatch), the suite logs this warning, sets the writer to null, and continues the run without the event stream — results are still produced, but no JSONL events.
Solutions
- Ensure the output directory exists and is writable by the test process before the run
- Check disk space and quota on the volume holding target/karate output
- Run with a fresh, empty output dir (or let Karate back it up) rather than a pre-created read-only path
- If JSONL events are not needed, disable the event stream option so the warning does not appear
Example fix
// before: unwritable output dir java -jar karate.jar -o /proc/output // after java -jar karate.jar -o target/karate-reports
Defensive patterns
Strategy: validation
Validate before calling
java.nio.file.Path out = java.nio.file.Path.of(outputDir);
java.nio.file.Files.createDirectories(out);
if (!java.nio.file.Files.isWritable(out))
throw new IllegalStateException("output dir not writable: " + out); Try / catch
try {
new Suite(builder).run();
} catch (Exception e) {
// JSONL init failures are only warnings; detect via missing events file afterwards
if (!java.nio.file.Files.exists(java.nio.file.Path.of(outputDir, "karate-events.jsonl")))
logger.warn("event stream was not created; results may lack event data");
} Prevention
- Create and verify the output directory is writable before Suite.run()
- Ensure adequate disk space/quota on the volume holding target output
- Avoid read-only container filesystems for the output path (mount a writable volume)
- If events are not required, disable the JSONL stream explicitly rather than relying on the fallback
When it happens
Trigger: Suite.run() with outputDir set and JSONL writing enabled where JsonLinesEventWriter.init() fails: output dir does not exist and cannot be created, disk full, permissions, or constructor/validation of the writer throws.
Common situations: Running in a read-only container/CI workspace; target/ or output dir deleted concurrently; outputDir pointed outside a writable volume; version mismatch where env/threadCount values are invalid.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Failed to close JSONL event stream
- Failed to backup existing dir
- Failed to read bytes from
- ext ' ': resource vanished after validation
- ext ' ': failed reading
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/674dc6fd166c0a11.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/Suite.java:557
JsonLinesEventWriter jsonlWriter = null;
boolean jsonlEnabled = outputJsonLines;
if (!jsonlEnabled && bootBinding != null) {
for (Ext ext : bootBinding.getExts()) {
if (ext.requiresJsonlEvents()) {
logger.info("JSONL event stream auto-enabled by ext: {}", ext.getClass().getSimpleName());
jsonlEnabled = true;
break;
}
}
}
if (jsonlEnabled) {
jsonlWriter = new JsonLinesEventWriter(outputDir, env, threadCount);
try {
jsonlWriter.init();
// Add to a mutable copy for event firing
addJsonlListener(jsonlWriter);
} catch (Exception e) {
logger.warn("Failed to initialize JSONL event stream: {}", e.getMessage());
jsonlWriter = null;
}
}
try {
// Notify listeners
// Reset the embed file sequence (001_, 002_, …) for THIS run, regardless of whether HTML
// reporting is on — embeds are externalized from the FEATURE_EXIT seam (see fireEvent) so the
// counter must restart even for a JSONL-only run.
HtmlReportWriter.resetEmbedCounter();
for (ResultListener listener : resultListeners) {
listener.onSuiteStart(this);
}
// Fire SUITE_ENTER event
fireEvent(SuiteRunEvent.enter(this));
View on GitHub (pinned to a22eb90246)