Skip to content

Announce that a load finished even when it failed - #5468

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/loader-stuck-after-failed-load
Oct 2, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/loader-stuck-after-failed-load

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

When ReloadPackages threw, the catch logged the exception and set IsLoading to false, but never raised FinishedLoading. The packages pages read "LoadsOnStart && !IsLoaded" as still-pending, so the page kept the "Loading packages" illustration forever -- and unlike the race fixed in #5387, navigating away and back re-ran FilterPackages against the same flags, so nothing short of hitting Reload cleared it.

Raise the event from the catch too, and have the pages ask HasPendingInitialLoad instead: a load that threw has concluded, even though it produced nothing. IsLoaded stays false on that path, so the callers that read it as "this list was never loaded, go fetch it" -- the IPC package list, the automatic updates editor, the maintenance scheduler's backup -- keep retrying exactly as they did before.

A FinishedLoading subscriber that throws unwinds into that same catch, so the announcement is guarded by a flag: a successful load whose subscriber threw must not fire the event a second time and re-run every handler that already ran, nor undo the state the success path just set. The announcement made from the catch is itself wrapped, so ReloadPackages still swallows what it swallowed before.

DiscoverablePackagesLoader re-arms its queued search from FinishedLoading, so a thrown load no longer strands that either.

When ReloadPackages threw, the catch logged the exception and set
IsLoading to false, but never raised FinishedLoading. The packages pages
read "LoadsOnStart && !IsLoaded" as still-pending, so the page kept the
"Loading packages" illustration forever -- and unlike the race fixed in
#5387, navigating away and back re-ran FilterPackages against the same
flags, so nothing short of hitting Reload cleared it.

Raise the event from the catch too, and have the pages ask
HasPendingInitialLoad instead: a load that threw has concluded, even
though it produced nothing. IsLoaded stays false on that path, so the
callers that read it as "this list was never loaded, go fetch it" -- the
IPC package list, the automatic updates editor, the maintenance
scheduler's backup -- keep retrying exactly as they did before.

A FinishedLoading subscriber that throws unwinds into that same catch,
so the announcement is guarded by a flag: a successful load whose
subscriber threw must not fire the event a second time and re-run every
handler that already ran, nor undo the state the success path just set.
The announcement made from the catch is itself wrapped, so ReloadPackages
still swallows what it swallowed before.

DiscoverablePackagesLoader re-arms its queued search from
FinishedLoading, so a thrown load no longer strands that either.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A throwing completion subscriber can incorrectly mark a successful load—or a newly started reload—as failed.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Updates package loaders and pages to treat failed loads as completed.

Changes:

  • Announces completion when loading throws.
  • Adds pending-initial-load state for UI rendering.
  • Adds failure and subscriber-exception tests.
File Description
PackageLoaderPipelineTests.cs Tests failed loads and throwing subscribers.
AbstractPackageLoader.cs Tracks pending loads and announces failures.
PackagesPageViewModel.cs Stops displaying indefinite loading after failure.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/UniGetUI.PackageEngine.PackageLoader/AbstractPackageLoader.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Failure events can trigger success-only automation, while throwing subscribers can prevent later handlers from receiving completion.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Isolate FinishedLoading subscriber failures

src/​UniGetUI.PackageEngine.PackageLoader/​AbstractPackageLoader.cs:266

This flag avoids invoking the whole event twice, but a multicast event stops at the first throwing subscriber, so every later subscriber is skipped permanently. A handler registered before the page/sidebar handlers can therefore leave those consumers in their loading state even though this method swallows the exception. Invoke each FinishedLoading handler independently with per-handler exception isolation, and extend the test with a recorder registered after the throwing handler.

This issue also appears on line 284 of the same file.

@randy-but-a-ro randy-but-a-ro Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉

Integration Details
{
	"deliveryId": "4830d9b0-be78-11f1-94c1-2fe3e3f0184a",
	"headSha": "3d7f8b2e7cab32558bf92d7c2a76d627a70587fd",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit eeb8888 into main Oct 2, 2026
6 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/loader-stuck-after-failed-load branch October 2, 2026 15:59
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