From ab21220b80047503c8a1d0d2a2cafbb2b80e710c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 03:19:28 +0000 Subject: [PATCH 1/5] Initial plan From d0369703a1a4fcca495f64c66531af53f9ecfea3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 03:26:22 +0000 Subject: [PATCH 2/5] Fix race condition in AssetCachingTests by using separate TaskCompletionSource variables Co-authored-by: lewing <24063+lewing@users.noreply.github.com> --- .../Wasm.Build.Tests/Blazor/AssetCachingTests.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs index c6c4988dca8768..3be4da74da8fb1 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs @@ -35,7 +35,8 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache() (string projectDir, string output) = BlazorPublish(project, Configuration.Release, new PublishOptions(AssertAppBundle: false)); - var counterLoaded = new TaskCompletionSource(); + var firstCounterLoaded = new TaskCompletionSource(); + var secondCounterLoaded = new TaskCompletionSource(); var wasmRequestRecorder = new WasmRequestRecorder(); var runOptions = new BlazorRunOptions(Configuration.Release) @@ -45,23 +46,25 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache() OnConsoleMessage = (type, msg) => { if (msg.Contains("Counter.OnAfterRender")) - counterLoaded.SetResult(); + { + firstCounterLoaded.TrySetResult(); + secondCounterLoaded.TrySetResult(); + } }, Test = async (page) => { - await counterLoaded.Task; + await firstCounterLoaded.Task; // Check server request logs after the first load. Assert.NotEmpty(wasmRequestRecorder.ResponseCodes); Assert.All(wasmRequestRecorder.ResponseCodes, r => Assert.Equal(200, r.ResponseCode)); wasmRequestRecorder.ResponseCodes.Clear(); - counterLoaded = new(); // Perform browser navigation to cause resource reload. // We use the initial base URL because the test server is not configured for SPA routing. await page.ReloadAsync(); - await counterLoaded.Task; + await secondCounterLoaded.Task; // Check server logs after the second load. if (EnvironmentVariables.UseFingerprinting) From 54bb1d825a7658a82b7cf3105095cafe4ec07e6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 03:27:53 +0000 Subject: [PATCH 3/5] Use counter to properly track which page load to signal Co-authored-by: lewing <24063+lewing@users.noreply.github.com> --- .../wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs index 3be4da74da8fb1..9202327cb5ad23 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using Microsoft.Playwright; using Xunit; @@ -37,6 +38,7 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache() var firstCounterLoaded = new TaskCompletionSource(); var secondCounterLoaded = new TaskCompletionSource(); + var loadCount = 0; var wasmRequestRecorder = new WasmRequestRecorder(); var runOptions = new BlazorRunOptions(Configuration.Release) @@ -47,8 +49,10 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache() { if (msg.Contains("Counter.OnAfterRender")) { - firstCounterLoaded.TrySetResult(); - secondCounterLoaded.TrySetResult(); + if (Interlocked.Increment(ref loadCount) == 1) + firstCounterLoaded.SetResult(); + else + secondCounterLoaded.SetResult(); } }, Test = async (page) => From 01819d378f88f1d3e3e06117cc2d56d4876e49ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 03:28:58 +0000 Subject: [PATCH 4/5] Add explicit count check to handle only first two page loads Co-authored-by: lewing <24063+lewing@users.noreply.github.com> --- src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs index 9202327cb5ad23..977cab6ff5d449 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs @@ -49,9 +49,10 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache() { if (msg.Contains("Counter.OnAfterRender")) { - if (Interlocked.Increment(ref loadCount) == 1) + var count = Interlocked.Increment(ref loadCount); + if (count == 1) firstCounterLoaded.SetResult(); - else + else if (count == 2) secondCounterLoaded.SetResult(); } }, From 900b9fcd06cb1b0d14cde5d16ed61eeb90fc395d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 05:00:49 +0000 Subject: [PATCH 5/5] Remove ActiveIssue attribute now that race condition is fixed Co-authored-by: lewing <24063+lewing@users.noreply.github.com> --- src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs index 977cab6ff5d449..22ee79b8d3b764 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs @@ -23,7 +23,6 @@ public AssetCachingTests(ITestOutputHelper output, SharedBuildPerTestClassFixtur } [Fact, TestCategory("no-fingerprinting")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/122338")] // add it back to eng\testing\scenarios\BuildWasmAppsJobsList.txt public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache() { var project = CopyTestAsset(