Skip to content

Fire and forget (ARCH103)

Key dotnet.async.fire-and-forget · Severity warning · Category async

A call returning a Task should be awaited or assigned to a variable. Otherwise exceptions are lost and execution continues before the work completes.

public async Task HandleAsync()
{
_repository.SaveAsync();
await _notifier.NotifyAsync();
}
public async Task HandleAsync()
{
await _repository.SaveAsync();
await _notifier.NotifyAsync();
}

Await the Task, or explicitly assign it to a variable if intentional. If needed, suppress the rule per project/workspace via except/ignore.