karatelabs/karate · error · RuntimeException
Interrupted while publishing test event
Error message
Interrupted while publishing test event
What it means
JUnitBridgeListener queues test events (feature start/end, scenario end, completion) onto a blocking queue for the JUnit streamer to consume. If the publishing thread is interrupted while blocking on the queue, the listener restores the interrupt flag and rethrows as a RuntimeException.
Solutions
- Let the JVM shutdown proceed; this error usually signals an external interruption, not a bug
- Check for build/test timeouts that interrupt the reporting thread and raise them
- Ensure no custom code shuts down the executor/threads while Karate features are still running
Example fix
// build config before <timeout>30</timeout> // after <timeout>300</timeout> <!-- allow long feature runs to finish -->
Defensive patterns
Strategy: try-catch
Validate before calling
// before shutdown, ensure reporting has drained boolean idle = bridgeListener != null && bridgeListener.isIdle();
Type guard
null
Try / catch
try {
runKarateSuite();
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("Interrupted while publishing test event")) {
Thread.interrupted(); // acknowledge and continue shutdown
return;
}
throw e;
} Prevention
- Avoid cancelling builds mid-feature when possible
- Do not interrupt executor threads that run Karate features
- Grant generous build timeouts so reporting completes
When it happens
Trigger: The thread calling putEvent (via onFeatureStart/onFeatureEnd/onScenarioEnd/complete) is interrupted while the event queue is full or the JVM is shutting down.
Common situations: Build cancellation (Ctrl+C in Maven/Gradle), test timeouts that interrupt worker threads, executor shutdown while a feature is still reporting.
Related errors
- retry interrupted
- Interrupted while waiting for driver
- Timeout waiting for Karate test events after
- listen interrupted
- Timeout waiting for available driver for scenario
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/b7a7093ff054a842.
Report an issue: GitHub.
Appendix: source
Thrown at karate-junit6/src/main/java/io/karatelabs/junit6/JUnitBridgeListener.java:103
* Deliberately <em>not</em> driven by {@link #onSuiteEnd(SuiteResult)}: that callback
* fires while the suite is still running its listener chain, so report writers (JUnit
* XML, Cucumber JSON) registered after this bridge may not have flushed their
* asynchronous per-feature writes yet. Emitting the terminal event from here — invoked
* only once {@code Runner.Builder.parallel(...)} has fully returned — guarantees that
* when the JUnit {@code @TestFactory} stream completes, all report files are on disk.
*
* @param result the suite result (may be null if execution failed before completing)
*/
public void complete(SuiteResult result) {
putEvent(new TestEvent.SuiteEnd(result));
}
private void putEvent(TestEvent event) {
try {
eventQueue.put(event);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted while publishing test event", e);
}
}
}
View on GitHub (pinned to a22eb90246)