added random retry times
This commit is contained in:
		
							
								
								
									
										8
									
								
								dist/cflare.classes.cflareaccount.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								dist/cflare.classes.cflareaccount.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										16
									
								
								test/test.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								test/test.js
									
									
									
									
									
								
							| @@ -13,7 +13,7 @@ describe('cflare', function () { | ||||
|     describe('.CflareAccount', function () { | ||||
|         describe('.listZones()', function () { | ||||
|             it('should display an entire account', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.listZones() | ||||
|                     .then((responseArg) => { | ||||
|                     done(); | ||||
| @@ -22,7 +22,7 @@ describe('cflare', function () { | ||||
|         }); | ||||
|         describe('.getZoneId(domainName)', function () { | ||||
|             it('should get an Cloudflare Id for a domain string', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.getZoneId('bleu.de') | ||||
|                     .then((responseArg) => { | ||||
|                     done(); | ||||
| @@ -31,7 +31,7 @@ describe('cflare', function () { | ||||
|         }); | ||||
|         describe('.listRecords(domainName)', function () { | ||||
|             it('should list all records for a specific Domain Name', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.listRecords('bleu.de') | ||||
|                     .then((responseArg) => { | ||||
|                     console.log(responseArg); | ||||
| @@ -41,14 +41,14 @@ describe('cflare', function () { | ||||
|         }); | ||||
|         describe('.createRecord', function () { | ||||
|             it('should create a valid record for a level 2 domain', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.createRecord('bleu.de', 'A', '127.0.0.1') | ||||
|                     .then(function (responseArg) { | ||||
|                     done(); | ||||
|                 }); | ||||
|             }); | ||||
|             it('should create a valid record for a subdomain', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.createRecord('subdomain.bleu.de', 'A', '127.0.0.1') | ||||
|                     .then(function (responseArg) { | ||||
|                     done(); | ||||
| @@ -57,7 +57,7 @@ describe('cflare', function () { | ||||
|         }); | ||||
|         describe('.getRecord', function () { | ||||
|             it('should get a record from Cloudflare', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.getRecord('bleu.de', 'A') | ||||
|                     .then(function (responseArg) { | ||||
|                     console.log(responseArg); | ||||
| @@ -67,7 +67,7 @@ describe('cflare', function () { | ||||
|         }); | ||||
|         describe('.removeRecord', function () { | ||||
|             it('should remove a record from Cloudflare', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.removeRecord('bleu.de', 'A') | ||||
|                     .then(function (responseArg) { | ||||
|                     console.log(responseArg); | ||||
| @@ -75,7 +75,7 @@ describe('cflare', function () { | ||||
|                 }); | ||||
|             }); | ||||
|             it('should remove a subdomain record from Cloudflare', function (done) { | ||||
|                 this.timeout(30000); | ||||
|                 this.timeout(60000); | ||||
|                 testCflareAccount.removeRecord('subdomain.bleu.de', 'A') | ||||
|                     .then(function (responseArg) { | ||||
|                     console.log(responseArg); | ||||
|   | ||||
							
								
								
									
										16
									
								
								test/test.ts
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								test/test.ts
									
									
									
									
									
								
							| @@ -14,7 +14,7 @@ describe('cflare', function () { | ||||
|     describe('.CflareAccount', function () { | ||||
|         describe('.listZones()', function () { | ||||
|             it('should display an entire account', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.listZones() | ||||
|                     .then((responseArg) => { | ||||
|                         done() | ||||
| @@ -23,7 +23,7 @@ describe('cflare', function () { | ||||
|         }) | ||||
|         describe('.getZoneId(domainName)', function () { | ||||
|             it('should get an Cloudflare Id for a domain string', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.getZoneId('bleu.de') | ||||
|                     .then((responseArg) => { | ||||
|                         done() | ||||
| @@ -32,7 +32,7 @@ describe('cflare', function () { | ||||
|         }) | ||||
|         describe('.listRecords(domainName)', function () { | ||||
|             it('should list all records for a specific Domain Name', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.listRecords('bleu.de') | ||||
|                     .then((responseArg) => { | ||||
|                         console.log(responseArg) | ||||
| @@ -42,14 +42,14 @@ describe('cflare', function () { | ||||
|         }) | ||||
|         describe('.createRecord', function () { | ||||
|             it('should create a valid record for a level 2 domain', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.createRecord('bleu.de', 'A', '127.0.0.1') | ||||
|                     .then(function (responseArg) { | ||||
|                         done() | ||||
|                     }) | ||||
|             }) | ||||
|             it('should create a valid record for a subdomain', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.createRecord('subdomain.bleu.de', 'A', '127.0.0.1') | ||||
|                     .then(function (responseArg) { | ||||
|                         done() | ||||
| @@ -58,7 +58,7 @@ describe('cflare', function () { | ||||
|         }) | ||||
|         describe('.getRecord', function () { | ||||
|             it('should get a record from Cloudflare', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.getRecord('bleu.de', 'A') | ||||
|                     .then(function (responseArg) { | ||||
|                         console.log(responseArg) | ||||
| @@ -68,7 +68,7 @@ describe('cflare', function () { | ||||
|         }) | ||||
|         describe('.removeRecord', function () { | ||||
|             it('should remove a record from Cloudflare', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.removeRecord('bleu.de', 'A') | ||||
|                     .then(function (responseArg) { | ||||
|                         console.log(responseArg) | ||||
| @@ -76,7 +76,7 @@ describe('cflare', function () { | ||||
|                     }) | ||||
|             }) | ||||
|             it('should remove a subdomain record from Cloudflare', function (done) { | ||||
|                 this.timeout(30000) | ||||
|                 this.timeout(60000) | ||||
|                 testCflareAccount.removeRecord('subdomain.bleu.de', 'A') | ||||
|                     .then(function (responseArg) { | ||||
|                         console.log(responseArg) | ||||
|   | ||||
| @@ -137,13 +137,11 @@ export class CflareAccount { | ||||
|                 console.log('rate limited! Waiting for retry!') | ||||
|                 retryRequest() | ||||
|             } else { | ||||
|                 console.log(response.status) | ||||
|                 console.log(response.messages) | ||||
|                 console.log(response.errors) | ||||
|                 console.log(response.statusCode) | ||||
|                 done.reject(new Error('request failed')) | ||||
|             } | ||||
|         } | ||||
|         let retryRequest = async (delayTimeArg = 6000) => { | ||||
|         let retryRequest = async (delayTimeArg = Math.floor(Math.random() * (60000 - 8000) + 8000)) => { | ||||
|             console.log(`retry started and waiting for ${delayTimeArg} ms`) | ||||
|             await plugins.smartdelay.delayFor(delayTimeArg) | ||||
|             if (retryCount < 10) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user