fix(persistence): make AmbientDbTransactionRegistry actually receive transaction events - #1393
Merged
Merged
Conversation
…transaction events Its TransactionStarted/TransactionUsed signatures did not match IDbTransactionInterceptor, and the async hooks were missing. The interface supplies default no-ops for every member, so the near-miss methods compiled but were never called: the registry stayed empty and the outbox never enlisted explicitly in the business transaction. Invisible on PostgreSQL (Npgsql runs commands in the connection's open transaction anyway). Implements every sync and async hook with the exact signatures, forgets disposed transactions by identity, and adds a reflection test that fails if any hook falls through to the interface default again. Extracted from #1374. Co-authored-by: maxiar <edujimenez86@hotmail.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Extracted from #1374 (credit @maxiar, co-author on the commit) so it can ship without the SQL Server provider.
Bug
AmbientDbTransactionRegistry(the interceptor that lets the outbox write enlist in the business transaction) declaredTransactionStarted/TransactionUsedwith signatures that don't matchIDbTransactionInterceptor, and had no async hooks. The interface gives every member a default no-op, so the methods compiled but were never called: the registry was always empty.It's invisible on PostgreSQL because Npgsql runs commands in the connection's open transaction anyway. Any provider that needs the transaction set explicitly (e.g. SQL Server) would fail.
Fix
Forgetalso matches by identity (a disposed transaction reports a nullConnection).AmbientDbTransactionRegistryTestsuses the interface map to fail if any hook falls through to the default again. It fails onmainand passes here.Verification
Framework.Tests 202/202. Full Integration.Tests 753/753 and Middleware 5/5, so the outbox paths behave the same on Postgres with the registry populated. Build: 0 warnings.
Touches
src/BuildingBlocks/Persistence(maintainer-approved).🤖 Generated with Claude Code