Skip to content

DataStore: Rethrow cancellation instead of reporting a failed write - #614

Draft
gp-iaik wants to merge 1 commit into
release/5.9.2-rcfrom
fix/datastore-cancellation
Draft

gp-iaik wants to merge 1 commit into
release/5.9.2-rcfrom
fix/datastore-cancellation

Conversation

@gp-iaik

@gp-iaik gp-iaik commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on release/5.9.2-rc.

RealDataStoreService.setPreference and deletePreference caught every Throwable, including CancellationException, and threw a new Exception without a cause. On a device, leaving the credential selection cancelled a write of credential_metadata_cache. The write was logged as Could not persist cache 'credential_metadata_cache', and the caller was not cancelled.

Changes

  • CancellationException is rethrown unchanged.
  • Other exceptions are kept as the cause of the thrown exception.

Checks:

  • Ran :androidApp:compileDebugKotlin, :shared:compileKotlinMetadata and :shared:testAndroidHostTest; all pass.
  • New RealDataStoreServiceTest: cancelling a pending write throws CancellationException.

🤖 Generated with Claude Code

RealDataStoreService wrapped every exception of setPreference and deletePreference, including CancellationException, in a new Exception without a cause. A write cancelled because its screen closed, e.g. of the credential metadata cache when leaving the credential selection, was reported as "Could not persist cache", and the caller was not cancelled.

CancellationException is now rethrown as is, and other exceptions are kept as the cause.
@gp-iaik
gp-iaik force-pushed the fix/datastore-cancellation branch from 2730dc8 to 8500089 Compare October 30, 2026 10:08
@gp-iaik
gp-iaik changed the base branch from feature/launchpad-2026-post to release/5.9.2-rc October 30, 2026 10:08
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.

1 participant