update quality
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Scalar.AspNetCore;
|
||||
|
||||
// Ensure S8n.Components.Packages assembly is loaded
|
||||
@@ -85,7 +86,7 @@ app.MapGet("/api/components", () =>
|
||||
.WithName("GetComponents");
|
||||
|
||||
// Runtime execution endpoint
|
||||
app.MapPost("/api/runtime/execute", (RuntimeRequest request) =>
|
||||
app.MapPost("/api/runtime/execute", async (RuntimeRequest request) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -166,6 +167,43 @@ app.MapPost("/api/runtime/execute", (RuntimeRequest request) =>
|
||||
result = method.Invoke(instance, null);
|
||||
}
|
||||
|
||||
Console.Error.WriteLine($"Invocation result type: {result?.GetType()}");
|
||||
// If method returns a Task, await it
|
||||
if (result is Task taskResult)
|
||||
{
|
||||
Console.Error.WriteLine($"Detected Task, awaiting...");
|
||||
await taskResult.ConfigureAwait(false);
|
||||
Console.Error.WriteLine($"Task completed, status: {taskResult.Status}");
|
||||
|
||||
// If it's a Task<T>, get the result via reflection
|
||||
var resultType = taskResult.GetType();
|
||||
Console.Error.WriteLine($"Task result type: {resultType}");
|
||||
if (typeof(Task).IsAssignableFrom(resultType))
|
||||
{
|
||||
Console.Error.WriteLine($"Generic Task detected");
|
||||
// Get the Result property
|
||||
var resultProperty = resultType.GetProperty("Result");
|
||||
if (resultProperty != null)
|
||||
{
|
||||
result = resultProperty.GetValue(taskResult);
|
||||
Console.Error.WriteLine($"Result value: {result}");
|
||||
Console.Error.WriteLine($"Result value type: {result?.GetType()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine($"Result property not found");
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Task (non-generic) returns nothing
|
||||
Console.Error.WriteLine($"Non-generic Task, setting result to null");
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
Console.Error.WriteLine($"Final result: {result}");
|
||||
return Results.Ok(new RuntimeResponse
|
||||
{
|
||||
Outputs = result
|
||||
|
||||
Reference in New Issue
Block a user