{"record":{"id":"ea176ed0ce735334","repo":"ReactiveX/RxJava","slug":"the-source-did-not-signal-an-event-for-timeout-ea176e","errorCode":null,"errorMessage":"The source did not signal an event for {timeout} {unit} and has been terminated.","messagePattern":"The source did not signal an event for (.+?) (.+?) and has been terminated\\.","errorType":"exception","errorClass":"TimeoutException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/reactivex/rxjava4/internal/observers/FutureObserver.java","lineNumber":98,"sourceCode":"            await();\n        }\n\n        if (isCancelled()) {\n            throw new CancellationException();\n        }\n        Throwable ex = error;\n        if (ex != null) {\n            throw new ExecutionException(ex);\n        }\n        return value;\n    }\n\n    @Override\n    public T get(long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {\n        if (getCount() != 0) {\n            BlockingHelper.verifyNonBlocking();\n            if (!await(timeout, unit)) {\n                throw new TimeoutException(timeoutMessage(timeout, unit));\n            }\n        }\n\n        if (isCancelled()) {\n            throw new CancellationException();\n        }\n\n        Throwable ex = error;\n        if (ex != null) {\n            throw new ExecutionException(ex);\n        }\n        return value;\n    }\n\n    @Override\n    public void onSubscribe(Disposable d) {\n        DisposableHelper.setOnce(this.upstream, d);\n    }","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/observers/FutureObserver.java#L80-L116","documentation":"Thrown as a TimeoutException by FutureObserver.get(long, TimeUnit) when the backing source does not signal within the given timeout. The message is produced by ExceptionHelper.timeoutMessage: 'The source did not signal an event for {timeout} {unit} and has been terminated.' FutureObserver implements Future<T> over an Observable/Streamer-style single source; 'has been terminated' refers to the get() call giving up after await() returns false, not necessarily a source-side failure.","triggerScenarios":"Calling futureObserver.get(3, TimeUnit.SECONDS) where the upstream emits nothing and does not complete/error within 3 seconds. Typical with sources blocked on a condition, hot sources that have not produced yet, or cold sources stalled on I/O.","commonSituations":"Blocking on a source that legitimately never completes; undersized timeouts relative to real latency; producer-thread starvation/deadlock; calling from a context where BlockingHelper.verifyNonBlocking() disallows blocking.","solutions":["Raise the timeout to cover realistic worst-case latency.","Apply a timeout() operator on the source so it terminates deterministically instead of leaving the Future hanging.","Catch TimeoutException and supply a fallback or trigger a retry.","Confirm the calling thread is allowed to block (BlockingHelper may reject it)."],"exampleFix":"// before\nT v = observable.toFuture().get(1, TimeUnit.SECONDS); // TimeoutException\n\n// after\nT v;\ntry {\n    v = observable.timeout(Duration.ofSeconds(1))\n                  .toFuture().get(5, TimeUnit.SECONDS);\n} catch (TimeoutException e) {\n    v = fallback();\n}","handlingStrategy":"try-catch","validationCode":"// bound the source and choose a realistic timeout:\nObservable<T> bounded = source.timeout(Duration.ofSeconds(5));\n// get(long, TimeUnit) declares TimeoutException — handle it.","typeGuard":null,"tryCatchPattern":"try {\n    T v = observable.toFuture().get(5, TimeUnit.SECONDS);\n} catch (TimeoutException e) {\n    v = fallback();\n} catch (InterruptedException | ExecutionException e) {\n    Thread.currentThread().interrupt();\n    throw new RuntimeException(e);\n}","preventionTips":["Apply timeout() on the source so the Future cannot hang indefinitely.","Match the get(timeout) to real worst-case latency.","Verify the calling thread may block (BlockingHelper check)."],"tags":["timeout","future","observer","blocking","rxjava"],"backgroundTag":null,"analyzedSha":"a8ab5356143f37a8f1dd6d76c79191bec5fa343b","analyzedAt":"2026-08-13T23:25:30.069Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}