Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Assets/Tests/Editor/JsonRpcProcessorCliVersionGateTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -108,10 +107,6 @@ public async Task ProcessRequest_WhenFirstToolWaitsForMainThread_ReturnsServerBu

Assert.That(dispatcher.PendingContinuationCount, Is.EqualTo(1));

LogAssert.Expect(
LogType.Error,
new Regex("\\[JsonRpcProcessor\\] Error: Unity tool execution is busy running 'single-flight-test'"));

secondResponseTask = JsonRpcProcessor.ProcessRequestWithEarlyResponseAsync(
BuildToolRequest(SingleFlightTestTool.Name, 2),
CancellationToken.None,
Expand All @@ -123,6 +118,7 @@ public async Task ProcessRequest_WhenFirstToolWaitsForMainThread_ReturnsServerBu
Assert.That(data["type"]?.ToString(), Is.EqualTo("server_busy"));
Assert.That(data["runningToolName"]?.ToString(), Is.EqualTo(SingleFlightTestTool.Name));
Assert.That(data["requestedToolName"]?.ToString(), Is.EqualTo(SingleFlightTestTool.Name));
LogAssert.NoUnexpectedReceived();
}
finally
{
Expand Down Expand Up @@ -171,10 +167,6 @@ public async Task ProcessRequest_WhenExecuteDynamicCodeWaitsForMainThread_Allows
Assert.That(dispatcher.PendingContinuationCount, Is.EqualTo(2));
Assert.That(secondDynamicCodeTask.IsCompleted, Is.False);

LogAssert.Expect(
LogType.Error,
new Regex("\\[JsonRpcProcessor\\] Error: Unity tool execution is busy running 'execute-dynamic-code'"));

otherToolTask = JsonRpcProcessor.ProcessRequestWithEarlyResponseAsync(
BuildToolRequest(SingleFlightTestTool.Name, 3),
CancellationToken.None,
Expand All @@ -186,6 +178,7 @@ public async Task ProcessRequest_WhenExecuteDynamicCodeWaitsForMainThread_Allows
Assert.That(data["type"]?.ToString(), Is.EqualTo("server_busy"));
Assert.That(data["runningToolName"]?.ToString(), Is.EqualTo(UnityCliLoopConstants.TOOL_NAME_EXECUTE_DYNAMIC_CODE));
Assert.That(data["requestedToolName"]?.ToString(), Is.EqualTo(SingleFlightTestTool.Name));
LogAssert.NoUnexpectedReceived();
}
finally
{
Expand Down
12 changes: 11 additions & 1 deletion Packages/src/Editor/Infrastructure/Api/JsonRpcProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,21 @@ private static async Task<string> ProcessRpcRequest(
}
catch (Exception ex) when (!(ex is OperationCanceledException))
{
UnityEngine.Debug.LogError($"[JsonRpcProcessor] Error: {ex.Message}\nStack trace: {ex.StackTrace}");
LogRpcExceptionIfNeeded(ex);
return CreateErrorResponse(request.Id, ex);
}
}

private static void LogRpcExceptionIfNeeded(Exception ex)
{
if (ex is UnityCliLoopToolBusyException)
{
return;
}

UnityEngine.Debug.LogError($"[JsonRpcProcessor] Error: {ex.Message}\nStack trace: {ex.StackTrace}");
}

private static bool IsCliUpdateRequired(string currentCliVersion)
{
if (string.IsNullOrWhiteSpace(currentCliVersion))
Expand Down
Loading