Fix async callback awaiting in HTTP endpoint (#6660)

* Await HTTP resume callbacks

* Update HttpEndpoint.cs

* Update HttpEndpointActivityExecutionContextExtensions.cs

* Refactor to use `WaitForHttpRequestAsync` consistently.

Replaced `WaitForHttpRequest` with `WaitForHttpRequestAsync` across the codebase to align with asynchronous naming conventions. This change improves clarity and maintains consistency in method naming.

* Add 'codex/*' branch to workflow path filters

This update ensures that actions in the workflow are triggered for changes in branches following the 'codex/*' naming convention. It aligns the path filters with the branching strategy and improves CI/CD coverage.
This commit is contained in:
Sipke Schoorstra 2025-05-20 11:24:23 +02:00 committed by GitHub
parent 2dcd852833
commit 562d91bd55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 23 deletions

View file

@ -11,6 +11,7 @@ on:
- 'enh/*'
- 'rc/*'
- 'develop/*'
- 'codex/*'
release:
types: [ prereleased, published ]
env:

View file

@ -163,7 +163,7 @@ public class HttpEndpoint : Trigger<HttpRequest>
{
var path = Path.Get(context);
var methods = SupportedMethods.GetOrDefault(context) ?? new List<string> { HttpMethods.Get };
context.WaitForHttpRequest(path, methods, OnResumeAsync);
await context.WaitForHttpRequestAsync(path, methods, OnResumeAsync);
}
private async ValueTask OnResumeAsync(ActivityExecutionContext context)
@ -497,4 +497,4 @@ public class HttpEndpoint : Trigger<HttpRequest>
return routeData;
}
}
}

View file

@ -20,10 +20,10 @@ public abstract class HttpEndpointBase<TResult> : Trigger<TResult>
{
}
protected override void Execute(ActivityExecutionContext context)
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var options = GetOptions();
context.WaitForHttpRequest(options, HttpRequestReceivedAsync);
await context.WaitForHttpRequestAsync(options, HttpRequestReceivedAsync);
}
protected override IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context)

View file

@ -9,27 +9,27 @@ namespace Elsa.Http.Extensions;
public static class HttpEndpointActivityExecutionContextExtensions
{
public static void WaitForHttpRequest(this ActivityExecutionContext context, string path, string method, ExecuteActivityDelegate? callback = null)
public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, string path, string method, ExecuteActivityDelegate? callback = null)
{
var options = new HttpEndpointOptions
{
var options = new HttpEndpointOptions
{
Path = path,
Methods = [method]
};
WaitForHttpRequest(context, options, callback);
}
Path = path,
Methods = [method]
};
await WaitForHttpRequestAsync(context, options, callback);
}
public static void WaitForHttpRequest(this ActivityExecutionContext context, string path, IEnumerable<string> methods, ExecuteActivityDelegate? callback = null)
public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, string path, IEnumerable<string> methods, ExecuteActivityDelegate? callback = null)
{
var options = new HttpEndpointOptions
{
var options = new HttpEndpointOptions
{
Path = path,
Methods = methods.ToList()
};
WaitForHttpRequest(context, options, callback);
}
Path = path,
Methods = methods.ToList()
};
await WaitForHttpRequestAsync(context, options, callback);
}
public static void WaitForHttpRequest(this ActivityExecutionContext context, HttpEndpointOptions options, ExecuteActivityDelegate? callback = null)
public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, HttpEndpointOptions options, ExecuteActivityDelegate? callback = null)
{
var path = options.Path;
if (path.Contains("//"))
@ -42,7 +42,8 @@ public static class HttpEndpointActivityExecutionContextExtensions
return;
}
callback?.Invoke(context);
if (callback is not null)
await callback(context);
}
public static IEnumerable<object> GetHttpEndpointStimuli(this TriggerIndexingContext context, string path, string method)
@ -91,4 +92,4 @@ public static class HttpEndpointActivityExecutionContextExtensions
};
context.CreateBookmark(bookmarkOptions);
}
}
}