Skip to content

Fix race condition on startup and improve fault tolerance#4914

Merged
Gabriel Dufresne (GabrielDuf) merged 3 commits into
mainfrom
fix/startup-crash-hardening
Jun 11, 2026
Merged

Fix race condition on startup and improve fault tolerance#4914
Gabriel Dufresne (GabrielDuf) merged 3 commits into
mainfrom
fix/startup-crash-hardening

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request improves the robustness of package manager initialization and error reporting throughout the application, ensuring that failures in constructing individual package managers do not crash the entire app. It also enhances exception logging and updates code to handle package managers that may be unavailable at runtime.

Package Manager Initialization and Handling

  • Refactored PEInterface so that each package manager (WinGet, Scoop, Chocolatey, etc.) is now initialized via a safe Create method that catches and logs exceptions, returning null if construction fails. This prevents a single manager's failure from crashing the app during static initialization. (src/UniGetUI.PackageEngine.PackageEngine/PEInterface.cs src/UniGetUI.PackageEngine.PackageEngine/PEInterface.csL36-R114)
  • Updated all usages of package manager fields to handle the possibility of null values, including in IgnoredUpdates.xaml.cs, MainView.xaml.cs, and PackageManager.xaml.cs, preventing null reference exceptions and gracefully skipping unavailable managers. (src/UniGetUI/Pages/DialogPages/IgnoredUpdates.xaml.cs src/UniGetUI/Pages/MainView.xaml.cs src/UniGetUI/Pages/SettingsPages/ManagersPages/PackageManager.xaml.cs

Exception Logging Improvements

  • Enhanced the crash handler to include the full exception detail using Exception.ToString(), ensuring that all inner exceptions (including those in AggregateException) are logged, not just the direct InnerException chain. (src/UniGetUI/CrashHandler.cs

Application Startup Stability

  • Ensured that Avalonia's UI-thread dispatcher is bound to the main thread before starting the single-instance listener, preventing threading issues if a second instance connects during startup. (src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs

@GabrielDuf Gabriel Dufresne (GabrielDuf) merged commit 2d6b4bd into main Jun 11, 2026
3 checks passed
@GabrielDuf Gabriel Dufresne (GabrielDuf) deleted the fix/startup-crash-hardening branch June 11, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants