Repository navigation
Fix crash when searching in the Python Packages dialog - #1795
deepratna-awale wants to merge 6 commits into
Conversation
Selecting a package loads its details (pip show / pip index) in a fire-and-forget task with no exception handler, so any failure other than a ProcessException was rethrown on the UI thread and took down the app. Typing in the search box moves the selection on almost every keystroke, starting one of these loads per keystroke, overlapping against the same venv. - Log failures of the details load instead of rethrowing them - Load one package's details at a time and skip loads whose package is no longer selected - Don't start a second load for an item that is already loading - PipIndexResult.Parse returns no versions instead of throwing when the output has no "Available versions:" line - PipShowResult.Parse no longer throws when "License:" has no following "Location:" line Fixes LykosAI#693
|
Nice digging on this one. The diagnosis checks out: the Avalonia app never sets a default A few non-blocking notes:
Looks good to merge. |
|
@mohnjiles I would like to do this before you Merge. |
PythonPackagesItemViewModel now owns the already loaded / loading check, so the dialog view model only checks that the selection hasn't moved on. A failed load shows a message in the details pane and is retried when the package is selected again. Pending loads are cancelled when the dialog closes, and the cancellation source and lock are disposed with the view model.
New UI tests cover the error and retry path and closing the dialog mid-load. |
ionite34
left a comment
There was a problem hiding this comment.
Thanks for the follow-ups! One thing left: if pip index fails, selecting the package again doesn't retry. PipShowResult is set (line 112) before PipIndex runs (line 117), so after an index failure the guard at line 94 returns early and the error stays until the dialog closes.
Assigning PipShowResult only after both calls succeed should fix it.
PipShowResult was set before pip index ran, so an index failure left the item looking loaded and selecting it again never retried. It is now assigned only once both calls succeed.
|
Noice catch, aarigato. PipShowResult is now assigned only after both pip show and pip index succeed, so a failed index lookup leaves the item unloaded and selecting it again retries. Added FailedIndexLookup_RetriesWhenSelectedAgain to cover it. |
|
The last commit is just for peas in a pod achievement on github lol |
Co-authored-by: Ionite34 <ionite34@users.noreply.github.com>
6cb63fa to
7d1b666
Compare
Fixes #693
Problem
Searching in Packages → ⋯ → Python Packages can crash Stability Matrix (e.g. typing "ja" to find
jax). Pasting the full name works around it.Selecting a package loads its details (
pip show/pip index versions) viaLoadExtraInfo(...).SafeFireAndForget()with no exception handler. With no handler, AsyncAwaitBestPractices lets the exception escape, so anything other than aProcessException(e.g.FileNotFoundExceptionfrom the uv/pip/pyvenv.cfg checks in the venv runner,InvalidOperationExceptionfromPipIndexResult.Parse,ArgumentOutOfRangeExceptionfromPipShowResult.Parse) is rethrown on the UI thread and ends the app.The list box uses
SelectionMode="AlwaysSelected", so as the search filter narrows the list the selection jumps to a new package on almost every keystroke. Each jump started another details load, and those loads overlapped against the same venv, each one rewritingpyvenv.cfgand spawning its own pip processes. Pasting the name changes the selection once, which is why the workaround helps.Changes
PythonPackagesViewModelSemaphoreSlim). A load still waiting for its turn is dropped when the selection moves on, and a load whose package is no longer selected is skipped.PythonPackagesItemViewModel.LoadExtraInfotakes a venv runner factory instead of a path plusPyBaseInstall, and skips if it is already loading.PipIndexResult.Parsereturns no versions instead of throwing when the output has noAvailable versions:line.PipShowResult.Parseno longer throws when aLicense:line has noLocation:line after it.Testing
PythonPackagesDialogTests) open the real dialog over a substituted venv runner and type into the search box:TypingInSearch_WhenPackageDetailsFailToLoad_DoesNotCrash:pip showthrowsFileNotFoundException. On the old code the exception is rethrown on the dispatcher and fails the test. It passes with the fix.TypingInSearch_LoadsOnePackagesDetailsAtATime: on the old code more than one detail load ran at once. With the fix, at most one runs at a time.PipIndexResultTestsand two extraPipShowResultsTestscases (license without location, location before license).StabilityMatrix.UITests: 21/21 passed.StabilityMatrix.Tests: all passed except theTestLicenseUrl/TestPreviewImageUrichecks, which need outbound network access that my test environment blocks (unrelated to this change).