fix(firestore): catch InterruptedException in FirestorePagingSource#2404
fix(firestore): catch InterruptedException in FirestorePagingSource#2404demolaf wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds handling for InterruptedException in FirestorePagingSource.loadSingle to prevent undeliverable RxJava exceptions when interrupted while disposed, and includes a corresponding integration test. The review feedback suggests avoiding logging expected errors at the ERROR level in the library to prevent cluttering Logcat, and recommends saving and restoring the original RxJavaPlugins error handler in the test to avoid side effects on other tests.
…lace sleeps with latches
russellwheatley
left a comment
There was a problem hiding this comment.
One suggestion on error visibility, otherwise this looks solid. Ran the paging test locally and confirmed the fix works, including the new disposal-interrupt regression test.
| Thread.currentThread().interrupt(); | ||
| return new LoadResult.Error<PageKey, DocumentSnapshot>(e); | ||
| } catch (Exception e) { | ||
| return new LoadResult.Error<PageKey, DocumentSnapshot>(e); |
There was a problem hiding this comment.
This generic catch now returns a LoadResult.Error with no logging, unlike DatabasePagingSource which logs failures via Log.e. Looks like logging was added and then dropped in a later commit on this branch. Could you restore it so production paging failures here don't go completely dark?
Fixes #2008.
FirestorePagingSource.loadSingle()blocks onTasks.await(task)inside aSingle.fromCallable. When Paging cancels an in-flight load, RxJava disposes the subscription, which interrupts the IO-scheduler thread mid-await, throwingInterruptedException. The source only caughtExecutionException, so theInterruptedExceptionescaped the callable after the subscription was already disposed — RxJava couldn't deliver it downstream, so it surfaced as anUndeliverableExceptionon the global handler and crashed the app.DatabasePagingSource(RTDB paging) already catchesInterruptedExceptionand returns aLoadResult.Errorinstead of throwing; this applies the same fix toFirestorePagingSource.Preview
untitled.webm