Skip to content

fix: convert maxRetries to gRPC maxAttempts correctly#287

Merged
YunchuWang merged 1 commit into
mainfrom
copilot-finds/bug/fix-retry-policy-off-by-one
Jul 8, 2026
Merged

fix: convert maxRetries to gRPC maxAttempts correctly#287
YunchuWang merged 1 commit into
mainfrom
copilot-finds/bug/fix-retry-policy-off-by-one

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #221

…→maxAttempts conversion

The createServiceConfig() function used the maxRetries option value directly
as the gRPC maxAttempts field. However, gRPC's maxAttempts includes the
initial attempt, while maxRetries means retries after the initial call.

This caused users to get one fewer retry than configured. Setting
maxRetries: 0 also produced an invalid maxAttempts: 0 config.

Fix: Add +1 when converting maxRetries to maxAttempts.
Also add comprehensive unit tests for the entire retry-policy module
which previously had zero test coverage.

Fixes #221

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the Azure Managed SDK’s gRPC retry service config generation by correctly translating user-facing maxRetries (retries after the initial call) into gRPC maxAttempts (total attempts including the initial call), addressing the off-by-one behavior reported in #221.

Changes:

  • Adjust createServiceConfig() to compute maxAttempts as maxRetries + 1 when maxRetries is provided.
  • Add unit tests covering default service config validity, maxRetries→maxAttempts conversion (including 0), backoff formatting, and retryable status code mapping/behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/durabletask-js-azuremanaged/src/retry-policy.ts Fixes maxRetries → gRPC maxAttempts conversion logic to include the initial attempt.
packages/durabletask-js-azuremanaged/test/unit/retry-policy.spec.ts Adds unit coverage for the service config generator (defaults, conversion semantics, backoff formatting, status code handling).

Comment thread packages/durabletask-js-azuremanaged/src/retry-policy.ts
@YunchuWang
YunchuWang merged commit 333e1c1 into main Jul 8, 2026
29 checks passed
@YunchuWang
YunchuWang deleted the copilot-finds/bug/fix-retry-policy-off-by-one branch July 8, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: createServiceConfig() uses maxRetries directly as gRPC maxAttempts, causing off-by-one in retry count

3 participants