From 11c65ec4b73661355d85dde200882ae970f0b949 Mon Sep 17 00:00:00 2001 From: Nelson Parente Date: Mon, 5 Oct 2026 02:18:31 +0200 Subject: [PATCH] test(workflow): gate the failing delta in RetiredStreamCannotOverwriteCurrentStreamCache The failing delta tears down the first stream, which cancels its token. When the retired turn's task has not started at that moment, Task.Run never runs it. Then retiredHandlerStarted is never set, and the current turn waits until the 20-second timeout. Deliver the failing delta only after the retired turn's handler has started. Signed-off-by: Nelson Parente Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017JhKUDV9dbs5JDz2uwZqz5 --- .../Worker/Grpc/GrpcProtocolHandlerStatefulHistoryTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Dapr.Workflow.Test/Worker/Grpc/GrpcProtocolHandlerStatefulHistoryTests.cs b/test/Dapr.Workflow.Test/Worker/Grpc/GrpcProtocolHandlerStatefulHistoryTests.cs index 3073aa2fe..2010e43a6 100644 --- a/test/Dapr.Workflow.Test/Worker/Grpc/GrpcProtocolHandlerStatefulHistoryTests.cs +++ b/test/Dapr.Workflow.Test/Worker/Grpc/GrpcProtocolHandlerStatefulHistoryTests.cs @@ -366,12 +366,15 @@ public async Task RetiredStreamCannotOverwriteCurrentStreamCache() var releaseRetiredHandler = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var retiredCompletionSent = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + // The failing delta tears down the first stream, which cancels that stream's token. A work item + // whose task has not started by then never runs, so deliver the failing delta only once the + // retired turn's handler is running. Otherwise the current turn waits for it forever. grpcClientMock .SetupSequence(x => x.GetWorkItems(It.IsAny(), It.IsAny())) .Returns(CreateServerStreamingCallFromReader(new GatedStreamReader( [ (retiredTurn, null), - (new WorkItem { WorkflowRequest = failingDelta }, null), + (new WorkItem { WorkflowRequest = failingDelta }, retiredHandlerStarted.Task), (new WorkItem(), neverCompletes.Task) ]))) .Returns(CreateServerStreamingCallFromReader(new GatedStreamReader(