{"record":{"id":"30bf907818e7ad62","repo":"karatelabs/karate","slug":"listen-interrupted","errorCode":null,"errorMessage":"listen interrupted","messagePattern":"listen interrupted","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java","lineNumber":2485,"sourceCode":"    }\n\n    /**\n     * Wait for a signal with timeout.\n     * Returns the signaled result or throws on timeout.\n     */\n    public Object waitForListenResult(long timeoutMs) {\n        try {\n            if (listenLatch.await(timeoutMs, TimeUnit.MILLISECONDS)) {\n                Object result = listenResult;\n                // Reset for potential reuse\n                listenResult = null;\n                listenLatch = new CountDownLatch(1);\n                return result;\n            }\n            throw new RuntimeException(\"listen timed out after \" + timeoutMs + \"ms\");\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new RuntimeException(\"listen interrupted\", e);\n        }\n    }\n\n    /**\n     * Get the current listen result without waiting.\n     */\n    public Object getListenResult() {\n        return listenResult;\n    }\n\n    // ========== Performance Testing (Gatling Integration) ==========\n\n    /**\n     * Check if performance mode is enabled.\n     * When true, HTTP request timing is reported via PerfHook.\n     */\n    public boolean isPerfMode() {\n        return featureRuntime != null","sourceCodeStart":2467,"sourceCodeEnd":2503,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java#L2467-L2503","documentation":"While waiting for a listen result, the waiting thread was interrupted. The runtime restores the interrupt flag and throws \"listen interrupted\" wrapping the InterruptedException, aborting the listen step.","triggerScenarios":"The scenario thread waiting on listenLatch.await() is interrupted: test-run shutdown, JUnit/TestNG timeout or executor cancellation, karate.abort(), or JVM teardown while a listen is pending.","commonSituations":"CI job killed/cancelled mid-scenario; time-limited test runners (e.g. JUnit @Timeout) firing while a browser callback listen is pending; stepping/debugger stopping threads; parallel runner shutdown.","solutions":["Ensure the external callback fires before test timeouts so listen completes normally","Remove or extend enclosing test timeouts that cut off the scenario thread during listen","On this error, treat it as a run-shutdown symptom: check for cancelled CI jobs or executor shutdown logs and re-run"],"exampleFix":"// before\n@Timeout(5) @Test void oauthFlow() { /* contains * listen 60000 */ }\n// after\n@Timeout(120) @Test void oauthFlow() { /* listen can finish */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { karate.listen(60000, 'token'); } catch (RuntimeException e) { if (e.getMessage().equals(\"listen interrupted\")) { logger.warn(\"scenario interrupted during listen (shutdown or test timeout)\"); } throw e; }","preventionTips":["Avoid enclosing time limits (@Timeout, executor deadlines) shorter than listen timeouts","Ensure callbacks fire promptly so listen finishes before shutdown","Treat this error as a run-cancellation symptom; check CI/executor logs"],"tags":["listen","interrupt","threading"],"backgroundTag":"thread-interrupted","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"}