{"record":{"id":"cf7b468b92167bf2","repo":"karatelabs/karate","slug":"no-time-left-to-stop","errorCode":null,"errorMessage":"no time left to stop {}","messagePattern":"no time left to stop (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-js/src/main/java/io/karatelabs/common/KarateLifecycle.java","lineNumber":357,"sourceCode":"                future.complete(summary);\n            }\n        }\n        synchronized (LOCK) {\n            return List.copyOf(results);\n        }\n    }\n\n    /**\n     * Run one {@code stop()} on a worker so it can be abandoned, and report the outcome. A worker\n     * that ignores its interrupt is left running — its thread is a daemon, so it cannot hold up\n     * JVM exit.\n     */\n    private static StopResult stopBounded(Stoppable stoppable, long budgetNanos) {\n        String name = name(stoppable);\n        String kind = kind(stoppable);\n        long start = System.nanoTime();\n        if (budgetNanos <= 0) {\n            logger.warn(\"no time left to stop {}\", name);\n            return new StopResult(name, kind, Outcome.TIMED_OUT, Duration.ZERO);\n        }\n        logger.debug(\"stopping {} [{}]\", name, kind);\n        Future<?> future = pool().submit(() -> {\n            SHUTDOWN_THREAD.set(true);\n            try {\n                stoppable.stop();\n            } finally {\n                SHUTDOWN_THREAD.remove();\n            }\n        });\n        Outcome outcome;\n        try {\n            future.get(budgetNanos, TimeUnit.NANOSECONDS);\n            outcome = Outcome.STOPPED;\n        } catch (TimeoutException e) {\n            future.cancel(true);\n            outcome = Outcome.TIMED_OUT;","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/common/KarateLifecycle.java#L339-L375","documentation":"KarateLifecycle.stopBounded() attempts to stop a registered Stoppable (server, mock, background process) within a shutdown time budget. If the budget is zero or negative — i.e. the overall shutdown deadline was already exhausted before this stoppable was reached — it logs this warning, skips stopping entirely, and returns StopResult with Outcome.TIMED_OUT. The resource is left running (or leaked) because the shutdown sequence has no time left to wait for a graceful stop.","triggerScenarios":"Calling KarateLifecycle.stop() (or server/mock shutdown) with a total shutdown budget that was already consumed by earlier stoppables, so budgetNanos <= 0 when this particular Stoppable is processed. Also triggered by explicitly passing a zero/negative budget into stopBounded().","commonSituations":"Suites registering many background mocks/servers each consuming the shutdown budget; a slow-to-stop resource earlier in the registry eating the whole deadline; environments (CI containers, slow disks) where graceful stops take longer than configured; very small configured shutdown timeout.","solutions":["Increase the shutdown time budget / timeout configuration for KarateLifecycle so there is time left when each stoppable is processed","Reduce the number of concurrently registered background resources, or stop them explicitly (and promptly) in test teardown before the global shutdown runs","Check logs for earlier 'timed out stopping' warnings to find the slow resource and fix or shorten its stop time","If the resource must be stopped, stop it directly via its own handle instead of relying on lifecycle batch shutdown"],"exampleFix":"// before: many slow mocks registered, budget exhausted by teardown\n// after: stop heavy resources explicitly first\nMyMock mock = MyMock.start(8080);\n// test ...\nmock.stop(); // free the shutdown budget early\nkarateLifecycle.stop(); // remaining stoppables still have time","handlingStrategy":"validation","validationCode":"// before shutdown, ensure budget is sane\nif (remainingBudgetNanos <= 0) { karate.warn('no shutdown budget left; stopping resources explicitly'); }\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stop heavy resources explicitly in teardown before global shutdown","Keep registered stoppables count low","Monitor logs for early 'timed out stopping' warnings","Give shutdown a generous budget in CI"],"tags":["lifecycle","shutdown","timeout","jvm"],"backgroundTag":"shutdown-timeout","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"}