Skip to content

Observe fire-and-forget startup tasks in WebHosting - #493

Merged
LarsLaskowski merged 3 commits into
mainfrom
claude/issue-195-5wrdpe
Jul 26, 2026
Merged

Observe fire-and-forget startup tasks in WebHosting#493
LarsLaskowski merged 3 commits into
mainfrom
claude/issue-195-5wrdpe

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

_webApplication.StartAsync(_cts.Token) and StartupCache(_cts.Token) in WebHosting.StartWebHosting were started without being awaited or otherwise observed. The trailing .ConfigureAwait(false) on StartupCache had no effect since the task was never awaited, so a startup failure of the web host or the cache initialization stayed completely silent.

Both tasks are now tracked and observed through a new ObserveStartupTask helper, which attaches a fault-only continuation that logs the exception via the application logger, without changing the fire-and-forget startup flow.

Linked issues

Closes #195

Review notes

StartWebHosting remains synchronous by design (it is called from the non-async StartReceiving), so the fix keeps the startup calls fire-and-forget but ensures faults are logged rather than swallowed.

claude added 3 commits July 26, 2026 06:53
_webApplication.StartAsync and StartupCache were started without being
awaited or observed, so a startup failure of the web host or the cache
initialization stayed silent. Both tasks are now tracked and any fault
is logged through the application logger.
Read the AggregateException into a local before the null-conditional
logger call so it is always observed, and log GetBaseException instead
of the wrapping AggregateException. Drop the redundant Logging using
directive already supplied by the Web SDK, document the new logger
field, and move the helper methods into the existing Private methods
region.
applicationData.Logger stays null unless OpenTelemetry logging is
configured, which silently swallowed the newly observed startup faults
in the default setup. The logger now falls back to the web
application's own ILoggerFactory once the host is built. A faulting
StartAsync also resets IsRunning so a host that failed to bind no
longer reports itself as running.
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit e0146ce into main Jul 26, 2026
6 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-195-5wrdpe branch July 26, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F-274 · Fire-and-forget: _webApplication.StartAsync(_cts.Token) (125) and …

2 participants