Skip to content

Commit ca4d724

Browse files
authored
Check for existing executor (#3265)
* Check for existing executor * Update release_notes.md
1 parent 0fd5e91 commit ca4d724

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Bug Fixes
88

9+
- Check if function invocation already has an executor before registering durable executor. (#3265)
10+
911
### Breaking Changes
1012

1113
### Dependency Updates

src/Worker.Extensions.DurableTask/DurableTaskFunctionsMiddleware.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ internal class DurableTaskFunctionsMiddleware(DurableFunctionExecutor invoker) :
1616
/// <inheritdoc />
1717
public Task Invoke(FunctionContext functionContext, FunctionExecutionDelegate next)
1818
{
19-
if (functionContext.TryGetOrchestrationBinding(out _)
20-
|| functionContext.TryGetEntityBinding(out _)
21-
|| functionContext.TryGetActivityBinding(out _))
19+
// If the function is a Durable Task function and there is no executor registered yet,
20+
// register the Durable Function executor.
21+
if (functionContext.Features.Get<IFunctionExecutor>() is null && functionContext.IsDurableTaskFunction())
2222
{
2323
functionContext.Features.Set<IFunctionExecutor>(invoker);
2424
}

src/Worker.Extensions.DurableTask/FunctionContextExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ namespace Microsoft.Azure.Functions.Worker.Extensions.DurableTask;
1111

1212
internal static class FunctionContextExtensions
1313
{
14+
/// <summary>
15+
/// Determines whether the function context represents a Durable Task function.
16+
/// </summary>
17+
/// <param name="context">The function context.</param>
18+
/// <returns>True if function is a durable task trigger, false otherwise.</returns>
19+
public static bool IsDurableTaskFunction(this FunctionContext context)
20+
=> context.TryGetOrchestrationBinding(out _)
21+
|| context.TryGetActivityBinding(out _)
22+
|| context.TryGetEntityBinding(out _);
23+
1424
/// <summary>
1525
/// Tries to get the orchestration trigger binding from the function context.
1626
/// </summary>

0 commit comments

Comments
 (0)