fix: async @EventHandler detached unit publishes lifecycle events under aggregation (#433)#436
Merged
Merged
Conversation
added 2 commits
July 20, 2026 21:15
…der aggregation (#433)
|
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.



Fixes #433.
Problem
In aggregated (multi-module) containers, async
@EventHandlerunits published no lifecycle events. Async dispatch runs through the module container'srunInDetachedEventScope→runInEventScope, and per-module containers are constructed withpublishLifecycleEvents=false(#339). The aggregator publishes unit lifecycle only around its ownrunInEventScope/supplyInEventScope(the sync path) — which async dispatch never traverses — so async units were invisible toEventStartedEvent/EventEndingEventmetrics.Fix
The gate was conflating two distinct questions.
publishLifecycleEvents=falsemeans "the aggregator brackets my sync units, so I stay silent" — but that reasoning does not hold for async detached units, which the aggregator never brackets. The module container is their sole publisher.The generated scope methods are refactored around a private
__runInEventScope(Runnable, boolean __publishLifecycle)core:runInEventScopedelegates with the standingpublishLifecycleEventsflag → sync units in a module stay silent (aggregator publishes the one pair). Unchanged behavior.runInDetachedEventScope(async path) forcestrue→ the detached unit always publishes its own pair.Single-module containers are built with
publishLifecycleEvents=true, so both paths publish exactly as before — no behavior change there.Tests
05_multi_moduleexample (MultiModuleLifecycleEventsTest): a genuineAggregatingContainerovermodule-a+module-b, an async@EventHandler, asserts exactly oneEventStartedEvent/EventEndingEventpair (one sharedeventId) reaches the shared bus. Verified red-before-green (times out with no pair when the force-trueis reverted).DetachedEventScopeTest,ContainerGeneratorLifecycleEventGateTest) to pin the new delegate/core structure and both gate expressions.16_async_scope(unchanged),tiko-runtime(155),tiko-test(27),tiko-processor(241), and both multi-module example reactors.docs/events.mdmulti-module note updated to describe the unified behavior.🤖 Generated with Claude Code