From 4a6632436b143c53b0d8627ca25f7b98916028ec Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 11:25:43 -0800 Subject: [PATCH 1/8] Align DTS gRPC message limits with the 4 MiB service limit Default MaxReceiveMessageSize/MaxSendMessageSize to 4 MiB instead of 64 MiB, matching the DTS service limit for unary calls and each streamed message. Bound activity and entity completions with the same worker completion bound as orchestration responses. Oversized results now fail with non-retriable ActivityResponseTooLarge / EntityResultTooLarge instead of being abandoned and re-executed indefinitely. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 3 ++ api/failure.go | 2 + client/grpc_worker.go | 9 +++-- client/grpc_worker_processor.go | 53 +++++++++++++++++++++++++ client/grpc_worker_test.go | 47 ++++++++++++++++++++++ durabletaskscheduler/README.md | 17 +++++--- durabletaskscheduler/connection_test.go | 26 ++++++------ durabletaskscheduler/options.go | 9 +++-- 8 files changed, 139 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9083bcc1..09e65147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- DTS connections now default `MaxReceiveMessageSize` and `MaxSendMessageSize` to 4 MiB, matching the DTS service limit for unary calls and each streamed message, instead of 64 MiB. Larger payloads now fail locally rather than after a service round-trip; use large-payload externalization for them. +- Activity and entity completions are now checked after large-payload externalization against the same worker completion bound as orchestration responses. Oversized results fail with non-retriable `api.ErrorTypeActivityResponseTooLarge` or `api.ErrorTypeEntityResultTooLarge` instead of being abandoned and re-executed indefinitely. + - Refreshed the vendored Durable Task protobuf contract to [`2dab0e7`](https://github.com/microsoft/durabletask-protobuf/commit/2dab0e72d0dea59c5c8c412dd03204a47b9aaf2f). It adds the sidecar extended-session RPCs and messages, `completionCount` on orchestration and entity completions, and tags on entity-started orchestrations. The worker doesn't use them yet. - Azure Blob payload reads use independent `AllowAllContainersInConfiguredAccount` and `AdditionalAccountURLs` options, with endpoint-and-container defaults shared by native token and generic location reads. Additional accounts require identity authentication and exact service endpoints. V2 token queries and fragments are ignored when resolving existing references; new v2 tokens remain credential-free, and v1 reads remain supported. diff --git a/api/failure.go b/api/failure.go index 482ba0f6..1938f0b5 100644 --- a/api/failure.go +++ b/api/failure.go @@ -19,6 +19,8 @@ const ( ErrorTypeVersionError ErrorType = "VersionError" ErrorTypeHistoryLimitExceeded ErrorType = "HistoryLimitExceeded" ErrorTypeOrchestratorResponseTooLarge ErrorType = "OrchestratorResponseTooLarge" + ErrorTypeActivityResponseTooLarge ErrorType = "ActivityResponseTooLarge" + ErrorTypeEntityResultTooLarge ErrorType = "EntityResultTooLarge" ErrorTypeActivityPanic ErrorType = "TaskActivityPanic" ErrorTypeEntityOperationPanic ErrorType = "EntityOperationPanic" ErrorTypeOrchestratorPanic ErrorType = "OrchestratorPanic" diff --git a/client/grpc_worker.go b/client/grpc_worker.go index ea367103..6ee1b8cb 100644 --- a/client/grpc_worker.go +++ b/client/grpc_worker.go @@ -65,7 +65,7 @@ const ( MaxStreamedHistoryBytes int64 = api.MaxHistoryMaxBytes // DefaultMaxOrchestratorCompletionBytes leaves headroom below the modern DTS - // orchestration-completion message limit. + // 4 MiB message limit. It bounds every work item completion. DefaultMaxOrchestratorCompletionBytes = 4_089_446 minOrchestratorCompletionBytes = 64 * 1024 @@ -243,9 +243,10 @@ func WithMaxStreamedHistoryBytes(n int64) TaskHubGrpcWorkerOption { } } -// WithMaxOrchestratorCompletionBytes lowers the post-externalization response -// bound used before completing an orchestration work item. Multiple options are -// monotonic: a later option cannot raise an earlier transport-derived cap. +// WithMaxOrchestratorCompletionBytes lowers the post-externalization bound used +// before completing orchestration, activity, and entity work items. Multiple +// options are monotonic: a later option cannot raise an earlier +// transport-derived cap. func WithMaxOrchestratorCompletionBytes(n int) TaskHubGrpcWorkerOption { return func(options *taskHubGrpcWorkerOptions) error { if n < minOrchestratorCompletionBytes || n > DefaultMaxOrchestratorCompletionBytes { diff --git a/client/grpc_worker_processor.go b/client/grpc_worker_processor.go index 92675571..62e5577b 100644 --- a/client/grpc_worker_processor.go +++ b/client/grpc_worker_processor.go @@ -389,6 +389,57 @@ func failOversizedOrchestratorResponse( } } +func completionTooLargeMessage(kind string, size, maxBytes int) string { + return fmt.Sprintf( + "%s of %.2f MiB exceeds the %.2f MiB worker completion bound; configure large-payload externalization or reduce the payload size", + kind, float64(size)/(1024*1024), float64(maxBytes)/(1024*1024), + ) +} + +// failOversizedActivityResponse converts an activity response that DTS cannot +// accept into a small, non-retriable task failure. Sending it unchanged would +// fail the RPC and abandon the work item, which re-runs the activity forever. +func failOversizedActivityResponse(response *protos.ActivityResponse, maxBytes int) *protos.ActivityResponse { + if response == nil || maxBytes <= 0 { + return response + } + size := proto.Size(response) + if size <= maxBytes { + return response + } + return &protos.ActivityResponse{ + InstanceId: response.InstanceId, + TaskId: response.TaskId, + CompletionToken: response.CompletionToken, + FailureDetails: &protos.TaskFailureDetails{ + ErrorType: string(api.ErrorTypeActivityResponseTooLarge), + ErrorMessage: completionTooLargeMessage("activity response", size, maxBytes), + IsNonRetriable: true, + }, + } +} + +// failOversizedEntityResult converts an entity batch result that DTS cannot +// accept into a small, non-retriable batch failure with no partial effects. +func failOversizedEntityResult(result *protos.EntityBatchResult, maxBytes int) *protos.EntityBatchResult { + if result == nil || maxBytes <= 0 { + return result + } + size := proto.Size(result) + if size <= maxBytes { + return result + } + return &protos.EntityBatchResult{ + CompletionToken: result.CompletionToken, + CompletionCount: result.CompletionCount, + FailureDetails: &protos.TaskFailureDetails{ + ErrorType: string(api.ErrorTypeEntityResultTooLarge), + ErrorMessage: completionTooLargeMessage("entity batch result", size, maxBytes), + IsNonRetriable: true, + }, + } +} + func populateOrchestratorActionTraceContexts( actions []*protos.OrchestratorAction, pastEvents []*protos.HistoryEvent, @@ -580,6 +631,7 @@ func (w *TaskHubGrpcWorker) processActivity( return } + response = failOversizedActivityResponse(response, w.options.maxOrchestratorCompletionBytes) err = w.executeRPCWithRetry(ctx, "complete activity task", func(callCtx context.Context) error { _, callErr := client.CompleteActivityTask(callCtx, response) return callErr @@ -756,6 +808,7 @@ func (w *TaskHubGrpcWorker) completeEntityBatchResult( instanceID string, result *protos.EntityBatchResult, ) { + result = failOversizedEntityResult(result, w.options.maxOrchestratorCompletionBytes) err := w.executeRPCWithRetry(ctx, "complete entity task", func(callCtx context.Context) error { _, callErr := client.CompleteEntityTask(callCtx, result) return callErr diff --git a/client/grpc_worker_test.go b/client/grpc_worker_test.go index 6efb1ae7..4b5477e8 100644 --- a/client/grpc_worker_test.go +++ b/client/grpc_worker_test.go @@ -1869,3 +1869,50 @@ func TestFailOversizedOrchestratorResponseIdentifiesOversizedAction(t *testing.T require.Contains(t, failure.GetErrorMessage(), "action 42") require.Contains(t, failure.GetErrorMessage(), "large-payload externalization") } + +func TestFailOversizedActivityResponse(t *testing.T) { + const maxBytes = 1024 + small := &protos.ActivityResponse{InstanceId: "instance", TaskId: 7, CompletionToken: "token", Result: wrapperspb.String("ok")} + require.Same(t, small, failOversizedActivityResponse(small, maxBytes)) + + large := &protos.ActivityResponse{ + InstanceId: "instance", + TaskId: 7, + CompletionToken: "token", + Result: wrapperspb.String(strings.Repeat("x", maxBytes*2)), + } + bounded := failOversizedActivityResponse(large, maxBytes) + require.LessOrEqual(t, proto.Size(bounded), maxBytes) + require.Equal(t, "instance", bounded.GetInstanceId()) + require.Equal(t, int32(7), bounded.GetTaskId()) + require.Equal(t, "token", bounded.GetCompletionToken()) + require.Nil(t, bounded.GetResult()) + require.Equal(t, string(api.ErrorTypeActivityResponseTooLarge), bounded.GetFailureDetails().GetErrorType()) + require.True(t, bounded.GetFailureDetails().GetIsNonRetriable()) + require.Contains(t, bounded.GetFailureDetails().GetErrorMessage(), "large-payload externalization") +} + +func TestFailOversizedEntityResult(t *testing.T) { + const maxBytes = 1024 + small := &protos.EntityBatchResult{CompletionToken: "token", EntityState: wrapperspb.String("state")} + require.Same(t, small, failOversizedEntityResult(small, maxBytes)) + + large := &protos.EntityBatchResult{ + CompletionToken: "token", + CompletionCount: 3, + EntityState: wrapperspb.String(strings.Repeat("s", maxBytes*2)), + Results: []*protos.OperationResult{{ResultType: &protos.OperationResult_Success{ + Success: &protos.OperationResultSuccess{Result: wrapperspb.String("r")}, + }}}, + OperationInfos: []*protos.OperationInfo{{RequestId: "req"}}, + } + bounded := failOversizedEntityResult(large, maxBytes) + require.LessOrEqual(t, proto.Size(bounded), maxBytes) + require.Equal(t, "token", bounded.GetCompletionToken()) + require.Equal(t, int32(3), bounded.GetCompletionCount()) + require.Nil(t, bounded.GetEntityState()) + require.Empty(t, bounded.GetResults()) + require.Empty(t, bounded.GetOperationInfos()) + require.Equal(t, string(api.ErrorTypeEntityResultTooLarge), bounded.GetFailureDetails().GetErrorType()) + require.True(t, bounded.GetFailureDetails().GetIsNonRetriable()) +} diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index 574d43df..b13c89f7 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -155,13 +155,18 @@ lifecycle operations are not automatically retried: a failed acknowledgement can follow a successful service-side change. Worker channels do not use this policy, because the worker owns its own reconnect loop. -Individual gRPC messages are bounded to 64 MiB by default through -`Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`. The worker uses a -3.9 MiB safety bound below the service ceiling. When +Individual gRPC messages are bounded to 4 MiB by default through +`Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`, matching the +DTS service limit for unary calls and each message of a stream. Streamed +history is still delivered in chunks, so the total history limit is separate. +The worker uses a 3.9 MiB safety bound for every work item completion. When `Options.MaxSendMessageSize` is lower, that configured send limit becomes the -bound instead. The worker validates the final response after large-payload -externalization and fails an orchestration once -with `OrchestratorResponseTooLarge` if it still exceeds that limit. The legacy +bound instead. The worker validates the final completion after large-payload +externalization. An oversized orchestration response fails the orchestration +once with `OrchestratorResponseTooLarge`; an oversized activity response fails +the task with non-retriable `ActivityResponseTooLarge`; and an oversized entity +batch result fails the batch with `EntityResultTooLarge`. None of them are +abandoned and re-executed. The legacy `isPartial`/`chunkIndex` response fields are deprecated; the Go worker does not use them because validation against the current DTS emulator did not provide a portable chunking path. Configure large-payload storage or reduce per-turn diff --git a/durabletaskscheduler/connection_test.go b/durabletaskscheduler/connection_test.go index 0a4820df..89487ae0 100644 --- a/durabletaskscheduler/connection_test.go +++ b/durabletaskscheduler/connection_test.go @@ -577,7 +577,7 @@ func TestNewClientFailsFastWhenHelloIsRejected(t *testing.T) { require.ErrorContains(t, err, "PermissionDenied") } -func TestNewClientReceivesMessagesLargerThanGrpcDefault(t *testing.T) { +func TestNewClientAppliesConfiguredReceiveMessageSize(t *testing.T) { const payloadSize = 5 * 1024 * 1024 server := &metadataServer{ metadata: make(chan metadata.MD, 4), @@ -597,33 +597,33 @@ func TestNewClientReceivesMessagesLargerThanGrpcDefault(t *testing.T) { options.Authentication = AuthenticationNone options.AllowInsecureConnection = true options.dialer = bufconnDialer(listener) - managementClient, err := NewClient(context.Background(), options, api.DefaultLogger()) + defaultClient, err := NewClient(context.Background(), options, api.DefaultLogger()) require.NoError(t, err) defer func() { - require.NoError(t, managementClient.Close()) + require.NoError(t, defaultClient.Close()) }() - - result, err := managementClient.FetchOrchestrationMetadata( + _, err = defaultClient.FetchOrchestrationMetadata( context.Background(), "large-message", api.WithFetchPayloads(true), ) - require.NoError(t, err) - require.Len(t, result.SerializedInput, payloadSize) + require.Equal(t, codes.ResourceExhausted, status.Code(err), "default must match the 4 MiB DTS limit") - limitedOptions := *options - limitedOptions.MaxReceiveMessageSize = 1024 * 1024 - limitedClient, err := NewClient(context.Background(), &limitedOptions, api.DefaultLogger()) + raisedOptions := *options + raisedOptions.MaxReceiveMessageSize = 8 * 1024 * 1024 + managementClient, err := NewClient(context.Background(), &raisedOptions, api.DefaultLogger()) require.NoError(t, err) defer func() { - require.NoError(t, limitedClient.Close()) + require.NoError(t, managementClient.Close()) }() - _, err = limitedClient.FetchOrchestrationMetadata( + + result, err := managementClient.FetchOrchestrationMetadata( context.Background(), "large-message", api.WithFetchPayloads(true), ) - require.Equal(t, codes.ResourceExhausted, status.Code(err)) + require.NoError(t, err) + require.Len(t, result.SerializedInput, payloadSize) } func TestNewClientRecreatesChannelAndPreservesConfiguration(t *testing.T) { diff --git a/durabletaskscheduler/options.go b/durabletaskscheduler/options.go index 9ccc9ff5..7cdbf481 100644 --- a/durabletaskscheduler/options.go +++ b/durabletaskscheduler/options.go @@ -25,9 +25,10 @@ const ( GovernmentResourceID = "https://durabletask.azure.us" // DefaultMaxReceiveMessageSize and DefaultMaxSendMessageSize are the default - // per-message gRPC bounds. - DefaultMaxReceiveMessageSize = 64 * 1024 * 1024 - DefaultMaxSendMessageSize = 64 * 1024 * 1024 + // per-message gRPC bounds. They match the DTS service limit, which applies to + // unary messages and to each message of a stream. + DefaultMaxReceiveMessageSize = 4 * 1024 * 1024 + DefaultMaxSendMessageSize = 4 * 1024 * 1024 // DefaultKeepaliveTime and DefaultKeepaliveTimeout configure pings while a // gRPC stream is active. DefaultKeepaliveTime = 2 * time.Minute @@ -111,7 +112,7 @@ type Options struct { HelloTimeout time.Duration // MaxReceiveMessageSize and MaxSendMessageSize bound individual gRPC - // messages. Zero uses the 64 MiB SDK default. + // messages. Zero uses the 4 MiB SDK default, which matches the DTS service. MaxReceiveMessageSize int MaxSendMessageSize int From e0e14ca8828de0033732bf5c0e6f5acd6415e222 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 11:32:38 -0800 Subject: [PATCH 2/8] Test worker size handling end to end and clarify DTS limits Add worker-path tests for oversized activity and entity completions, with and without large-payload externalization, plus gRPC tests for the send limit and per-message stream receive limit. Correct the docs: DTS enforces 4 MiB only on messages it receives; its history chunks target about 2 MiB, and the receive default matches the .NET worker. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 2 +- client/grpc_worker_test.go | 94 +++++++++++++++++++++ durabletaskscheduler/README.md | 12 +-- durabletaskscheduler/connection_test.go | 105 +++++++++++++++++++++++- durabletaskscheduler/options.go | 4 +- 5 files changed, 208 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09e65147..03fadabf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- DTS connections now default `MaxReceiveMessageSize` and `MaxSendMessageSize` to 4 MiB, matching the DTS service limit for unary calls and each streamed message, instead of 64 MiB. Larger payloads now fail locally rather than after a service round-trip; use large-payload externalization for them. +- DTS connections now default `MaxReceiveMessageSize` and `MaxSendMessageSize` to 4 MiB instead of 64 MiB. The send limit matches the 4 MiB per-message limit DTS enforces on what it receives, and the receive limit matches the .NET worker. Both apply to each message, including each message of a stream; use large-payload externalization for larger payloads. - Activity and entity completions are now checked after large-payload externalization against the same worker completion bound as orchestration responses. Oversized results fail with non-retriable `api.ErrorTypeActivityResponseTooLarge` or `api.ErrorTypeEntityResultTooLarge` instead of being abandoned and re-executed indefinitely. - Refreshed the vendored Durable Task protobuf contract to [`2dab0e7`](https://github.com/microsoft/durabletask-protobuf/commit/2dab0e72d0dea59c5c8c412dd03204a47b9aaf2f). It adds the sidecar extended-session RPCs and messages, `completionCount` on orchestration and entity completions, and tags on entity-started orchestrations. The worker doesn't use them yet. diff --git a/client/grpc_worker_test.go b/client/grpc_worker_test.go index 4b5477e8..a7685255 100644 --- a/client/grpc_worker_test.go +++ b/client/grpc_worker_test.go @@ -3,6 +3,7 @@ package client import ( "context" "errors" + "fmt" "io" "strings" "sync" @@ -1916,3 +1917,96 @@ func TestFailOversizedEntityResult(t *testing.T) { require.Equal(t, string(api.ErrorTypeEntityResultTooLarge), bounded.GetFailureDetails().GetErrorType()) require.True(t, bounded.GetFailureDetails().GetIsNonRetriable()) } + +func TestWorkerOversizedActivityCompletion(t *testing.T) { + const limit = minOrchestratorCompletionBytes + value := strings.Repeat("x", 2*limit) + for _, externalize := range []bool{false, true} { + t.Run(fmt.Sprintf("externalize=%t", externalize), func(t *testing.T) { + client := new(fakeSchedulerClient) + opts := []TaskHubGrpcWorkerOption{WithMaxOrchestratorCompletionBytes(limit)} + var payloadOptions *api.LargePayloadOptions + if externalize { + store := payload.NewMemoryStore() + payloadOptions = &api.LargePayloadOptions{Store: store, Resolver: store, ThresholdBytes: 1024} + opts = append(opts, WithWorkerLargePayloads(payloadOptions)) + } + worker := newFakeWorker(t, client, opts...) + worker.executor = &recordingExecutor{ + executeActivity: func(context.Context, api.InstanceID, *protos.HistoryEvent) (*protos.HistoryEvent, error) { + return &protos.HistoryEvent{EventType: &protos.HistoryEvent_TaskCompleted{ + TaskCompleted: &protos.TaskCompletedEvent{Result: wrapperspb.String(value)}, + }}, nil + }, + } + worker.processActivity(context.Background(), client, "token", &protos.ActivityRequest{ + Name: "activity", TaskId: 7, + OrchestrationInstance: &protos.OrchestrationInstance{InstanceId: "instance"}, + }) + + require.Zero(t, client.activityAbandons) + require.Len(t, client.activityCompletions, 1) + completion := client.activityCompletions[0] + require.LessOrEqual(t, proto.Size(completion), limit) + require.Equal(t, "token", completion.CompletionToken) + if externalize { + require.Nil(t, completion.FailureDetails) + hydrated, err := largepayload.Hydrate(context.Background(), payloadOptions, completion.Result) + require.NoError(t, err) + require.Equal(t, value, hydrated.GetValue()) + } else { + require.Nil(t, completion.Result) + require.Equal(t, string(api.ErrorTypeActivityResponseTooLarge), completion.GetFailureDetails().GetErrorType()) + require.True(t, completion.GetFailureDetails().GetIsNonRetriable()) + } + }) + } +} + +func TestWorkerOversizedEntityCompletion(t *testing.T) { + const limit = minOrchestratorCompletionBytes + value := strings.Repeat("x", 2*limit) + for _, externalize := range []bool{false, true} { + t.Run(fmt.Sprintf("externalize=%t", externalize), func(t *testing.T) { + client := new(fakeSchedulerClient) + opts := []TaskHubGrpcWorkerOption{WithMaxOrchestratorCompletionBytes(limit)} + var payloadOptions *api.LargePayloadOptions + if externalize { + store := payload.NewMemoryStore() + payloadOptions = &api.LargePayloadOptions{Store: store, Resolver: store, ThresholdBytes: 1024} + opts = append(opts, WithWorkerLargePayloads(payloadOptions)) + } + worker := newFakeWorker(t, client, opts...) + worker.executor = &recordingExecutor{ + executeEntity: func(context.Context, *protos.EntityBatchRequest) (*protos.EntityBatchResult, error) { + return &protos.EntityBatchResult{ + EntityState: wrapperspb.String(value), + Results: []*protos.OperationResult{{ResultType: &protos.OperationResult_Success{ + Success: &protos.OperationResultSuccess{Result: wrapperspb.String("ok")}, + }}}, + }, nil + }, + } + worker.processEntityV2(context.Background(), client, "token", newFakeEntitySignalRequest("set", nil)) + + require.Zero(t, client.entityAbandonAttempts) + require.Len(t, client.entityCompletions, 1) + completion := client.entityCompletions[0] + require.LessOrEqual(t, proto.Size(completion), limit) + require.Equal(t, "token", completion.CompletionToken) + if externalize { + require.Nil(t, completion.FailureDetails) + require.Len(t, completion.OperationInfos, 1) + hydrated, err := largepayload.Hydrate(context.Background(), payloadOptions, completion.EntityState) + require.NoError(t, err) + require.Equal(t, value, hydrated.GetValue()) + } else { + require.Nil(t, completion.EntityState) + require.Empty(t, completion.Results) + require.Empty(t, completion.OperationInfos) + require.Equal(t, string(api.ErrorTypeEntityResultTooLarge), completion.GetFailureDetails().GetErrorType()) + require.True(t, completion.GetFailureDetails().GetIsNonRetriable()) + } + }) + } +} diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index b13c89f7..298daca9 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -156,17 +156,19 @@ can follow a successful service-side change. Worker channels do not use this policy, because the worker owns its own reconnect loop. Individual gRPC messages are bounded to 4 MiB by default through -`Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`, matching the -DTS service limit for unary calls and each message of a stream. Streamed -history is still delivered in chunks, so the total history limit is separate. +`Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`. DTS rejects +incoming messages over 4 MiB, so a larger send limit only moves the failure to +the service. DTS streams history in chunks of about 2 MiB, so the 4 MiB receive +limit leaves headroom. These limits apply to each message, including each +message of a stream; the total streamed history limit is separate. The worker uses a 3.9 MiB safety bound for every work item completion. When `Options.MaxSendMessageSize` is lower, that configured send limit becomes the bound instead. The worker validates the final completion after large-payload externalization. An oversized orchestration response fails the orchestration once with `OrchestratorResponseTooLarge`; an oversized activity response fails the task with non-retriable `ActivityResponseTooLarge`; and an oversized entity -batch result fails the batch with `EntityResultTooLarge`. None of them are -abandoned and re-executed. The legacy +batch result fails the batch with `EntityResultTooLarge`. The worker sends a +small failure completion instead of abandoning the oversized result. The legacy `isPartial`/`chunkIndex` response fields are deprecated; the Go worker does not use them because validation against the current DTS emulator did not provide a portable chunking path. Configure large-payload storage or reduce per-turn diff --git a/durabletaskscheduler/connection_test.go b/durabletaskscheduler/connection_test.go index 89487ae0..861145e1 100644 --- a/durabletaskscheduler/connection_test.go +++ b/durabletaskscheduler/connection_test.go @@ -3,6 +3,7 @@ package durabletaskscheduler import ( "context" "errors" + "fmt" "net" "strings" "sync" @@ -25,6 +26,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" @@ -132,6 +134,27 @@ type metadataServer struct { state *protos.OrchestrationState } +type messageSizeHistoryServer struct { + protos.UnimplementedTaskHubSidecarServiceServer +} + +func (*messageSizeHistoryServer) StreamInstanceHistory( + _ *protos.StreamInstanceHistoryRequest, + stream protos.TaskHubSidecarService_StreamInstanceHistoryServer, +) error { + for _, size := range []int{2 << 20, 2 << 20, 2 << 20, 4 << 20} { + err := stream.Send(&protos.HistoryChunk{Events: []*protos.HistoryEvent{{ + EventType: &protos.HistoryEvent_GenericEvent{GenericEvent: &protos.GenericEvent{ + Data: wrapperspb.String(strings.Repeat("x", size)), + }}, + }}}) + if err != nil { + return err + } + } + return nil +} + func (s *metadataServer) GetInstance( ctx context.Context, _ *protos.GetInstanceRequest, @@ -607,7 +630,7 @@ func TestNewClientAppliesConfiguredReceiveMessageSize(t *testing.T) { "large-message", api.WithFetchPayloads(true), ) - require.Equal(t, codes.ResourceExhausted, status.Code(err), "default must match the 4 MiB DTS limit") + require.Equal(t, codes.ResourceExhausted, status.Code(err), "default receive limit must be 4 MiB") raisedOptions := *options raisedOptions.MaxReceiveMessageSize = 8 * 1024 * 1024 @@ -626,6 +649,86 @@ func TestNewClientAppliesConfiguredReceiveMessageSize(t *testing.T) { require.Len(t, result.SerializedInput, payloadSize) } +func TestConnectionAppliesConfiguredSendMessageSize(t *testing.T) { + const limit = 4 * 1024 * 1024 + listener := bufconn.Listen(1024 * 1024) + server := grpc.NewServer(grpc.MaxRecvMsgSize(8 * 1024 * 1024)) + protos.RegisterTaskHubSidecarServiceServer(server, &metadataServer{metadata: make(chan metadata.MD, 4)}) + go func() { _ = server.Serve(listener) }() + defer func() { + server.Stop() + require.NoError(t, listener.Close()) + }() + + options := NewOptions("http://bufconn", "default") + options.Authentication = AuthenticationNone + options.AllowInsecureConnection = true + options.dialer = bufconnDialer(listener) + prepared, err := prepareOptions(options) + require.NoError(t, err) + conn, err := connect(&prepared, clientRole, "") + require.NoError(t, err) + defer conn.Close() + + request := &protos.GetInstanceRequest{InstanceId: strings.Repeat("x", limit-5)} + require.Equal(t, limit, proto.Size(request)) + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + _, err = protos.NewTaskHubSidecarServiceClient(conn).GetInstance(ctx, request) + require.NoError(t, err) + + request.InstanceId += "x" + require.Equal(t, limit+1, proto.Size(request)) + _, err = protos.NewTaskHubSidecarServiceClient(conn).GetInstance(ctx, request) + require.Equal(t, codes.ResourceExhausted, status.Code(err)) + + prepared.MaxSendMessageSize = 8 * 1024 * 1024 + raised, err := connect(&prepared, clientRole, "") + require.NoError(t, err) + defer raised.Close() + _, err = protos.NewTaskHubSidecarServiceClient(raised).GetInstance(ctx, request) + require.NoError(t, err) +} + +func TestConnectionReceiveLimitAppliesPerStreamMessage(t *testing.T) { + listener, stop := startBufconnServer(t, &messageSizeHistoryServer{}) + defer stop() + options := NewOptions("http://bufconn", "default") + options.Authentication = AuthenticationNone + options.AllowInsecureConnection = true + options.dialer = bufconnDialer(listener) + prepared, err := prepareOptions(options) + require.NoError(t, err) + + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + for _, raised := range []bool{false, true} { + t.Run(fmt.Sprintf("raised=%t", raised), func(t *testing.T) { + streamOptions := prepared + if raised { + streamOptions.MaxReceiveMessageSize = 8 * 1024 * 1024 + } + conn, err := connect(&streamOptions, clientRole, "") + require.NoError(t, err) + defer conn.Close() + stream, err := protos.NewTaskHubSidecarServiceClient(conn).StreamInstanceHistory(ctx, &protos.StreamInstanceHistoryRequest{}) + require.NoError(t, err) + for range 3 { + chunk, err := stream.Recv() + require.NoError(t, err) + require.Len(t, chunk.GetEvents()[0].GetGenericEvent().GetData().GetValue(), 2<<20) + } + chunk, err := stream.Recv() + if raised { + require.NoError(t, err) + require.Len(t, chunk.GetEvents()[0].GetGenericEvent().GetData().GetValue(), 4<<20) + } else { + require.Equal(t, codes.ResourceExhausted, status.Code(err)) + } + }) + } +} + func TestNewClientRecreatesChannelAndPreservesConfiguration(t *testing.T) { firstServer := &metadataServer{ getErr: status.Error(codes.Unavailable, "replace this channel"), diff --git a/durabletaskscheduler/options.go b/durabletaskscheduler/options.go index 7cdbf481..43456d18 100644 --- a/durabletaskscheduler/options.go +++ b/durabletaskscheduler/options.go @@ -25,8 +25,8 @@ const ( GovernmentResourceID = "https://durabletask.azure.us" // DefaultMaxReceiveMessageSize and DefaultMaxSendMessageSize are the default - // per-message gRPC bounds. They match the DTS service limit, which applies to - // unary messages and to each message of a stream. + // per-message gRPC bounds, including each message of a stream. DTS rejects + // incoming messages over 4 MiB. DefaultMaxReceiveMessageSize = 4 * 1024 * 1024 DefaultMaxSendMessageSize = 4 * 1024 * 1024 // DefaultKeepaliveTime and DefaultKeepaliveTimeout configure pings while a From 4879a5902fa3595bcd2efc57d6236643ce0f25e5 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 11:34:11 -0800 Subject: [PATCH 3/8] Document the soft DTS history chunk target Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- durabletaskscheduler/README.md | 7 +++++-- durabletaskscheduler/options.go | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index 298daca9..de88a3bf 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -159,8 +159,11 @@ Individual gRPC messages are bounded to 4 MiB by default through `Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`. DTS rejects incoming messages over 4 MiB, so a larger send limit only moves the failure to the service. DTS streams history in chunks of about 2 MiB, so the 4 MiB receive -limit leaves headroom. These limits apply to each message, including each -message of a stream; the total streamed history limit is separate. +limit leaves headroom. That chunk size is a soft target: a single history event +larger than it is sent alone, so raise `Options.MaxReceiveMessageSize` if +individual events can exceed 4 MiB. These limits apply to each message, +including each message of a stream; the total streamed history limit is +separate. The worker uses a 3.9 MiB safety bound for every work item completion. When `Options.MaxSendMessageSize` is lower, that configured send limit becomes the bound instead. The worker validates the final completion after large-payload diff --git a/durabletaskscheduler/options.go b/durabletaskscheduler/options.go index 43456d18..a12ec196 100644 --- a/durabletaskscheduler/options.go +++ b/durabletaskscheduler/options.go @@ -112,7 +112,8 @@ type Options struct { HelloTimeout time.Duration // MaxReceiveMessageSize and MaxSendMessageSize bound individual gRPC - // messages. Zero uses the 4 MiB SDK default, which matches the DTS service. + // messages. Zero uses the 4 MiB SDK default. DTS rejects incoming messages + // over 4 MiB, so raising MaxSendMessageSize does not help. MaxReceiveMessageSize int MaxSendMessageSize int From fc9c04cbee561be402a65256b4b7a73ff745ce2b Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 11:35:25 -0800 Subject: [PATCH 4/8] Document that DTS keeps each message within 4 MiB DTS keeps every message it sends, including history chunks, within the default 4 MiB gRPC limit; drop the advice to raise MaxReceiveMessageSize. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- durabletaskscheduler/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index de88a3bf..63485d70 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -158,10 +158,8 @@ policy, because the worker owns its own reconnect loop. Individual gRPC messages are bounded to 4 MiB by default through `Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`. DTS rejects incoming messages over 4 MiB, so a larger send limit only moves the failure to -the service. DTS streams history in chunks of about 2 MiB, so the 4 MiB receive -limit leaves headroom. That chunk size is a soft target: a single history event -larger than it is sent alone, so raise `Options.MaxReceiveMessageSize` if -individual events can exceed 4 MiB. These limits apply to each message, +the service. DTS keeps each message it sends within the default 4 MiB gRPC +limit, including each history chunk. These limits apply to each message, including each message of a stream; the total streamed history limit is separate. The worker uses a 3.9 MiB safety bound for every work item completion. When From 4fbd15b299f3835fbf350300b246deb12f064690 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 11:36:16 -0800 Subject: [PATCH 5/8] State the DTS 4 MiB send bound as an expectation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- durabletaskscheduler/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index 63485d70..9679ca78 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -158,10 +158,12 @@ policy, because the worker owns its own reconnect loop. Individual gRPC messages are bounded to 4 MiB by default through `Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`. DTS rejects incoming messages over 4 MiB, so a larger send limit only moves the failure to -the service. DTS keeps each message it sends within the default 4 MiB gRPC -limit, including each history chunk. These limits apply to each message, -including each message of a stream; the total streamed history limit is -separate. +the service. DTS is expected to keep each message it sends, including each +history chunk, within the default 4 MiB gRPC limit that most clients use. The +SDK does not raise the receive default to tolerate larger messages; a message +over the limit fails with `ResourceExhausted`. These limits apply to each +message, including each message of a stream; the total streamed history limit +is separate. The worker uses a 3.9 MiB safety bound for every work item completion. When `Options.MaxSendMessageSize` is lower, that configured send limit becomes the bound instead. The worker validates the final completion after large-payload From d73873658a2aca63532c93620c9b1de3f72210d7 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 13:24:56 -0800 Subject: [PATCH 6/8] Defer DTS transport send limits to the server Restore the 64 MiB receive default and leave the transport send limit unset unless explicitly configured. Retain the worker completion safety cap and cover default, explicit, and server-enforced message limits. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 3 +- durabletaskscheduler/README.md | 31 ++++---- durabletaskscheduler/connection.go | 9 ++- durabletaskscheduler/connection_test.go | 98 ++++++++++++++----------- durabletaskscheduler/options.go | 21 +++--- durabletaskscheduler/worker.go | 9 ++- 6 files changed, 96 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03fadabf..6f1446f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- DTS connections now default `MaxReceiveMessageSize` and `MaxSendMessageSize` to 4 MiB instead of 64 MiB. The send limit matches the 4 MiB per-message limit DTS enforces on what it receives, and the receive limit matches the .NET worker. Both apply to each message, including each message of a stream; use large-payload externalization for larger payloads. - Activity and entity completions are now checked after large-payload externalization against the same worker completion bound as orchestration responses. Oversized results fail with non-retriable `api.ErrorTypeActivityResponseTooLarge` or `api.ErrorTypeEntityResultTooLarge` instead of being abandoned and re-executed indefinitely. - Refreshed the vendored Durable Task protobuf contract to [`2dab0e7`](https://github.com/microsoft/durabletask-protobuf/commit/2dab0e72d0dea59c5c8c412dd03204a47b9aaf2f). It adds the sidecar extended-session RPCs and messages, `completionCount` on orchestration and entity completions, and tags on entity-started orchestrations. The worker doesn't use them yet. @@ -104,7 +103,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Worker completion and abandon RPCs no longer retry `NotFound` responses ten times. A completion whose work item is already unavailable is dropped for normal DTS redelivery without a second, guaranteed-failing abandon RPC. - The gRPC worker no longer deep-clones freshly owned orchestrator and entity executor results before adding transport fields and externalizing payloads. - Streamed orchestration histories are now bounded before retention to 100,000 events and 64 MiB by default, with configurable limits up to the public history maxima. -- DTS connections now apply explicit 64 MiB send/receive message limits and active-stream keepalive settings. Local message-size failures are non-retryable instead of entering a reconnect loop. +- DTS connections use a 64 MiB receive limit for unary responses and individual stream chunks, with active-stream keepalive settings. `MaxSendMessageSize` defaults to zero, leaving outgoing message-size enforcement to the server and the gRPC-Go transport's own default maximum; positive values opt into a client-side send limit. The separate 3.9 MiB worker completion safety bound remains in place. Local message-size failures are non-retryable instead of entering a reconnect loop. - gRPC worker reconnect delays now use bounded jitter to prevent synchronized reconnect storms while always remaining inside the configured `[baseDelay, maxDelay]` interval. Exponential growth still saturates instead of overflowing for very large configured maximums. - A work item that the service delivers concurrently with the gRPC worker's silent-disconnect timeout is now processed instead of dropped. Previously the racing message was discarded without being abandoned, so the service considered it dispatched and it could only be redelivered after its lock expired. - `client.WithMaxConcurrentOrchestrationWorkItems`, `WithMaxConcurrentActivityWorkItems`, and `WithMaxConcurrentEntityWorkItems` now reject limits above `math.MaxInt32`. Previously such a limit silently wrapped to a negative value in the 32-bit `GetWorkItems` fields advertised to the service. diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index 9679ca78..1044e9d0 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -155,22 +155,23 @@ lifecycle operations are not automatically retried: a failed acknowledgement can follow a successful service-side change. Worker channels do not use this policy, because the worker owns its own reconnect loop. -Individual gRPC messages are bounded to 4 MiB by default through -`Options.MaxReceiveMessageSize` and `Options.MaxSendMessageSize`. DTS rejects -incoming messages over 4 MiB, so a larger send limit only moves the failure to -the service. DTS is expected to keep each message it sends, including each -history chunk, within the default 4 MiB gRPC limit that most clients use. The -SDK does not raise the receive default to tolerate larger messages; a message -over the limit fails with `ResourceExhausted`. These limits apply to each -message, including each message of a stream; the total streamed history limit -is separate. -The worker uses a 3.9 MiB safety bound for every work item completion. When +Incoming gRPC messages are bounded to 64 MiB by default through +`Options.MaxReceiveMessageSize`, providing generous headroom for unary responses +and individual stream chunks. The limit applies to each message, not the total +stream; the total streamed history limit is separate. By default, +`Options.MaxSendMessageSize` is zero and the SDK does not set a transport send +limit, leaving message-size enforcement to the server. The gRPC-Go transport's +own default maximum (approximately 2 GiB) still applies. A positive +`Options.MaxSendMessageSize` opts into an explicit client-side send limit. + +The worker retains a separate 3.9 MiB safety bound for every work item +completion, regardless of the default transport send behavior. When a positive `Options.MaxSendMessageSize` is lower, that configured send limit becomes the -bound instead. The worker validates the final completion after large-payload -externalization. An oversized orchestration response fails the orchestration -once with `OrchestratorResponseTooLarge`; an oversized activity response fails -the task with non-retriable `ActivityResponseTooLarge`; and an oversized entity -batch result fails the batch with `EntityResultTooLarge`. The worker sends a +completion bound instead. The worker validates the final completion after +large-payload externalization. An oversized orchestration response fails the +orchestration once with `OrchestratorResponseTooLarge`; an oversized activity +response fails the task with non-retriable `ActivityResponseTooLarge`; and an +oversized entity batch result fails the batch with `EntityResultTooLarge`. The worker sends a small failure completion instead of abandoning the oversized result. The legacy `isPartial`/`chunkIndex` response fields are deprecated; the Go worker does not use them because validation against the current DTS emulator did not provide a diff --git a/durabletaskscheduler/connection.go b/durabletaskscheduler/connection.go index 96039be6..28939860 100644 --- a/durabletaskscheduler/connection.go +++ b/durabletaskscheduler/connection.go @@ -444,9 +444,6 @@ func prepareOptionsWith(options *Options, factory credentialFactory) (Options, e if prepared.MaxReceiveMessageSize == 0 { prepared.MaxReceiveMessageSize = DefaultMaxReceiveMessageSize } - if prepared.MaxSendMessageSize == 0 { - prepared.MaxSendMessageSize = DefaultMaxSendMessageSize - } if prepared.KeepaliveTime > 0 && prepared.KeepaliveTimeout == 0 { prepared.KeepaliveTimeout = DefaultKeepaliveTimeout } @@ -520,9 +517,13 @@ func connect( grpc.WithPerRPCCredentials(newPerRPCCredentials(options, role, workerID)), grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(options.MaxReceiveMessageSize), - grpc.MaxCallSendMsgSize(options.MaxSendMessageSize), ), } + if options.MaxSendMessageSize > 0 { + dialOptions = append(dialOptions, grpc.WithDefaultCallOptions( + grpc.MaxCallSendMsgSize(options.MaxSendMessageSize), + )) + } if options.KeepaliveTime > 0 { dialOptions = append(dialOptions, grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: options.KeepaliveTime, diff --git a/durabletaskscheduler/connection_test.go b/durabletaskscheduler/connection_test.go index 861145e1..739d1a4f 100644 --- a/durabletaskscheduler/connection_test.go +++ b/durabletaskscheduler/connection_test.go @@ -625,28 +625,28 @@ func TestNewClientAppliesConfiguredReceiveMessageSize(t *testing.T) { defer func() { require.NoError(t, defaultClient.Close()) }() - _, err = defaultClient.FetchOrchestrationMetadata( + result, err := defaultClient.FetchOrchestrationMetadata( context.Background(), "large-message", api.WithFetchPayloads(true), ) - require.Equal(t, codes.ResourceExhausted, status.Code(err), "default receive limit must be 4 MiB") + require.NoError(t, err) + require.Len(t, result.SerializedInput, payloadSize) - raisedOptions := *options - raisedOptions.MaxReceiveMessageSize = 8 * 1024 * 1024 - managementClient, err := NewClient(context.Background(), &raisedOptions, api.DefaultLogger()) + limitedOptions := *options + limitedOptions.MaxReceiveMessageSize = 4 * 1024 * 1024 + limitedClient, err := NewClient(context.Background(), &limitedOptions, api.DefaultLogger()) require.NoError(t, err) defer func() { - require.NoError(t, managementClient.Close()) + require.NoError(t, limitedClient.Close()) }() - result, err := managementClient.FetchOrchestrationMetadata( + _, err = limitedClient.FetchOrchestrationMetadata( context.Background(), "large-message", api.WithFetchPayloads(true), ) - require.NoError(t, err) - require.Len(t, result.SerializedInput, payloadSize) + require.Equal(t, codes.ResourceExhausted, status.Code(err)) } func TestConnectionAppliesConfiguredSendMessageSize(t *testing.T) { @@ -660,34 +660,50 @@ func TestConnectionAppliesConfiguredSendMessageSize(t *testing.T) { require.NoError(t, listener.Close()) }() - options := NewOptions("http://bufconn", "default") - options.Authentication = AuthenticationNone - options.AllowInsecureConnection = true - options.dialer = bufconnDialer(listener) - prepared, err := prepareOptions(options) - require.NoError(t, err) - conn, err := connect(&prepared, clientRole, "") - require.NoError(t, err) - defer conn.Close() - - request := &protos.GetInstanceRequest{InstanceId: strings.Repeat("x", limit-5)} - require.Equal(t, limit, proto.Size(request)) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() - _, err = protos.NewTaskHubSidecarServiceClient(conn).GetInstance(ctx, request) - require.NoError(t, err) - - request.InstanceId += "x" - require.Equal(t, limit+1, proto.Size(request)) - _, err = protos.NewTaskHubSidecarServiceClient(conn).GetInstance(ctx, request) - require.Equal(t, codes.ResourceExhausted, status.Code(err)) + for _, testCase := range []struct { + name string + sendLimit int + messageBytes int + wantCode codes.Code + }{ + {"default leaves send limit unset", 0, limit + 1, codes.OK}, + {"explicit limit accepts boundary", limit, limit, codes.OK}, + {"explicit limit rejects oversized message", limit, limit + 1, codes.ResourceExhausted}, + {"raised explicit limit", 2 * limit, limit + 1, codes.OK}, + {"server enforces its receive limit", 0, 2*limit + 1, codes.ResourceExhausted}, + } { + t.Run(testCase.name, func(t *testing.T) { + options := NewOptions("http://bufconn", "default") + options.Authentication = AuthenticationNone + options.AllowInsecureConnection = true + options.MaxSendMessageSize = testCase.sendLimit + options.dialer = bufconnDialer(listener) + var sendLimitSet bool + options.UnaryInterceptors = []grpc.UnaryClientInterceptor{ + func(ctx context.Context, method string, request, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, callOptions ...grpc.CallOption) error { + for _, option := range callOptions { + if _, ok := option.(grpc.MaxSendMsgSizeCallOption); ok { + sendLimitSet = true + } + } + return invoker(ctx, method, request, reply, cc, callOptions...) + }, + } + prepared, err := prepareOptions(options) + require.NoError(t, err) + conn, err := connect(&prepared, clientRole, "") + require.NoError(t, err) + defer conn.Close() - prepared.MaxSendMessageSize = 8 * 1024 * 1024 - raised, err := connect(&prepared, clientRole, "") - require.NoError(t, err) - defer raised.Close() - _, err = protos.NewTaskHubSidecarServiceClient(raised).GetInstance(ctx, request) - require.NoError(t, err) + request := &protos.GetInstanceRequest{InstanceId: strings.Repeat("x", testCase.messageBytes-5)} + require.Equal(t, testCase.messageBytes, proto.Size(request)) + _, err = protos.NewTaskHubSidecarServiceClient(conn).GetInstance(ctx, request) + require.Equal(t, testCase.wantCode, status.Code(err)) + require.Equal(t, testCase.sendLimit > 0, sendLimitSet) + }) + } } func TestConnectionReceiveLimitAppliesPerStreamMessage(t *testing.T) { @@ -702,11 +718,11 @@ func TestConnectionReceiveLimitAppliesPerStreamMessage(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() - for _, raised := range []bool{false, true} { - t.Run(fmt.Sprintf("raised=%t", raised), func(t *testing.T) { + for _, limited := range []bool{false, true} { + t.Run(fmt.Sprintf("limited=%t", limited), func(t *testing.T) { streamOptions := prepared - if raised { - streamOptions.MaxReceiveMessageSize = 8 * 1024 * 1024 + if limited { + streamOptions.MaxReceiveMessageSize = 4 * 1024 * 1024 } conn, err := connect(&streamOptions, clientRole, "") require.NoError(t, err) @@ -719,11 +735,11 @@ func TestConnectionReceiveLimitAppliesPerStreamMessage(t *testing.T) { require.Len(t, chunk.GetEvents()[0].GetGenericEvent().GetData().GetValue(), 2<<20) } chunk, err := stream.Recv() - if raised { + if limited { + require.Equal(t, codes.ResourceExhausted, status.Code(err)) + } else { require.NoError(t, err) require.Len(t, chunk.GetEvents()[0].GetGenericEvent().GetData().GetValue(), 4<<20) - } else { - require.Equal(t, codes.ResourceExhausted, status.Code(err)) } }) } diff --git a/durabletaskscheduler/options.go b/durabletaskscheduler/options.go index a12ec196..62141e5f 100644 --- a/durabletaskscheduler/options.go +++ b/durabletaskscheduler/options.go @@ -24,11 +24,11 @@ const ( // GovernmentResourceID is the token audience for DTS in US Government and DoD regions. GovernmentResourceID = "https://durabletask.azure.us" - // DefaultMaxReceiveMessageSize and DefaultMaxSendMessageSize are the default - // per-message gRPC bounds, including each message of a stream. DTS rejects - // incoming messages over 4 MiB. - DefaultMaxReceiveMessageSize = 4 * 1024 * 1024 - DefaultMaxSendMessageSize = 4 * 1024 * 1024 + // DefaultMaxReceiveMessageSize provides headroom for unary responses and + // individual messages of a stream. + DefaultMaxReceiveMessageSize = 64 * 1024 * 1024 + // DefaultMaxSendMessageSize leaves the gRPC send limit unset. + DefaultMaxSendMessageSize = 0 // DefaultKeepaliveTime and DefaultKeepaliveTimeout configure pings while a // gRPC stream is active. DefaultKeepaliveTime = 2 * time.Minute @@ -111,11 +111,14 @@ type Options struct { // HelloTimeout controls fail-fast connectivity checks. HelloTimeout time.Duration - // MaxReceiveMessageSize and MaxSendMessageSize bound individual gRPC - // messages. Zero uses the 4 MiB SDK default. DTS rejects incoming messages - // over 4 MiB, so raising MaxSendMessageSize does not help. + // MaxReceiveMessageSize bounds individual unary responses and streamed + // messages. Zero uses the 64 MiB SDK default. MaxReceiveMessageSize int - MaxSendMessageSize int + + // MaxSendMessageSize optionally bounds individual outgoing gRPC messages. + // Zero leaves the gRPC send limit unset, allowing the server to enforce its + // receive limit. The gRPC-Go transport's own default maximum still applies. + MaxSendMessageSize int // KeepaliveTime controls client pings while a gRPC stream is active. Zero // disables keepalive, in which case KeepaliveTimeout is ignored. diff --git a/durabletaskscheduler/worker.go b/durabletaskscheduler/worker.go index 0889b0b2..21709515 100644 --- a/durabletaskscheduler/worker.go +++ b/durabletaskscheduler/worker.go @@ -34,14 +34,15 @@ func NewWorker( } return connection, connection, nil } + completionLimit := durabletaskclient.DefaultMaxOrchestratorCompletionBytes + if prepared.MaxSendMessageSize > 0 { + completionLimit = min(completionLimit, prepared.MaxSendMessageSize) + } configuredOptions := []durabletaskclient.TaskHubGrpcWorkerOption{ durabletaskclient.WithWorkerHelloTimeout(prepared.HelloTimeout), durabletaskclient.WithWorkerDataConverter(prepared.DataConverter), durabletaskclient.WithMaximumTimerInterval(prepared.MaximumTimerInterval), - durabletaskclient.WithMaxOrchestratorCompletionBytes(min( - prepared.MaxSendMessageSize, - durabletaskclient.DefaultMaxOrchestratorCompletionBytes, - )), + durabletaskclient.WithMaxOrchestratorCompletionBytes(completionLimit), } if prepared.LargePayloads != nil { configuredOptions = append( From 53d34fb8eb6d1bbe8364c2e2ec969e83d86736e6 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 13:32:44 -0800 Subject: [PATCH 7/8] Scope PR to unlimited send limit; drop activity/entity completion checks Match the .NET SDK, which only bounds orchestration responses. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 4 +- api/failure.go | 2 - client/grpc_worker.go | 9 +- client/grpc_worker_processor.go | 53 ------------ client/grpc_worker_test.go | 141 -------------------------------- durabletaskscheduler/README.md | 13 ++- 6 files changed, 10 insertions(+), 212 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f1446f2..3f2011d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Activity and entity completions are now checked after large-payload externalization against the same worker completion bound as orchestration responses. Oversized results fail with non-retriable `api.ErrorTypeActivityResponseTooLarge` or `api.ErrorTypeEntityResultTooLarge` instead of being abandoned and re-executed indefinitely. - - Refreshed the vendored Durable Task protobuf contract to [`2dab0e7`](https://github.com/microsoft/durabletask-protobuf/commit/2dab0e72d0dea59c5c8c412dd03204a47b9aaf2f). It adds the sidecar extended-session RPCs and messages, `completionCount` on orchestration and entity completions, and tags on entity-started orchestrations. The worker doesn't use them yet. - Azure Blob payload reads use independent `AllowAllContainersInConfiguredAccount` and `AdditionalAccountURLs` options, with endpoint-and-container defaults shared by native token and generic location reads. Additional accounts require identity authentication and exact service endpoints. V2 token queries and fragments are ignored when resolving existing references; new v2 tokens remain credential-free, and v1 reads remain supported. @@ -103,7 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Worker completion and abandon RPCs no longer retry `NotFound` responses ten times. A completion whose work item is already unavailable is dropped for normal DTS redelivery without a second, guaranteed-failing abandon RPC. - The gRPC worker no longer deep-clones freshly owned orchestrator and entity executor results before adding transport fields and externalizing payloads. - Streamed orchestration histories are now bounded before retention to 100,000 events and 64 MiB by default, with configurable limits up to the public history maxima. -- DTS connections use a 64 MiB receive limit for unary responses and individual stream chunks, with active-stream keepalive settings. `MaxSendMessageSize` defaults to zero, leaving outgoing message-size enforcement to the server and the gRPC-Go transport's own default maximum; positive values opt into a client-side send limit. The separate 3.9 MiB worker completion safety bound remains in place. Local message-size failures are non-retryable instead of entering a reconnect loop. +- DTS connections use a 64 MiB receive limit for unary responses and individual stream chunks, with active-stream keepalive settings. `MaxSendMessageSize` defaults to zero, leaving outgoing message-size enforcement to the server and the gRPC-Go transport's own default maximum; positive values opt into a client-side send limit. The separate 3.9 MiB orchestration-response safety bound remains in place. Local message-size failures are non-retryable instead of entering a reconnect loop. - gRPC worker reconnect delays now use bounded jitter to prevent synchronized reconnect storms while always remaining inside the configured `[baseDelay, maxDelay]` interval. Exponential growth still saturates instead of overflowing for very large configured maximums. - A work item that the service delivers concurrently with the gRPC worker's silent-disconnect timeout is now processed instead of dropped. Previously the racing message was discarded without being abandoned, so the service considered it dispatched and it could only be redelivered after its lock expired. - `client.WithMaxConcurrentOrchestrationWorkItems`, `WithMaxConcurrentActivityWorkItems`, and `WithMaxConcurrentEntityWorkItems` now reject limits above `math.MaxInt32`. Previously such a limit silently wrapped to a negative value in the 32-bit `GetWorkItems` fields advertised to the service. diff --git a/api/failure.go b/api/failure.go index 1938f0b5..482ba0f6 100644 --- a/api/failure.go +++ b/api/failure.go @@ -19,8 +19,6 @@ const ( ErrorTypeVersionError ErrorType = "VersionError" ErrorTypeHistoryLimitExceeded ErrorType = "HistoryLimitExceeded" ErrorTypeOrchestratorResponseTooLarge ErrorType = "OrchestratorResponseTooLarge" - ErrorTypeActivityResponseTooLarge ErrorType = "ActivityResponseTooLarge" - ErrorTypeEntityResultTooLarge ErrorType = "EntityResultTooLarge" ErrorTypeActivityPanic ErrorType = "TaskActivityPanic" ErrorTypeEntityOperationPanic ErrorType = "EntityOperationPanic" ErrorTypeOrchestratorPanic ErrorType = "OrchestratorPanic" diff --git a/client/grpc_worker.go b/client/grpc_worker.go index 6ee1b8cb..ea367103 100644 --- a/client/grpc_worker.go +++ b/client/grpc_worker.go @@ -65,7 +65,7 @@ const ( MaxStreamedHistoryBytes int64 = api.MaxHistoryMaxBytes // DefaultMaxOrchestratorCompletionBytes leaves headroom below the modern DTS - // 4 MiB message limit. It bounds every work item completion. + // orchestration-completion message limit. DefaultMaxOrchestratorCompletionBytes = 4_089_446 minOrchestratorCompletionBytes = 64 * 1024 @@ -243,10 +243,9 @@ func WithMaxStreamedHistoryBytes(n int64) TaskHubGrpcWorkerOption { } } -// WithMaxOrchestratorCompletionBytes lowers the post-externalization bound used -// before completing orchestration, activity, and entity work items. Multiple -// options are monotonic: a later option cannot raise an earlier -// transport-derived cap. +// WithMaxOrchestratorCompletionBytes lowers the post-externalization response +// bound used before completing an orchestration work item. Multiple options are +// monotonic: a later option cannot raise an earlier transport-derived cap. func WithMaxOrchestratorCompletionBytes(n int) TaskHubGrpcWorkerOption { return func(options *taskHubGrpcWorkerOptions) error { if n < minOrchestratorCompletionBytes || n > DefaultMaxOrchestratorCompletionBytes { diff --git a/client/grpc_worker_processor.go b/client/grpc_worker_processor.go index 62e5577b..92675571 100644 --- a/client/grpc_worker_processor.go +++ b/client/grpc_worker_processor.go @@ -389,57 +389,6 @@ func failOversizedOrchestratorResponse( } } -func completionTooLargeMessage(kind string, size, maxBytes int) string { - return fmt.Sprintf( - "%s of %.2f MiB exceeds the %.2f MiB worker completion bound; configure large-payload externalization or reduce the payload size", - kind, float64(size)/(1024*1024), float64(maxBytes)/(1024*1024), - ) -} - -// failOversizedActivityResponse converts an activity response that DTS cannot -// accept into a small, non-retriable task failure. Sending it unchanged would -// fail the RPC and abandon the work item, which re-runs the activity forever. -func failOversizedActivityResponse(response *protos.ActivityResponse, maxBytes int) *protos.ActivityResponse { - if response == nil || maxBytes <= 0 { - return response - } - size := proto.Size(response) - if size <= maxBytes { - return response - } - return &protos.ActivityResponse{ - InstanceId: response.InstanceId, - TaskId: response.TaskId, - CompletionToken: response.CompletionToken, - FailureDetails: &protos.TaskFailureDetails{ - ErrorType: string(api.ErrorTypeActivityResponseTooLarge), - ErrorMessage: completionTooLargeMessage("activity response", size, maxBytes), - IsNonRetriable: true, - }, - } -} - -// failOversizedEntityResult converts an entity batch result that DTS cannot -// accept into a small, non-retriable batch failure with no partial effects. -func failOversizedEntityResult(result *protos.EntityBatchResult, maxBytes int) *protos.EntityBatchResult { - if result == nil || maxBytes <= 0 { - return result - } - size := proto.Size(result) - if size <= maxBytes { - return result - } - return &protos.EntityBatchResult{ - CompletionToken: result.CompletionToken, - CompletionCount: result.CompletionCount, - FailureDetails: &protos.TaskFailureDetails{ - ErrorType: string(api.ErrorTypeEntityResultTooLarge), - ErrorMessage: completionTooLargeMessage("entity batch result", size, maxBytes), - IsNonRetriable: true, - }, - } -} - func populateOrchestratorActionTraceContexts( actions []*protos.OrchestratorAction, pastEvents []*protos.HistoryEvent, @@ -631,7 +580,6 @@ func (w *TaskHubGrpcWorker) processActivity( return } - response = failOversizedActivityResponse(response, w.options.maxOrchestratorCompletionBytes) err = w.executeRPCWithRetry(ctx, "complete activity task", func(callCtx context.Context) error { _, callErr := client.CompleteActivityTask(callCtx, response) return callErr @@ -808,7 +756,6 @@ func (w *TaskHubGrpcWorker) completeEntityBatchResult( instanceID string, result *protos.EntityBatchResult, ) { - result = failOversizedEntityResult(result, w.options.maxOrchestratorCompletionBytes) err := w.executeRPCWithRetry(ctx, "complete entity task", func(callCtx context.Context) error { _, callErr := client.CompleteEntityTask(callCtx, result) return callErr diff --git a/client/grpc_worker_test.go b/client/grpc_worker_test.go index a7685255..6efb1ae7 100644 --- a/client/grpc_worker_test.go +++ b/client/grpc_worker_test.go @@ -3,7 +3,6 @@ package client import ( "context" "errors" - "fmt" "io" "strings" "sync" @@ -1870,143 +1869,3 @@ func TestFailOversizedOrchestratorResponseIdentifiesOversizedAction(t *testing.T require.Contains(t, failure.GetErrorMessage(), "action 42") require.Contains(t, failure.GetErrorMessage(), "large-payload externalization") } - -func TestFailOversizedActivityResponse(t *testing.T) { - const maxBytes = 1024 - small := &protos.ActivityResponse{InstanceId: "instance", TaskId: 7, CompletionToken: "token", Result: wrapperspb.String("ok")} - require.Same(t, small, failOversizedActivityResponse(small, maxBytes)) - - large := &protos.ActivityResponse{ - InstanceId: "instance", - TaskId: 7, - CompletionToken: "token", - Result: wrapperspb.String(strings.Repeat("x", maxBytes*2)), - } - bounded := failOversizedActivityResponse(large, maxBytes) - require.LessOrEqual(t, proto.Size(bounded), maxBytes) - require.Equal(t, "instance", bounded.GetInstanceId()) - require.Equal(t, int32(7), bounded.GetTaskId()) - require.Equal(t, "token", bounded.GetCompletionToken()) - require.Nil(t, bounded.GetResult()) - require.Equal(t, string(api.ErrorTypeActivityResponseTooLarge), bounded.GetFailureDetails().GetErrorType()) - require.True(t, bounded.GetFailureDetails().GetIsNonRetriable()) - require.Contains(t, bounded.GetFailureDetails().GetErrorMessage(), "large-payload externalization") -} - -func TestFailOversizedEntityResult(t *testing.T) { - const maxBytes = 1024 - small := &protos.EntityBatchResult{CompletionToken: "token", EntityState: wrapperspb.String("state")} - require.Same(t, small, failOversizedEntityResult(small, maxBytes)) - - large := &protos.EntityBatchResult{ - CompletionToken: "token", - CompletionCount: 3, - EntityState: wrapperspb.String(strings.Repeat("s", maxBytes*2)), - Results: []*protos.OperationResult{{ResultType: &protos.OperationResult_Success{ - Success: &protos.OperationResultSuccess{Result: wrapperspb.String("r")}, - }}}, - OperationInfos: []*protos.OperationInfo{{RequestId: "req"}}, - } - bounded := failOversizedEntityResult(large, maxBytes) - require.LessOrEqual(t, proto.Size(bounded), maxBytes) - require.Equal(t, "token", bounded.GetCompletionToken()) - require.Equal(t, int32(3), bounded.GetCompletionCount()) - require.Nil(t, bounded.GetEntityState()) - require.Empty(t, bounded.GetResults()) - require.Empty(t, bounded.GetOperationInfos()) - require.Equal(t, string(api.ErrorTypeEntityResultTooLarge), bounded.GetFailureDetails().GetErrorType()) - require.True(t, bounded.GetFailureDetails().GetIsNonRetriable()) -} - -func TestWorkerOversizedActivityCompletion(t *testing.T) { - const limit = minOrchestratorCompletionBytes - value := strings.Repeat("x", 2*limit) - for _, externalize := range []bool{false, true} { - t.Run(fmt.Sprintf("externalize=%t", externalize), func(t *testing.T) { - client := new(fakeSchedulerClient) - opts := []TaskHubGrpcWorkerOption{WithMaxOrchestratorCompletionBytes(limit)} - var payloadOptions *api.LargePayloadOptions - if externalize { - store := payload.NewMemoryStore() - payloadOptions = &api.LargePayloadOptions{Store: store, Resolver: store, ThresholdBytes: 1024} - opts = append(opts, WithWorkerLargePayloads(payloadOptions)) - } - worker := newFakeWorker(t, client, opts...) - worker.executor = &recordingExecutor{ - executeActivity: func(context.Context, api.InstanceID, *protos.HistoryEvent) (*protos.HistoryEvent, error) { - return &protos.HistoryEvent{EventType: &protos.HistoryEvent_TaskCompleted{ - TaskCompleted: &protos.TaskCompletedEvent{Result: wrapperspb.String(value)}, - }}, nil - }, - } - worker.processActivity(context.Background(), client, "token", &protos.ActivityRequest{ - Name: "activity", TaskId: 7, - OrchestrationInstance: &protos.OrchestrationInstance{InstanceId: "instance"}, - }) - - require.Zero(t, client.activityAbandons) - require.Len(t, client.activityCompletions, 1) - completion := client.activityCompletions[0] - require.LessOrEqual(t, proto.Size(completion), limit) - require.Equal(t, "token", completion.CompletionToken) - if externalize { - require.Nil(t, completion.FailureDetails) - hydrated, err := largepayload.Hydrate(context.Background(), payloadOptions, completion.Result) - require.NoError(t, err) - require.Equal(t, value, hydrated.GetValue()) - } else { - require.Nil(t, completion.Result) - require.Equal(t, string(api.ErrorTypeActivityResponseTooLarge), completion.GetFailureDetails().GetErrorType()) - require.True(t, completion.GetFailureDetails().GetIsNonRetriable()) - } - }) - } -} - -func TestWorkerOversizedEntityCompletion(t *testing.T) { - const limit = minOrchestratorCompletionBytes - value := strings.Repeat("x", 2*limit) - for _, externalize := range []bool{false, true} { - t.Run(fmt.Sprintf("externalize=%t", externalize), func(t *testing.T) { - client := new(fakeSchedulerClient) - opts := []TaskHubGrpcWorkerOption{WithMaxOrchestratorCompletionBytes(limit)} - var payloadOptions *api.LargePayloadOptions - if externalize { - store := payload.NewMemoryStore() - payloadOptions = &api.LargePayloadOptions{Store: store, Resolver: store, ThresholdBytes: 1024} - opts = append(opts, WithWorkerLargePayloads(payloadOptions)) - } - worker := newFakeWorker(t, client, opts...) - worker.executor = &recordingExecutor{ - executeEntity: func(context.Context, *protos.EntityBatchRequest) (*protos.EntityBatchResult, error) { - return &protos.EntityBatchResult{ - EntityState: wrapperspb.String(value), - Results: []*protos.OperationResult{{ResultType: &protos.OperationResult_Success{ - Success: &protos.OperationResultSuccess{Result: wrapperspb.String("ok")}, - }}}, - }, nil - }, - } - worker.processEntityV2(context.Background(), client, "token", newFakeEntitySignalRequest("set", nil)) - - require.Zero(t, client.entityAbandonAttempts) - require.Len(t, client.entityCompletions, 1) - completion := client.entityCompletions[0] - require.LessOrEqual(t, proto.Size(completion), limit) - require.Equal(t, "token", completion.CompletionToken) - if externalize { - require.Nil(t, completion.FailureDetails) - require.Len(t, completion.OperationInfos, 1) - hydrated, err := largepayload.Hydrate(context.Background(), payloadOptions, completion.EntityState) - require.NoError(t, err) - require.Equal(t, value, hydrated.GetValue()) - } else { - require.Nil(t, completion.EntityState) - require.Empty(t, completion.Results) - require.Empty(t, completion.OperationInfos) - require.Equal(t, string(api.ErrorTypeEntityResultTooLarge), completion.GetFailureDetails().GetErrorType()) - require.True(t, completion.GetFailureDetails().GetIsNonRetriable()) - } - }) - } -} diff --git a/durabletaskscheduler/README.md b/durabletaskscheduler/README.md index 1044e9d0..f85bd9e5 100644 --- a/durabletaskscheduler/README.md +++ b/durabletaskscheduler/README.md @@ -164,15 +164,12 @@ limit, leaving message-size enforcement to the server. The gRPC-Go transport's own default maximum (approximately 2 GiB) still applies. A positive `Options.MaxSendMessageSize` opts into an explicit client-side send limit. -The worker retains a separate 3.9 MiB safety bound for every work item -completion, regardless of the default transport send behavior. When a positive +The worker retains a separate 3.9 MiB safety bound for orchestration +responses, regardless of the default transport send behavior. When a positive `Options.MaxSendMessageSize` is lower, that configured send limit becomes the -completion bound instead. The worker validates the final completion after -large-payload externalization. An oversized orchestration response fails the -orchestration once with `OrchestratorResponseTooLarge`; an oversized activity -response fails the task with non-retriable `ActivityResponseTooLarge`; and an -oversized entity batch result fails the batch with `EntityResultTooLarge`. The worker sends a -small failure completion instead of abandoning the oversized result. The legacy +bound instead. The worker validates the final response after large-payload +externalization and fails an orchestration once +with `OrchestratorResponseTooLarge` if it still exceeds that limit. The legacy `isPartial`/`chunkIndex` response fields are deprecated; the Go worker does not use them because validation against the current DTS emulator did not provide a portable chunking path. Configure large-payload storage or reduce per-turn From 02a31c5ae8b29a4371e83ec4423f850d5f86c3af Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 23 Nov 2026 13:40:22 -0800 Subject: [PATCH 8/8] Check connection cleanup errors in tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- durabletaskscheduler/connection_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/durabletaskscheduler/connection_test.go b/durabletaskscheduler/connection_test.go index 739d1a4f..ed62138e 100644 --- a/durabletaskscheduler/connection_test.go +++ b/durabletaskscheduler/connection_test.go @@ -695,7 +695,7 @@ func TestConnectionAppliesConfiguredSendMessageSize(t *testing.T) { require.NoError(t, err) conn, err := connect(&prepared, clientRole, "") require.NoError(t, err) - defer conn.Close() + defer func() { require.NoError(t, conn.Close()) }() request := &protos.GetInstanceRequest{InstanceId: strings.Repeat("x", testCase.messageBytes-5)} require.Equal(t, testCase.messageBytes, proto.Size(request)) @@ -726,7 +726,7 @@ func TestConnectionReceiveLimitAppliesPerStreamMessage(t *testing.T) { } conn, err := connect(&streamOptions, clientRole, "") require.NoError(t, err) - defer conn.Close() + defer func() { require.NoError(t, conn.Close()) }() stream, err := protos.NewTaskHubSidecarServiceClient(conn).StreamInstanceHistory(ctx, &protos.StreamInstanceHistoryRequest{}) require.NoError(t, err) for range 3 {