Skip to content

Commit

Permalink
[core-amqp] Mark more network errors as retryable (#33230)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR
@azure/core-amqp

### Issues associated with this PR
#33205

### Describe the problem that is addressed by this PR
Some network errors are not being retried.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?
It makes sense to retry network errors.

### Are there test cases added in this PR? _(If not, why?)_
Yes

### Provide a list of related PRs _(if any)_
N/A

### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [x] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [x] Added a changelog (if necessary)
  • Loading branch information
deyaaeldeen authored Feb 28, 2025
1 parent d47f5b3 commit d3c6094
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sdk/core/core-amqp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Designates `EAI_AGAIN` and `EADDRNOTAVAIL` errors as timeout errors to be retryable.

### Other Changes

## 4.3.5 (2025-02-06)
Expand Down
4 changes: 4 additions & 0 deletions sdk/core/core-amqp/review/core-amqp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ export const StandardAbortMessage = "The operation was aborted.";

// @public
export enum SystemErrorConditionMapper {
// (undocumented)
EADDRNOTAVAIL = "com.microsoft:timeout",
// (undocumented)
EAI_AGAIN = "com.microsoft:timeout",
// (undocumented)
EBUSY = "com.microsoft:server-busy",
// (undocumented)
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/core-amqp/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ export enum SystemErrorConditionMapper {
ENETRESET = "com.microsoft:timeout",
ENETUNREACH = "com.microsoft:timeout",
ENONET = "com.microsoft:timeout",
EADDRNOTAVAIL = "com.microsoft:timeout",
EAI_AGAIN = "com.microsoft:timeout",
/* eslint-enable @typescript-eslint/no-duplicate-enum-values */
}

Expand Down
18 changes: 17 additions & 1 deletion sdk/core/core-amqp/test/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ describe("Errors", function () {
syscall: "read",
message: "code: ENOTFOUND, errno: ENOTFOUND, syscall: read",
},
{
code: "EADDRNOTAVAIL",
errno: "EADDRNOTAVAIL",
syscall: "read",
message: "code: EADDRNOTAVAIL, errno: EADDRNOTAVAIL, syscall: read",
},
{
code: "EAI_AGAIN",
errno: "EAI_AGAIN",
syscall: "read",
message: "code: EAI_AGAIN, errno: EAI_AGAIN, syscall: read",
},
{
code: "ESOMETHINGRANDOM",
errno: "ESOMETHINGRANDOM",
Expand All @@ -197,7 +209,11 @@ describe("Errors", function () {
const translatedError = Errors.translate(mapping as any) as Errors.MessagingError;
assert.equal(translatedError.name, "MessagingError");
assert.equal(translatedError.code, mapping.code);
if (["ECONNRESET", "ECONNREFUSED", "EBUSY"].indexOf(mapping.code) !== -1) {
if (
["ECONNRESET", "ECONNREFUSED", "EBUSY", "EAI_AGAIN", "EADDRNOTAVAIL"].indexOf(
mapping.code,
) !== -1
) {
assert.isTrue(translatedError.retryable);
} else {
assert.isFalse(translatedError.retryable);
Expand Down

0 comments on commit d3c6094

Please sign in to comment.