Fix MutableStore.write() ignoring SourceOfTruth write failures #727
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.
Closes #722
Problem
MutableStore.write()returnedStoreWriteResponse.Successeven whenSourceOfTruth.write()failed, causing silent data loss. Callers received explicit success while their data was never persisted.Root Cause
SourceOfTruthWithBarrier.write()caught exceptions from the delegate but only propagated errors to readers via the barrier mechanism. It never surfaced errors back to write callers. Consequently,RealStore.write()always returnedStoreDelegateWriteResult.Success.Solution
Changed
SourceOfTruthWithBarrier.write()to returnSourceOfTruth.WriteException?instead ofUnit. This enables:RealStore.write()to check the return value and return appropriateStoreDelegateWriteResultRealMutableStoreto surface write errors to callersFetcherControllerto continue working unchanged (ignores return value)Note
Fixes silent data loss by propagating SourceOfTruth write failures and gating follow-up actions.
SourceOfTruthWithBarrier.writeto returnSourceOfTruth.WriteException?; still emits barrier error to readersRealStore.writeto interpret the new return value and only cache on success, returningStoreDelegateWriteResult.Erroron failureRealMutableStorewrite flow to proceed to network only if the local write succeeds; surface local write errors asStoreWriteResponse.ErrorTestStoreto usesourceOfTruth = null; trackpostCallCountinTestUpdaterWritten by Cursor Bugbot for commit f12f175. This will update automatically on new commits. Configure here.