Skip to content

Commit 9afdcf1

Browse files
committed
fix: Fix possible invalid error message
1 parent 10ac374 commit 9afdcf1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Uno.UI.RemoteControl.Host/IDEChannel/IdeChannelServer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private async Task<bool> InitializeServer()
9696

9797
private async Task StartKeepAliveAsync()
9898
{
99+
// Note: The dev-server is expected to send message regularly ... and AS SOON AS POSSIBLE (the Task.Delay is after the first SendToIde()!).
99100
while (_pipeServer?.IsConnected ?? false)
100101
{
101102
_proxy?.SendToIde(new KeepAliveIdeMessage("dev-server"));

src/Uno.UI.RemoteControl.Host/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,19 @@ static async Task Main(string[] args)
9292
.SetMinimumLevel(LogLevel.Debug));
9393

9494
globalServices.AddGlobalTelemetry(); // Global telemetry services (Singleton)
95+
globalServices.AddSingleton<IIdeChannel, IdeChannelServer>();
9596

9697
#pragma warning disable ASP0000 // Do not call ConfigureServices after calling UseKestrel.
9798
var globalServiceProvider = globalServices.BuildServiceProvider();
9899
#pragma warning restore ASP0000
99100

100101
telemetry = globalServiceProvider.GetRequiredService<ITelemetry>();
101102

103+
// Force resolution of the IDEChannel to enable connection (Note: We should use a BackgroundService instead)
104+
// Note: The IDE channel is expected to inform IDE that we are up as soon as possible.
105+
// This is required for UDEI to **not** log invalid timeout message.
106+
globalServiceProvider.GetService<IIdeChannel>();
107+
102108
#pragma warning disable ASPDEPR004
103109
// WebHostBuilder is deprecated in .NET 10 RC1.
104110
// As we still build for .NET 9, ignore this warning until $(NetPrevious)=net10.
@@ -121,7 +127,7 @@ static async Task Main(string[] args)
121127
})
122128
.ConfigureServices(services =>
123129
{
124-
services.AddSingleton<IIdeChannel, IdeChannelServer>();
130+
services.AddSingleton<IIdeChannel>(_ => globalServiceProvider.GetRequiredService<IIdeChannel>());
125131
services.AddSingleton<UnoDevEnvironmentService>();
126132

127133
// Add the global service provider to the DI container
@@ -151,8 +157,6 @@ static async Task Main(string[] args)
151157
// Once the app has started, we use the logger from the host
152158
Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = host.Services.GetRequiredService<ILoggerFactory>();
153159

154-
// Force resolution of the IDEChannel to enable connection (Note: We should use a BackgroundService instead)
155-
host.Services.GetService<IIdeChannel>();
156160
_ = host.Services.GetRequiredService<UnoDevEnvironmentService>().StartAsync(ct.Token); // Background services are not supported by WebHostBuilder
157161

158162
// Display DevServer version banner

src/Uno.UI.RemoteControl.VS/EntryPoint.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ private async Task EnsureServerAsync()
517517

518518
async Task TrackConnectionTimeoutAsync(IdeChannelClient ideChannel)
519519
{
520-
await Task.Delay(5000, devServerCt.Token);
520+
// The dev-server is expected to connect back to the IDE as soon as possible, 10sec should be more than enough.
521+
await Task.Delay(10_000, devServerCt.Token);
521522
if (ideChannel.MessagesReceivedCount is 0 && _udei is not null && !devServerCt.IsCancellationRequested)
522523
{
523524
await _udei.NotifyDevServerTimeoutAsync(devServerCt.Token);

0 commit comments

Comments
 (0)