AsyncLazy will cache the exceptions
Author: gravity00Created Oct 23, 2018Updated May 30, 2024
I believe it should be at least noted that if an exception occurs inside the factory function, the exception will be cached by the Task and since everything is a singleton, the application won't be able to recover from the failed state without some restart (unless I'm missing something).
Obviously this may or may not be a problem, depends on the developer needs, but usually this isn't the intended behavior. Most commonly is like not adding an item to a cache if the initialization fails.
Source: davidfowl/AspNetCoreDiagnosticScenarios