{"record":{"id":"b5d79b93b98a4696","repo":"Netflix/Hystrix","slug":"hystrix-does-not-support-delayed-scheduling","errorCode":null,"errorMessage":"Hystrix does not support delayed scheduling","messagePattern":"Hystrix does not support delayed scheduling","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixContextScheduler.java","lineNumber":180,"sourceCode":"                return Subscriptions.unsubscribed();\n            }\n\n            // This is internal RxJava API but it is too useful.\n            ScheduledAction sa = new ScheduledAction(action);\n\n            subscription.add(sa);\n            sa.addParent(subscription);\n\n            ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor();\n            FutureTask<?> f = (FutureTask<?>) executor.submit(sa);\n            sa.add(new FutureCompleterWithConfigurableInterrupt(f, shouldInterruptThread, executor));\n\n            return sa;\n        }\n\n        @Override\n        public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {\n            throw new IllegalStateException(\"Hystrix does not support delayed scheduling\");\n        }\n    }\n\n    /**\n     * Very similar to rx.internal.schedulers.ScheduledAction.FutureCompleter, but with configurable interrupt behavior\n     */\n    private static class FutureCompleterWithConfigurableInterrupt implements Subscription {\n        private final FutureTask<?> f;\n        private final Func0<Boolean> shouldInterruptThread;\n        private final ThreadPoolExecutor executor;\n\n        private FutureCompleterWithConfigurableInterrupt(FutureTask<?> f, Func0<Boolean> shouldInterruptThread, ThreadPoolExecutor executor) {\n            this.f = f;\n            this.shouldInterruptThread = shouldInterruptThread;\n            this.executor = executor;\n        }\n\n        @Override","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixContextScheduler.java#L162-L198","documentation":"ThreadPoolScheduler - the RxJava Scheduler Hystrix uses for thread-isolated commands - only supports immediate scheduling onto the Hystrix thread pool. Its schedule(action, delayTime, unit) overload deliberately throws IllegalStateException because delayed tasks have no defined thread-pool semantics in Hystrix.","triggerScenarios":"Using RxJava operators that introduce delays on a Hystrix-scheduled observable, e.g. observable.delay(...), timer(...), or interval(...) while subscribed on a HystrixContextScheduler/ThreadPoolScheduler.","commonSituations":"Chaining .delay() or .timer() onto a HystrixCommand's toObservable() and then calling subscribeOn with the Hystrix scheduler; custom Rx pipelines built on HystrixPlugins concurrency strategy schedulers.","solutions":["Apply delayed operators on a standard Rx scheduler (Schedulers.computation()/io()) instead of the Hystrix thread-pool scheduler.","Reorder the chain: schedule only the command execution itself on Hystrix; do retry/delay/backpressure orchestration downstream on another scheduler.","If you need delayed retries, use Hystrix's own retry mechanisms or an outer observable with retryWhen on a default scheduler."],"exampleFix":"// before\ncommand.toObservable()\n    .delay(1, TimeUnit.SECONDS)          // forces delayed schedule\n    .subscribeOn(hystrixScheduler)       // -> IllegalStateException\n\n// after\ncommand.toObservable()\n    .delay(1, TimeUnit.SECONDS)\n    .subscribeOn(Schedulers.computation());","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    observable.delay(1, TimeUnit.SECONDS).subscribeOn(hystrixScheduler);\n} catch (IllegalStateException e) {\n    if (\"Hystrix does not support delayed scheduling\".equals(e.getMessage())) {\n        // restructure: use Schedulers.computation() for delayed operators\n    }\n}","preventionTips":["Never schedule delayed Rx operators on Hystrix thread-pool schedulers.","Reserve the Hystrix scheduler for the command execution itself."],"tags":["hystrix","rxjava","scheduler","unsupported-operation"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}