Problem
App.axaml.cs has two startup reliability defects:
1. Fire-and-forget InitialiseAsync
Line 46: _ = InitialiseAsync(_serviceProvider, viewModel);
If MigrateAsync or LoadPersistedAccountsAsync throws, the exception is unobserved and silently discarded. The app will appear to start normally but with no accounts loaded and no migration applied.
Fix — attach an explicit error-surfacing continuation:
_ = InitialiseAsync(_serviceProvider, viewModel)
.ContinueWith(t =>
{
if (t.Exception is { } ex)
{
LogStartupFailed(_logger, ex.Message);
Dispatcher.UIThread.InvokeAsync(() =>
{
viewModel.HasError = true;
viewModel.ErrorMessage = "Startup failed. Please restart the application.";
});
}
}, TaskScheduler.Default);
2. Missing TaskScheduler.UnobservedTaskException handler
onedrive-di.md requires a top-level unhandled exception handler:
TaskScheduler.UnobservedTaskException += (_, args) =>
{
LogUnhandledException(_logger, args.Exception);
args.SetObserved();
RxApp.MainThreadScheduler.Schedule(() =>
{
viewModel.HasError = true;
viewModel.ErrorMessage = "An unexpected error occurred. Please restart the application.";
});
};
Without this, unobserved exceptions from any async operation silently crash the task.
Rule reference
@.claude/rules/onedrive-di.md — Unhandled exceptions section
Problem
App.axaml.cshas two startup reliability defects:1. Fire-and-forget
InitialiseAsyncLine 46:
_ = InitialiseAsync(_serviceProvider, viewModel);If
MigrateAsyncorLoadPersistedAccountsAsyncthrows, the exception is unobserved and silently discarded. The app will appear to start normally but with no accounts loaded and no migration applied.Fix — attach an explicit error-surfacing continuation:
2. Missing
TaskScheduler.UnobservedTaskExceptionhandleronedrive-di.mdrequires a top-level unhandled exception handler:Without this, unobserved exceptions from any async operation silently crash the task.
Rule reference
@.claude/rules/onedrive-di.md— Unhandled exceptions section