From 36b1e1d7c43f802c6c700c8dc009a5177f5c2944 Mon Sep 17 00:00:00 2001 From: PreethikaSelvam Date: Thu, 29 Oct 2026 11:34:15 +0530 Subject: [PATCH 1/3] Fixed the issue: With skipNegotiation: true, a temporary WebSocket reconnection failure displays the fatal error banner, which remains visible even after successful recovery. --- .../src/Platform/Circuits/CircuitManager.ts | 4 +- .../ServerReconnectionTest.cs | 73 +++++++++++++++++++ .../Pages/_ServerHost.cshtml | 3 + 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts b/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts index b911d0e30c72..4be47f6329c3 100644 --- a/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts +++ b/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts @@ -234,8 +234,8 @@ export class CircuitManager implements DotNet.DotNetCallDispatcher { } catch (ex: any) { this.unhandledError(ex as Error); - if (ex.errorType === 'FailedToNegotiateWithServerError') { - // Connection with the server has been interrupted, and we're in the process of reconnecting. + if (this._circuitId || ex.errorType === 'FailedToNegotiateWithServerError') { + // An existing circuit can retry any connection failure, including when negotiation is skipped. // Throw this exception so it can be handled at the reconnection layer, and don't show the // error notification. throw ex; diff --git a/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs index d072a9101e68..82437bbca0cd 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; using Microsoft.AspNetCore.E2ETesting; using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; using TestServer; using Xunit.Abstractions; @@ -48,6 +49,77 @@ public void ReconnectUI() Browser.Equal("2", () => Browser.Exists(By.Id("count")).Text); } + [Fact] + public void FailedReconnectDoesNotShowErrorUI_WithNegotiation() + { + FailedReconnectDoesNotShowErrorUI(skipNegotiation: false); + } + + [Fact] + public void FailedReconnectDoesNotShowErrorUI_WithoutNegotiation() + { + Navigate($"{ServerPathBase}?skipNegotiation=true"); + Browser.MountTestComponent(); + Browser.Exists(By.Id("count")); + + FailedReconnectDoesNotShowErrorUI(skipNegotiation: true); + } + + private void FailedReconnectDoesNotShowErrorUI(bool skipNegotiation) + { + Browser.Exists(By.Id("increment")).Click(); + Browser.Equal("1", () => Browser.Exists(By.Id("count")).Text); + + var chromeDriver = (ChromeDriver)Browser; + var javascript = (IJavaScriptExecutor)Browser; + var timeOrigin = javascript.ExecuteScript("return performance.timeOrigin"); + var logs = new List(); + string errorDisplayDuringRetry; + + chromeDriver.ExecuteCdpCommand("Network.enable", new Dictionary()); + try + { + SetOffline(chromeDriver, offline: true); + javascript.ExecuteScript("Blazor._internal.forceCloseConnection()"); + + Browser.Equal("block", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display")); + Browser.True(() => + { + logs.AddRange(Browser.Manage().Logs.GetLog(LogType.Browser)); + return logs.Any(entry => entry.Message.Contains(skipNegotiation + ? "Error: Error: WebSocket failed to connect" + : "Error: Error: Failed to complete negotiation")); + }); + errorDisplayDuringRetry = Browser.Exists(By.Id("blazor-error-ui")).GetCssValue("display"); + } + finally + { + SetOffline(chromeDriver, offline: false); + chromeDriver.ExecuteCdpCommand("Network.disable", new Dictionary()); + } + + Browser.Equal("none", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display")); + Browser.Exists(By.Id("increment")).Click(); + Browser.Equal("2", () => Browser.Exists(By.Id("count")).Text); + Assert.Equal(timeOrigin, javascript.ExecuteScript("return performance.timeOrigin")); + + Browser.Equal("none", () => Browser.Exists(By.Id("blazor-error-ui")).GetCssValue("display")); + Assert.Equal("none", errorDisplayDuringRetry); + logs.AddRange(Browser.Manage().Logs.GetLog(LogType.Browser)); + Assert.DoesNotContain(logs, entry => entry.Message.Contains("Cannot send data if the connection is not in the 'Connected' State.")); + } + + private static void SetOffline(ChromeDriver chromeDriver, bool offline) + { + chromeDriver.ExecuteCdpCommand("Network.emulateNetworkConditions", new Dictionary + { + ["offline"] = offline, + ["latency"] = 0, + ["downloadThroughput"] = -1, + ["uploadThroughput"] = -1, + }); + } + [Fact] public void RendersContinueAfterReconnect() { @@ -80,5 +152,6 @@ public void ErrorsStopTheRenderingProcess() Browser.Exists(By.Id("cause-error")).Click(); Browser.True(() => Browser.Manage().Logs.GetLog(LogType.Browser) .Any(l => l.Level == LogLevel.Info && l.Message.Contains("Connection disconnected."))); + Browser.Equal("block", () => Browser.Exists(By.Id("blazor-error-ui")).GetCssValue("display")); } } diff --git a/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml b/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml index 0870f09a058c..6310321f3037 100644 --- a/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml +++ b/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml @@ -66,6 +66,9 @@ myJsRootComponentInitializers.captureRendererInterop(Blazor); Blazor.start({ configureSignalR: builder => { + if (query.get('skipNegotiation') === 'true') { + builder.withUrl('_blazor', { skipNegotiation: true, transport: 1 }); + } if (query.has('captureAuthenticationRefresh')) { const build = builder.build.bind(builder); builder.build = () => { From 5d4f58f2c64b014524540fbeb1938a71c78ba15a Mon Sep 17 00:00:00 2001 From: PreethikaSelvam Date: Thu, 29 Oct 2026 12:00:50 +0530 Subject: [PATCH 2/3] Updated comment line. --- src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts b/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts index 4be47f6329c3..8b2859bcbe8a 100644 --- a/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts +++ b/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts @@ -235,7 +235,7 @@ export class CircuitManager implements DotNet.DotNetCallDispatcher { this.unhandledError(ex as Error); if (this._circuitId || ex.errorType === 'FailedToNegotiateWithServerError') { - // An existing circuit can retry any connection failure, including when negotiation is skipped. + // An existing circuit can retry any connection-start failure, including when negotiation is skipped. // Throw this exception so it can be handled at the reconnection layer, and don't show the // error notification. throw ex; From 23f4fbe09f8d2985779586bce916699eb29e9a24 Mon Sep 17 00:00:00 2001 From: PreethikaSelvam Date: Tue, 3 Nov 2026 11:31:09 +0530 Subject: [PATCH 3/3] Removed the E2E test. --- .../ServerReconnectionTest.cs | 73 ------------------- .../Pages/_ServerHost.cshtml | 3 - 2 files changed, 76 deletions(-) diff --git a/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs index 82437bbca0cd..d072a9101e68 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionTest.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; using Microsoft.AspNetCore.E2ETesting; using OpenQA.Selenium; -using OpenQA.Selenium.Chrome; using TestServer; using Xunit.Abstractions; @@ -49,77 +48,6 @@ public void ReconnectUI() Browser.Equal("2", () => Browser.Exists(By.Id("count")).Text); } - [Fact] - public void FailedReconnectDoesNotShowErrorUI_WithNegotiation() - { - FailedReconnectDoesNotShowErrorUI(skipNegotiation: false); - } - - [Fact] - public void FailedReconnectDoesNotShowErrorUI_WithoutNegotiation() - { - Navigate($"{ServerPathBase}?skipNegotiation=true"); - Browser.MountTestComponent(); - Browser.Exists(By.Id("count")); - - FailedReconnectDoesNotShowErrorUI(skipNegotiation: true); - } - - private void FailedReconnectDoesNotShowErrorUI(bool skipNegotiation) - { - Browser.Exists(By.Id("increment")).Click(); - Browser.Equal("1", () => Browser.Exists(By.Id("count")).Text); - - var chromeDriver = (ChromeDriver)Browser; - var javascript = (IJavaScriptExecutor)Browser; - var timeOrigin = javascript.ExecuteScript("return performance.timeOrigin"); - var logs = new List(); - string errorDisplayDuringRetry; - - chromeDriver.ExecuteCdpCommand("Network.enable", new Dictionary()); - try - { - SetOffline(chromeDriver, offline: true); - javascript.ExecuteScript("Blazor._internal.forceCloseConnection()"); - - Browser.Equal("block", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display")); - Browser.True(() => - { - logs.AddRange(Browser.Manage().Logs.GetLog(LogType.Browser)); - return logs.Any(entry => entry.Message.Contains(skipNegotiation - ? "Error: Error: WebSocket failed to connect" - : "Error: Error: Failed to complete negotiation")); - }); - errorDisplayDuringRetry = Browser.Exists(By.Id("blazor-error-ui")).GetCssValue("display"); - } - finally - { - SetOffline(chromeDriver, offline: false); - chromeDriver.ExecuteCdpCommand("Network.disable", new Dictionary()); - } - - Browser.Equal("none", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display")); - Browser.Exists(By.Id("increment")).Click(); - Browser.Equal("2", () => Browser.Exists(By.Id("count")).Text); - Assert.Equal(timeOrigin, javascript.ExecuteScript("return performance.timeOrigin")); - - Browser.Equal("none", () => Browser.Exists(By.Id("blazor-error-ui")).GetCssValue("display")); - Assert.Equal("none", errorDisplayDuringRetry); - logs.AddRange(Browser.Manage().Logs.GetLog(LogType.Browser)); - Assert.DoesNotContain(logs, entry => entry.Message.Contains("Cannot send data if the connection is not in the 'Connected' State.")); - } - - private static void SetOffline(ChromeDriver chromeDriver, bool offline) - { - chromeDriver.ExecuteCdpCommand("Network.emulateNetworkConditions", new Dictionary - { - ["offline"] = offline, - ["latency"] = 0, - ["downloadThroughput"] = -1, - ["uploadThroughput"] = -1, - }); - } - [Fact] public void RendersContinueAfterReconnect() { @@ -152,6 +80,5 @@ public void ErrorsStopTheRenderingProcess() Browser.Exists(By.Id("cause-error")).Click(); Browser.True(() => Browser.Manage().Logs.GetLog(LogType.Browser) .Any(l => l.Level == LogLevel.Info && l.Message.Contains("Connection disconnected."))); - Browser.Equal("block", () => Browser.Exists(By.Id("blazor-error-ui")).GetCssValue("display")); } } diff --git a/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml b/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml index 6310321f3037..0870f09a058c 100644 --- a/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml +++ b/src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml @@ -66,9 +66,6 @@ myJsRootComponentInitializers.captureRendererInterop(Blazor); Blazor.start({ configureSignalR: builder => { - if (query.get('skipNegotiation') === 'true') { - builder.withUrl('_blazor', { skipNegotiation: true, transport: 1 }); - } if (query.has('captureAuthenticationRefresh')) { const build = builder.build.bind(builder); builder.build = () => {