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..2bf146f1 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(); }) @@ -96,9 +96,26 @@ describe("custom client options", function () { expect(countPolicy.count).eq(2); }); - // 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"); + 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); + }); })