From 7df89e66c8783d5afd423592de13acd855e8a9a6 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sat, 20 Mar 2021 10:21:10 -0700 Subject: [PATCH] request has no retry method i thought it was using superagent --- src/cert/acme2.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cert/acme2.js b/src/cert/acme2.js index 18eacd515..47b368953 100644 --- a/src/cert/acme2.js +++ b/src/cert/acme2.js @@ -572,18 +572,20 @@ Acme2.prototype.acmeFlow = function (hostname, domain, callback) { Acme2.prototype.getDirectory = function (callback) { const that = this; - request.retry(5).get(this.caDirectory, { json: true, timeout: 30000 }, function (error, response) { - if (error) return callback(new BoxError(BoxError.NETWORK_ERROR, `Network error getting directory: ${error.message}`)); - if (response.statusCode !== 200) return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Invalid response code when fetching directory : ' + response.statusCode)); + async.retry({ times: 3, interval: 20000 }, function (retryCallback) { + request.get(that.caDirectory, { json: true, timeout: 30000 }, function (error, response) { + if (error) return retryCallback(new BoxError(BoxError.NETWORK_ERROR, `Network error getting directory: ${error.message}`)); + if (response.statusCode !== 200) return retryCallback(new BoxError(BoxError.EXTERNAL_ERROR, 'Invalid response code when fetching directory : ' + response.statusCode)); - if (typeof response.body.newNonce !== 'string' || - typeof response.body.newOrder !== 'string' || - typeof response.body.newAccount !== 'string') return callback(new BoxError(BoxError.EXTERNAL_ERROR, `Invalid response body : ${response.body}`)); + if (typeof response.body.newNonce !== 'string' || + typeof response.body.newOrder !== 'string' || + typeof response.body.newAccount !== 'string') return retryCallback(new BoxError(BoxError.EXTERNAL_ERROR, `Invalid response body : ${response.body}`)); - that.directory = response.body; + that.directory = response.body; - callback(null); - }); + retryCallback(null); + }); + }, callback); }; Acme2.prototype.getCertificate = function (vhost, domain, callback) {