Fix silent map-directive drop: use Channel(UNLIMITED) in HomeViewModel (#1904)#1924
Merged
Merged
Conversation
#1904) #1865 replaced a replay-0 SharedFlow with Channel(capacity = 16) so a directive emitted while HOME's collector was resubscribing would queue instead of vanish. But emitMapDirective uses trySend, which fails silently once the bounded channel fills — 17+ directives queued while the user is on a pushed destination reproduced the very drop bug the Channel was introduced to fix, unlogged. Switch to Channel(capacity = Channel.UNLIMITED): directives are tiny and low-frequency, so an unbounded buffer never drops and costs nothing. trySend can then only fail on a closed channel (which this VM never does), so it stays a correct synchronous emit. Add a regression test that emits 40 directives (past the old bound of 16) with no collector subscribed, then subscribes and asserts all 40 are delivered in order — fails under capacity = 16, passes under UNLIMITED. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesMap directive delivery
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1904.
Problem
HomeViewModel._mapDirectiveswas aChannel(capacity = 16)written withtrySend. #1865 introduced this Channel (replacing a replay-0 SharedFlow) precisely so a directive emitted while HOME's collector is resubscribing would queue instead of vanish. ButtrySendfails silently once the bounded channel fills — 17+ directives queued while the user is on a pushed destination reproduces the very drop bug the Channel was introduced to fix, unlogged.Fix
Switch to
Channel(capacity = Channel.UNLIMITED). Directives are tiny and low-frequency, so an unbounded buffer never drops and costs nothing.trySendcan then only fail on a closed channel (which this VM never does), so it stays a correct synchronous emit — the comments are updated to reflect that.Test
Added a regression test that emits 40 directives (past the old bound of 16) with no collector subscribed, then subscribes and asserts all 40 are delivered in order. It fails under
capacity = 16and passes underUNLIMITED.Verification
./gradlew :onebusaway-android:testObaGoogleDebugUnitTest --tests "org.onebusaway.android.ui.home.HomeViewModelTest" -PwarningsAsErrors=true→ BUILD SUCCESSFUL, all tests green, no compiler warnings.🤖 Generated with Claude Code
Summary by CodeRabbit