Fix gallery cancellation after concurrent refresh

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b34be394-240f-4bdd-878f-41460bc09c36
This commit is contained in:
Michael Jolley
2026-08-27 18:31:20 -05:00
parent a1af071496
commit 42cd5e4e50
2 changed files with 20 additions and 0 deletions

View File

@@ -254,6 +254,12 @@ public sealed partial class JsonRpcExtensionService : IExtensionService, IJsExte
{
RaiseProviderAdded(wrapper);
}
if (timeoutCts.IsCancellationRequested)
{
cancellationToken.ThrowIfCancellationRequested();
return false;
}
}
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
{

View File

@@ -182,6 +182,20 @@ public class JsonRpcExtensionServiceReconciliationTests
Assert.IsNull(manifest);
}
[TestMethod]
public async Task RefreshAndAwaitProviderAsync_CallerCancellation_Throws()
{
using var service = new JsonRpcExtensionService(TaskScheduler.Default);
using var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
await Assert.ThrowsExactlyAsync<OperationCanceledException>(() =>
service.RefreshAndAwaitProviderAsync(
Path.Combine(_root, "missing"),
TimeSpan.FromSeconds(1),
cancellationTokenSource.Token));
}
[TestMethod]
public void GetExtensionDirectoryForPath_ReturnsOwningTopLevelDirectory()
{