Skip to content

CHR0083: Reactor handler must not be async void

An async void handler returns to Chronicle before its asynchronous work completes. Chronicle cannot await that work or observe its exceptions through the handler’s return value. CHR0083 reports non-static async-void reactor methods whose first parameter is a known event type and whose remaining parameters satisfy the reactor dependency checks. Public and nonpublic handlers follow the same runtime convention, including private, protected and internal methods.

The rule uses the same event-type and explicit-registration evidence as the existing reactor method checks. A reactor can implement IReactor or be explicitly registered; its event parameter can have [EventType] or be explicitly registered.

Warning

Change the handler from async void to async Task. Keep its body and await its asynchronous operations. The Return Task from async reactor handler code fix replaces only the return type with global::System.Threading.Tasks.Task, preserving the body, attributes, parameters and comments. The fully qualified name also works when another type named Task is in scope. Fix All is supported.

The code fix is withheld for overrides and explicit or implicit interface implementations, because changing their return type would break an existing signature contract. Eligible override and implicit-interface handlers still receive the warning; resolving it requires changing the contract or restructuring the asynchronous work. Explicit interface implementations are not ordinary handler methods and do not receive CHR0083.

Synchronous void, Task and Task<T> handlers are unaffected. Methods without a known event first parameter are helpers, regardless of their accessibility. Static methods and unrelated classes are not covered. Existing missing-event and invalid-dependency diagnostics remain separate; a method rejected by those checks does not also receive CHR0083.

  • CHR0004: Reactor method has a parameter that cannot be resolved.
  • CHR0005: Reactor event parameter must have [EventType] attribute.
  • CHR0054: Reactor method has an unsupported return type.
  • CHR0082: Scenario terminal tasks must not be discarded.