Fix duplicate instances on toast click when IPC forward times out#5184
Merged
Gabriel Dufresne (GabrielDuf) merged 3 commits intoJul 23, 2026
Merged
Conversation
Copilot started reviewing on behalf of
Gabriel Dufresne (GabrielDuf)
July 23, 2026 13:37
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Improves single-instance IPC resilience for Avalonia launches.
Changes:
- Handles concurrent named-pipe connections asynchronously.
- Adds read and forwarding timeouts with retry logic.
- Prevents stalled clients from blocking subsequent activations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Marc-André Moreau (mamoreau-devolutions)
approved these changes
Jul 23, 2026
Gabriel Dufresne (GabrielDuf)
deleted the
fix/single-instance-forward-timeout
branch
July 23, 2026 15:43
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the single-instance handling logic in
SingleInstanceRedirector.csto make inter-process communication via named pipes more robust and responsive. The main improvements are around error handling, non-blocking connection management, and timeouts for both reading and forwarding arguments between instances.Named pipe connection handling improvements:
NamedPipeServerStream.MaxAllowedServerInstancesand asynchronous options, allowing multiple incoming connections to be handled without blocking the main thread. Each client connection is processed off-thread, so a slow or stuck client cannot prevent new connections. (src/UniGetUI.Avalonia/Infrastructure/SingleInstanceRedirector.cs)HandleConnectionmethod that reads pipe input asynchronously with a timeout (ReadTimeout), preventing clients that never send EOF from blocking the server. Errors are logged without crashing the listener. (src/UniGetUI.Avalonia/Infrastructure/SingleInstanceRedirector.cs)Timeouts and retry logic:
ForwardBudgetandReadTimeoutconstants to bound how long the process will attempt to forward arguments to the first instance and how long it will wait for pipe reads, respectively. (src/UniGetUI.Avalonia/Infrastructure/SingleInstanceRedirector.cs)TryForwardToFirstInstancemethod now retries connecting and sending arguments to the first instance until theForwardBudgetexpires, logging the last error if unsuccessful. (src/UniGetUI.Avalonia/Infrastructure/SingleInstanceRedirector.cs)