File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
test/e2e/Apps/BasicDotNetIsolated Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 88using System . Diagnostics ;
99
1010var host = new HostBuilder ( )
11- . ConfigureFunctionsWebApplication ( )
11+ . ConfigureFunctionsWebApplication ( workerApplication =>
12+ {
13+ // Register async middleware to test the fix for https://github.com/microsoft/durabletask-dotnet/issues/158
14+ // This middleware performs async operations that previously caused non-determinism exceptions
15+ workerApplication . UseMiddleware < Microsoft . Azure . Durable . Tests . E2E . TestAsyncMiddleware > ( ) ;
16+ } )
1217 . ConfigureServices ( services => {
1318 services . AddApplicationInsightsTelemetryWorkerService ( ) ;
1419 services . ConfigureFunctionsApplicationInsights ( ) ;
Original file line number Diff line number Diff line change 1+ // Copyright (c) .NET Foundation. All rights reserved.
2+ // Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+ using System ;
5+ using System . Threading . Tasks ;
6+ using Microsoft . Azure . Functions . Worker ;
7+ using Microsoft . Azure . Functions . Worker . Middleware ;
8+
9+ namespace Microsoft . Azure . Durable . Tests . E2E ;
10+
11+ /// <summary>
12+ /// Test middleware that performs async operations to validate the fix for
13+ /// https://github.com/microsoft/durabletask-dotnet/issues/158
14+ /// This middleware simulates async behaviors like App Configuration or logging services.
15+ /// </summary>
16+ public class TestAsyncMiddleware : IFunctionsWorkerMiddleware
17+ {
18+ public async Task Invoke ( FunctionContext context , FunctionExecutionDelegate next )
19+ {
20+ // Simulate an async operation like fetching configuration or logging
21+ await Task . Delay ( 1 ) ;
22+
23+ // Store metadata to verify the middleware ran
24+ context . Items [ "AsyncMiddlewareExecuted" ] = true ;
25+ context . Items [ "AsyncMiddlewareTimestamp" ] = DateTime . UtcNow ;
26+
27+ // Continue to the next middleware/function
28+ await next ( context ) ;
29+
30+ // Simulate async post-processing
31+ await Task . Delay ( 1 ) ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments