From 505a9c61dc1d209b3285ae7ea85cd40f7d83efe2 Mon Sep 17 00:00:00 2001 From: Yan Zhang Date: Thu, 9 Nov 2023 05:24:50 +0800 Subject: [PATCH 1/2] update @azure/core-rest-pipeline to 1.12.2 --- package-lock.json | 14 +++++++------- test/clientOptions.test.ts | 29 +++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9987ca56..d500c31e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -145,9 +145,9 @@ } }, "node_modules/@azure/core-rest-pipeline": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.12.1.tgz", - "integrity": "sha512-SsyWQ+T5MFQRX+M8H/66AlaI6HyCbQStGfFngx2fuiW+vKI2DkhtOvbYodPyf9fOe/ARLWWc3ohX54lQ5Kmaog==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.12.2.tgz", + "integrity": "sha512-wLLJQdL4v1yoqYtEtjKNjf8pJ/G/BqVomAWxcKOR1KbZJyCEnCv04yks7Y1NhJ3JzxbDs307W67uX0JzklFdCg==", "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.4.0", @@ -160,7 +160,7 @@ "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" } }, "node_modules/@azure/core-tracing": { @@ -3655,9 +3655,9 @@ } }, "@azure/core-rest-pipeline": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.12.1.tgz", - "integrity": "sha512-SsyWQ+T5MFQRX+M8H/66AlaI6HyCbQStGfFngx2fuiW+vKI2DkhtOvbYodPyf9fOe/ARLWWc3ohX54lQ5Kmaog==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.12.2.tgz", + "integrity": "sha512-wLLJQdL4v1yoqYtEtjKNjf8pJ/G/BqVomAWxcKOR1KbZJyCEnCv04yks7Y1NhJ3JzxbDs307W67uX0JzklFdCg==", "requires": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.4.0", diff --git a/test/clientOptions.test.ts b/test/clientOptions.test.ts index c5496fb9..d06174a5 100644 --- a/test/clientOptions.test.ts +++ b/test/clientOptions.test.ts @@ -28,12 +28,12 @@ class HttpRequestCountPolicy { describe("custom client options", function () { const fakeEndpoint = "https://azure.azconfig.io"; - before(() => { + beforeEach(() => { // Thus here mock it to reply 500, in which case the retry mechanism works. nock(fakeEndpoint).persist().get(() => true).reply(500); }); - after(() => { + afterEach(() => { nock.restore(); }) @@ -98,7 +98,28 @@ describe("custom client options", function () { // Note: // core-rest-pipeline skips the retry throwing `RestError: getaddrinfo ENOTFOUND azure.azconfig.io` - // Probably would be fixed in upstream libs. // See https://github.com/Azure/azure-sdk-for-js/issues/27037 - it("should retry on DNS failure"); + // Fixed in @azure/core-rest-pipeline@1.2.2 + it("should retry on DNS failure", async () => { + nock.restore(); // stop mocking with 500 error but sending real requests which will fail with ENOTFOUND + const countPolicy = new HttpRequestCountPolicy(); + const loadPromise = () => { + return load(createMockedConnectionString(fakeEndpoint), { + clientOptions: { + additionalPolicies: [{ + policy: countPolicy, + position: "perRetry" + }] + } + }) + }; + let error; + try { + await loadPromise(); + } catch (e) { + error = e; + } + expect(error).not.undefined; + expect(countPolicy.count).eq(3); + }); }) From 004d34cbddc45b7b1c6feeb94f644bdc3e77a55b Mon Sep 17 00:00:00 2001 From: Yan Zhang <2351748+Eskibear@users.noreply.github.com> Date: Thu, 9 Nov 2023 07:04:00 +0800 Subject: [PATCH 2/2] remove notes --- test/clientOptions.test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/clientOptions.test.ts b/test/clientOptions.test.ts index d06174a5..2bf146f1 100644 --- a/test/clientOptions.test.ts +++ b/test/clientOptions.test.ts @@ -96,10 +96,6 @@ describe("custom client options", function () { expect(countPolicy.count).eq(2); }); - // Note: - // core-rest-pipeline skips the retry throwing `RestError: getaddrinfo ENOTFOUND azure.azconfig.io` - // See https://github.com/Azure/azure-sdk-for-js/issues/27037 - // Fixed in @azure/core-rest-pipeline@1.2.2 it("should retry on DNS failure", async () => { nock.restore(); // stop mocking with 500 error but sending real requests which will fail with ENOTFOUND const countPolicy = new HttpRequestCountPolicy();