Persist IEventStream<T> compound-handler appends without AutoApplyTransactions (#3032)#3044
Merged
Merged
Conversation
…nsactions (GH-3032) A compound handler that loads an IEventStream<T> (via FetchForWriting in a Load/LoadAsync method) and appends to it got no Marten transaction support unless opts.Policies.AutoApplyTransactions() was enabled - the appended events were silently dropped (no SaveChangesAsync, no exception). This was inconsistent with the other handler-side Marten effects that self-persist: single/collection IMartenOp returns (GH-3025) and [AggregateHandler]. MartenOpPolicy now also detects a handler that takes an IEventStream<T> parameter (the append shape) and applies the same idempotent Marten transaction support. ApplyTransactionSupport guards on CreateDocumentSessionFrame + DocumentSessionSaveChanges, so this composes with the aggregate workflow (which also uses IEventStream<T> via [WriteAggregate]) and with AutoApplyTransactions. Regression test: a compound handler (LoadAsync -> FetchForWriting<T>, Handle appends) on a host WITHOUT AutoApplyTransactions now persists the append (FetchStreamAsync count 1). Verified it fails (count 0, dropped) without the fix. Bug_225, the aggregate-handler workflow, and the single-IMartenOp suites stay green (94). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closed
17 tasks
This was referenced Jun 8, 2026
Merged
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.
Closes #3032.
Problem
A compound handler that obtains an
IEventStream<T>via theLoad/LoadAsyncconvention (FetchForWriting<T>) and appends to it got no Marten transaction support unlessopts.Policies.AutoApplyTransactions()was enabled —SaveChangesAsyncwas never generated and the appended events were silently dropped (no exception). This was inconsistent with the other handler-side Marten effects that self-persist: single/collectionIMartenOpreturns (fixed in #3025) and[AggregateHandler].Fix
MartenOpPolicynow also detects a handler that takes anIEventStream<T>parameter (the append shape) and applies the same idempotent Marten transaction support it already applies forIMartenOpreturns.ApplyTransactionSupportguards onCreateDocumentSessionFrame+DocumentSessionSaveChanges, so it composes with the aggregate workflow (which also usesIEventStream<T>via[WriteAggregate]) and withAutoApplyTransactions.Tests
New
event_stream_append_persists— a compound handler (LoadAsync→FetchForWriting<T>,Handleappends) on a host withoutAutoApplyTransactionsnow persists the append (FetchStreamAsynccount 1). Verified it fails (count 0, dropped) without the fix.AutoApplyTransactions-on compound path), the aggregate-handler workflow, and the single-IMartenOpsuites stay green (94 targeted).🤖 Generated with Claude Code