GH-3365: stop double-registering the primary Polecat IEventStore#3412
Merged
jeremydmiller merged 1 commit intoJul 13, 2026
Merged
Conversation
Polecat's own AddPolecat() already registers JasperFx.Events.IEventStore for the primary DocumentStore -- on every overload, as of the 4.8.0 floor of our package range. Wolverine's IntegrateWithWolverine() bridged it a second time, so GetServices<IEventStore>() handed back the same DocumentStore instance twice and every consumer enumerating the registered stores double-counted the primary. Drop the redundant bridge (Wolverine.Marten registers nothing equivalent for its primary store, for exactly this reason). The ancillary bridge stays -- AddPolecatStore<T>() does NOT register IEventStore for the T store. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 14, 2026
This was referenced Jul 18, 2026
Open
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.
Root cause (not the one suspected in the issue)
The issue guessed that
WolverineOptionsPolecatExtensions.IntegrateWithWolverine()was executing twice — once explicitly, once from an internal integration pass. That is wrong.IntegrateWithWolverine()runs exactly once.The duplicate comes from Polecat itself. Dumping the
IServiceCollectionfor the reported host shape produces threeIEventStoredescriptors with these implementation factories:AddPolecat()now registers the store-agnosticJasperFx.Events.IEventStorefor the primaryDocumentStoreon its own — verified against all fourAddPolecatoverloads (Action<StoreOptions>,string,StoreOptions,Func<IServiceProvider, StoreOptions>) at Polecat 4.8.0, the floor of our package range. Both factories resolve the sameIDocumentStoresingleton, hence the reference-equal duplicate.Wolverine's bridge dates to GH-3133 / GH-3219, when
AddPolecatgenuinely did not registerIEventStore. Once Polecat started doing so, the two stacked.Fix
Delete the redundant primary bridge in
WolverineOptionsPolecatExtensions.IntegrateWithWolverine(). This restores parity withWolverine.Marten, which registers nothing equivalent for its primary store precisely becauseAddMartenhandles it.TryAddEnumerableis not usable here: it throws when the descriptor's implementation type equals its service type, which is the case for anAddSingleton<IEventStore>(sp => ...)factory registration on both sides.The ancillary bridge in
AncillaryWolverineOptionsPolecatExtensionsis untouched and still required —AddPolecatStore<T>()does not registerIEventStorefor theTstore.Test
New
does_not_register_any_event_store_twiceinbootstrapping_ancillary_polecat_stores_with_wolverine(primary + ancillary host shape from the issue) asserts reference-distinctness, not just a count: every resolved store is a distinct instance, the primary appears exactly once, each ancillary exactly once. It fails loudly if Polecat ever drops its own registration.PolecatTestssuite: 241 passed, 4 skipped, 0 faileddotnet build wolverine.slnx -c Release: clean, 0 warningsFixes #3365
🤖 Generated with Claude Code