Skip to content

fix(firestore): catch InterruptedException in FirestorePagingSource#2404

Open
demolaf wants to merge 5 commits into
masterfrom
fix/firestore-paging-interrupt
Open

fix(firestore): catch InterruptedException in FirestorePagingSource#2404
demolaf wants to merge 5 commits into
masterfrom
fix/firestore-paging-interrupt

Conversation

@demolaf

@demolaf demolaf commented Jul 20, 2026

Copy link
Copy Markdown
Member

Fixes #2008.

FirestorePagingSource.loadSingle() blocks on Tasks.await(task) inside a Single.fromCallable. When Paging cancels an in-flight load, RxJava disposes the subscription, which interrupts the IO-scheduler thread mid-await, throwing InterruptedException. The source only caught ExecutionException, so the InterruptedException escaped the callable after the subscription was already disposed — RxJava couldn't deliver it downstream, so it surfaced as an UndeliverableException on the global handler and crashed the app.

DatabasePagingSource (RTDB paging) already catches InterruptedException and returns a LoadResult.Error instead of throwing; this applies the same fix to FirestorePagingSource.

Preview

untitled.webm

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@demolaf
demolaf marked this pull request as ready for review July 21, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InterruptedException at com.firebase.ui.firestore.paging.FirestorePagingSource.lambda$loadSingle$0(FirestorePagingSource.java)

1 participant