Skip to content

4.x: Fix Streamable.timeout missing deadlines during synchronous pulls - #8407

Merged
akarnokd merged 2 commits into
ReactiveX:4.xfrom
ZainnQureshii:fix-streamable-timeout-sync-pull
Nov 28, 2026
Merged

akarnokd merged 2 commits into
ReactiveX:4.xfrom
ZainnQureshii:fix-streamable-timeout-sync-pull

Conversation

@ZainnQureshii

@ZainnQureshii ZainnQureshii commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Streamable.timeout started the timer after calling next() on the upstream streamer (base src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeout.java:77, timer at :79). A synchronous map could exceed the deadline and still emit its item, so the subscriber missed the fallback.

The timer now starts before the pull (src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeout.java:82). When the timer wins, it claims upstream cleanup once and waits for the pull to settle. Late mapper and cleanup errors reach the observer without a second call to upstream finish(). After successful cleanup, the operator checks downstream disposal immediately before starting the fallback (src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeout.java:97). An idle trampoline worker runs the timer inline, so it can now select the fallback before the first pull.

Streamable.timeout is the sole entry point to this operator. Timed Flowable and Observable already arm their timers before subscribing. Streamable.takeUntil shares a cancellation helper and uses a separate stop signal. Streamable.onErrorResumeNext switches on error through its own path.

The run below covered the style validators and Checkstyle, plus regressions for expiry during a synchronous pull, a failing cleanup, and disposal during cleanup.

./gradlew --offline --no-daemon --no-watch-fs --console=plain --max-workers=4 test --tests 'io.reactivex.rxjava4.internal.operators.streamable.*' --tests 'io.reactivex.rxjava4.validators.*' --tests '*FlowableTimeoutTests' --tests '*ObservableTimeoutTests' checkstyleMain checkstyleTest

Prepared with AI assistance (Codex and Claude Code) and reviewed with GitHub Copilot.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.602 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeout.java: 4.396
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeoutTest.java: 4.807

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.62%. Comparing base (4f0f68c) to head (0431f41).

Files with missing lines Patch % Lines
...ternal/operators/streamable/StreamableTimeout.java 90.00% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (90.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##                4.x    #8407      +/-   ##
============================================
- Coverage     98.63%   98.62%   -0.01%     
  Complexity     7184     7184              
============================================
  Files           826      826              
  Lines         51048    51055       +7     
  Branches       6947     6951       +4     
============================================
+ Hits          50352    50354       +2     
- Misses          474      479       +5     
  Partials        222      222              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akarnokd

Copy link
Copy Markdown
Member

The new code path wasn't covered.

I believe using the Schedulers.trampoline and a timeout of zero will synchronously trigger that path

https://github.com/ReactiveX/RxJava/pull/8407/changes#diff-20a5e5f8c648fd8c186ff576544a7a9916b852cba0fee42ade714441754272d2R107

@akarnokd akarnokd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new code path wasn't covered.

I believe using the Schedulers.trampoline and a timeout of zero will synchronously trigger that path on line 107

@ZainnQureshii

Copy link
Copy Markdown
Contributor Author

@akarnokd I added a zero-timeout test with Schedulers.trampoline() in 0431f41, so the timer fires before the first pull, and it checks that the fallback value comes through and the upstream is never pulled. It fails if I take the skip branch out, so that path is covered now.

@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.6 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeout.java: 4.396
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTimeoutTest.java: 4.804

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@akarnokd
akarnokd merged commit 68696e5 into ReactiveX:4.x Nov 28, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants