From 5b709ed5a2fb03eefe86a01b14945534d1c13574 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 10 Jan 2025 13:54:50 -0500 Subject: [PATCH 1/3] fix(devSrv): Do not fail connection if a client processor fails --- .../HotReload/ClientHotReloadProcessor.cs | 19 ++++++++++++++----- .../RemoteControlClient.cs | 12 +++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs index 6ead2216e6dd..44c53194c25a 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs @@ -65,7 +65,7 @@ public async Task ProcessFrame(Messages.Frame frame) private async Task ConfigureServer() { var assembly = _rcClient.AppType.Assembly; - if (assembly.GetCustomAttributes(typeof(ProjectConfigurationAttribute), false) is ProjectConfigurationAttribute[] configs) + if (assembly.GetCustomAttributes(typeof(ProjectConfigurationAttribute), false) is ProjectConfigurationAttribute[]{Length: >0} configs) { _status.ReportServerState(HotReloadState.Initializing); @@ -85,14 +85,23 @@ private async Task ConfigureServer() _status.ReportInvalidRuntime(); } - ConfigureServer message = new(_projectPath, GetMetadataUpdateCapabilities(), _serverMetadataUpdatesEnabled, config.MSBuildProperties); + var message = new ConfigureServer(_projectPath, GetMetadataUpdateCapabilities(), _serverMetadataUpdatesEnabled, config.MSBuildProperties); await _rcClient.SendMessage(message); + + if (this.Log().IsEnabled(LogLevel.Trace)) + { + this.Log().Trace($"Successfully sent request to configure HR server for project '{_projectPath}'."); + } } - catch + catch (Exception error) { _status.ReportServerState(HotReloadState.Disabled); - throw; + + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError("Unable to configure HR server", error); + } } } else @@ -101,7 +110,7 @@ private async Task ConfigureServer() if (this.Log().IsEnabled(LogLevel.Error)) { - this.Log().LogError("Unable to find ProjectConfigurationAttribute"); + this.Log().LogError("Unable to configure HR server as ProjectConfigurationAttribute is missing."); } } } diff --git a/src/Uno.UI.RemoteControl/RemoteControlClient.cs b/src/Uno.UI.RemoteControl/RemoteControlClient.cs index 5df9baac1e12..e03ef47d87d3 100644 --- a/src/Uno.UI.RemoteControl/RemoteControlClient.cs +++ b/src/Uno.UI.RemoteControl/RemoteControlClient.cs @@ -499,7 +499,17 @@ private async Task ProcessMessages(WebSocket socket, CancellationToken ct) foreach (var processor in _processors) { - await processor.Value.Initialize(); + try + { + await processor.Value.Initialize(); + } + catch (Exception error) + { + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"Failed to initialize processor '{processor}'.", error); + } + } } StartKeepAliveTimer(); From 811c1a6ab4de07cf7704cab47bad15c9eef9951b Mon Sep 17 00:00:00 2001 From: David Date: Mon, 13 Jan 2025 09:27:17 -0500 Subject: [PATCH 2/3] chore: Change log level of processor missing --- .../RemoteControlClient.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Uno.UI.RemoteControl/RemoteControlClient.cs b/src/Uno.UI.RemoteControl/RemoteControlClient.cs index e03ef47d87d3..e350bab76e40 100644 --- a/src/Uno.UI.RemoteControl/RemoteControlClient.cs +++ b/src/Uno.UI.RemoteControl/RemoteControlClient.cs @@ -536,14 +536,23 @@ private async Task ProcessMessages(WebSocket socket, CancellationToken ct) this.Log().Trace($"Received frame [{frame.Scope}/{frame.Name}]"); } - bool skipProcessing = false; - + var skipProcessing = false; foreach (var preProcessor in _preprocessors) { - if (await preProcessor.SkipProcessingFrame(frame)) + try { - skipProcessing = true; - break; + if (await preProcessor.SkipProcessingFrame(frame)) + { + skipProcessing = true; + break; + } + } + catch (Exception error) + { + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"Error while **PRE**processing frame [{frame.Scope}/{frame.Name}]", error); + } } } @@ -564,9 +573,9 @@ private async Task ProcessMessages(WebSocket socket, CancellationToken ct) } else { - if (this.Log().IsEnabled(LogLevel.Error)) + if (this.Log().IsEnabled(LogLevel.Trace)) { - this.Log().LogError($"Unknown Frame scope {frame.Scope}"); + this.Log().Trace($"Unknown Frame scope {frame.Scope}"); } } } From 9eb8d0ecdc250bc97d5703e8a3c3fc91457bf2c0 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 13 Jan 2025 14:59:05 -0500 Subject: [PATCH 3/3] chore: Spaces --- src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs index 44c53194c25a..11b97f2da216 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.cs @@ -65,7 +65,7 @@ public async Task ProcessFrame(Messages.Frame frame) private async Task ConfigureServer() { var assembly = _rcClient.AppType.Assembly; - if (assembly.GetCustomAttributes(typeof(ProjectConfigurationAttribute), false) is ProjectConfigurationAttribute[]{Length: >0} configs) + if (assembly.GetCustomAttributes(typeof(ProjectConfigurationAttribute), false) is ProjectConfigurationAttribute[] { Length: > 0 } configs) { _status.ReportServerState(HotReloadState.Initializing);