From 03a2efa4f4a3d36103eb29b8bb9799558622b13a Mon Sep 17 00:00:00 2001 From: Koushik-Ayila Date: Wed, 17 Feb 2021 11:33:56 +0530 Subject: [PATCH 1/3] Fixed bug on multiple call placing during retries. --- lib/rest/axios.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/rest/axios.js b/lib/rest/axios.js index 0b81ddb..5c3879a 100644 --- a/lib/rest/axios.js +++ b/lib/rest/axios.js @@ -20,6 +20,7 @@ export function Axios(config) { const config = error.config; if (counter < max_time && error.response.status >= 500) { counter++; + config.url = options.urls[counter] + options.authId + '/' + options.action; return new Promise((resolve) => { resolve(axios(config)); }) @@ -85,11 +86,26 @@ export function Axios(config) { return new Promise((resolve, reject) => { if (isVoiceReq) { - retryWrapper(axios, {retryTime: 2}); - let retryAttempt; - for (retryAttempt = 0; retryAttempt < 3; retryAttempt++) { - options.url = apiVoiceUris[retryAttempt] + config.authId + '/' + action; + retryWrapper(axios, {retryTime: 2, urls: apiVoiceUris, authId: config.authId, action: action}); + options.url = apiVoiceUris[0] + config.authId + '/' + action; axios(options).then(response => { + const exceptionClass = { + 400: Exceptions.InvalidRequestError, + 401: Exceptions.AuthenticationError, + 404: Exceptions.ResourceNotFoundError, + 405: Exceptions.InvalidRequestError, + 500: Exceptions.ServerError, + } [response.status] || Error; + + if (!_.inRange(response.status, 200, 300)) { + let body = response.data; + if (typeof body === 'object') { + reject(new exceptionClass(JSON.stringify(body))); + } + else { + reject(new exceptionClass(body)); + } + } resolve({ response: response, body: response.data @@ -98,7 +114,6 @@ export function Axios(config) { .catch(function (error) { reject(error.stack+ "\r\n" + JSON.stringify(error.response.data)); }) - } } else { axios(options).then(response => { From 87e4b272cacb54ffae1ead2fb697a2d8f90301c6 Mon Sep 17 00:00:00 2001 From: Koushik-Ayila Date: Wed, 17 Feb 2021 16:19:59 +0530 Subject: [PATCH 2/3] Fixed bug on multiple call placing during retries. --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f6f7c6..38c1534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [4.14.2](https://github.com/plivo/plivo-node/releases/tag/v4.14.1)(2021-02-17) +- Fix duplicate call issue for make call API. + ## [4.14.1](https://github.com/plivo/plivo-node/releases/tag/v4.14.1)(2021-02-09) - Fix Buy Number API & env variables support for TypeScript. diff --git a/package.json b/package.json index 705d749..c4d3189 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.14.1", + "version": "4.14.2", "description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [ From 2bc340bf778b43c5f02bd5bd4c9b10b87eb10380 Mon Sep 17 00:00:00 2001 From: huzaif Date: Wed, 17 Feb 2021 16:35:20 +0530 Subject: [PATCH 3/3] fix version tag --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c1534..1052162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.14.2](https://github.com/plivo/plivo-node/releases/tag/v4.14.1)(2021-02-17) +## [4.14.2](https://github.com/plivo/plivo-node/releases/tag/v4.14.2)(2021-02-17) - Fix duplicate call issue for make call API. ## [4.14.1](https://github.com/plivo/plivo-node/releases/tag/v4.14.1)(2021-02-09)