From bc40432daca814884f1f25a1fd136ab4477445c7 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 16 Apr 2019 14:28:46 -0700 Subject: [PATCH] Retry errors 3 times on reasonably retryable errors. --- package-lock.json | 97 ++++++++++++++++++++++---------------------- package.json | 16 ++++---- src/index.ts | 6 +-- src/programs.test.ts | 2 +- src/values.test.ts | 2 +- 5 files changed, 62 insertions(+), 61 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2d60598..5da5f80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lightrail-client", - "version": "4.1.2", + "version": "4.1.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -44,18 +44,18 @@ } }, "@types/jsonwebtoken": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.3.0.tgz", - "integrity": "sha512-YKnUTR4VxwljbPORPrRon9E3uel1aD8nUdvzqArCCdMTWPvo0gnI2UZkwIHN2QATdj6HYXV/Iq3/KcecAO42Ww==", + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.3.2.tgz", + "integrity": "sha512-Mkjljd9DTpkPlrmGfTJvcP4aBU7yO2QmW7wNVhV4/6AEUxYoacqU7FJU/N0yFEHTsIrE4da3rUrjrR5ejicFmA==", "dev": true, "requires": { "@types/node": "*" } }, "@types/mocha": { - "version": "5.2.5", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", - "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", + "version": "5.2.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.6.tgz", + "integrity": "sha512-1axi39YdtBI7z957vdqXI4Ac25e7YihYQtJa+Clnxg1zTJEaIRbndt71O3sP4GAMgiAm0pY26/b9BrY4MR/PMw==", "dev": true }, "@types/node": { @@ -190,9 +190,9 @@ } }, "chai-exclude": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/chai-exclude/-/chai-exclude-1.0.12.tgz", - "integrity": "sha512-7xJgaLhigf51U+s7k23vOLnXk4w/rIffmlnUu/ueYJg21sLyrTqCn3BxvOjbGNGYgXTQNFwjFX3lUnbcai0oCA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/chai-exclude/-/chai-exclude-2.0.1.tgz", + "integrity": "sha512-9cZ0ZzlGRwZvNiKUPTbx4E1anQ4aTqtKOX96+cb4XrNa+8B5KNZg3d43clYNawgXgBcQAenXeX5fbeY7+TdkrA==", "dev": true, "requires": { "fclone": "^1.0.11" @@ -306,9 +306,9 @@ } }, "ecdsa-sig-formatter": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz", - "integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", "requires": { "safe-buffer": "^5.0.1" } @@ -425,9 +425,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", - "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -435,11 +435,11 @@ } }, "jsonwebtoken": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.4.0.tgz", - "integrity": "sha512-coyXjRTCy0pw5WYBpMvWOMN+Kjaik2MwTUIq9cna/W7NpO9E+iYbumZONAz3hcr+tXFJECoQVrtmIoC3Oz0gvg==", + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", + "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", "requires": { - "jws": "^3.1.5", + "jws": "^3.2.2", "lodash.includes": "^4.3.0", "lodash.isboolean": "^3.0.3", "lodash.isinteger": "^4.0.4", @@ -447,7 +447,8 @@ "lodash.isplainobject": "^4.0.6", "lodash.isstring": "^4.0.1", "lodash.once": "^4.0.0", - "ms": "^2.1.1" + "ms": "^2.1.1", + "semver": "^5.6.0" }, "dependencies": { "ms": { @@ -458,21 +459,21 @@ } }, "jwa": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.6.tgz", - "integrity": "sha512-tBO/cf++BUsJkYql/kBbJroKOgHWEigTKBAjjBEmrMGYd1QMBC74Hr4Wo2zCZw6ZrVhlJPvoMrkcOnlWR/DJfw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", "requires": { "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.10", + "ecdsa-sig-formatter": "1.0.11", "safe-buffer": "^5.0.1" } }, "jws": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.5.tgz", - "integrity": "sha512-GsCSexFADNQUr8T5HPJvayTjvPIfoyJPtLQBwn5a4WZQchcrPMPMAWcC1AzJVRDKyD6ZPROPAxgv6rfHViO4uQ==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", "requires": { - "jwa": "^1.1.5", + "jwa": "^1.4.1", "safe-buffer": "^5.0.1" } }, @@ -702,8 +703,7 @@ "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" }, "source-map": { "version": "0.6.1", @@ -712,9 +712,9 @@ "dev": true }, "source-map-support": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.10.tgz", - "integrity": "sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ==", + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", + "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -789,9 +789,9 @@ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" }, "ts-node": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.0.2.tgz", - "integrity": "sha512-MosTrinKmaAcWgO8tqMjMJB22h+sp3Rd1i4fdoWY4mhBDekOwIAKI/bzmRi7IcbCmjquccYg2gcF6NBkLgr0Tw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.1.0.tgz", + "integrity": "sha512-34jpuOrxDuf+O6iW1JpgTRDFynUZ1iEqtYruBqh35gICNjN8x+LpVcPAcwzLPi9VU6mdA3ym+x233nZmZp445A==", "dev": true, "requires": { "arg": "^4.1.0", @@ -808,9 +808,9 @@ "dev": true }, "tslint": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.12.1.tgz", - "integrity": "sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==", + "version": "5.15.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.15.0.tgz", + "integrity": "sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==", "dev": true, "requires": { "babel-code-frame": "^6.22.0", @@ -819,12 +819,13 @@ "commander": "^2.12.1", "diff": "^3.2.0", "glob": "^7.1.1", - "js-yaml": "^3.7.0", + "js-yaml": "^3.13.0", "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", "tslib": "^1.8.0", - "tsutils": "^2.27.2" + "tsutils": "^2.29.0" }, "dependencies": { "ansi-styles": { @@ -874,9 +875,9 @@ "dev": true }, "typescript": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3.tgz", - "integrity": "sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.3.tgz", + "integrity": "sha512-FFgHdPt4T/duxx6Ndf7hwgMZZjZpB+U0nMNGVCYPq0rEzWKjEDobm4J6yb3CS7naZ0yURFqdw9Gwc7UOh/P9oQ==", "dev": true }, "underscore": { @@ -908,9 +909,9 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, "yn": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.0.0.tgz", - "integrity": "sha512-+Wo/p5VRfxUgBUGy2j/6KX2mj9AYJWOHuhMjMcbBFc3y54o9/4buK1ksBvuiK01C3kby8DH9lSmJdSxw+4G/2Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.0.tgz", + "integrity": "sha512-kKfnnYkbTfrAdd0xICNFw7Atm8nKpLcLv9AZGEt+kczL/WQVai4e2V6ZN8U/O+iI6WrNuJjNNOyu4zfhl9D3Hg==", "dev": true } } diff --git a/package.json b/package.json index a871732..3aa5afd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lightrail-client", - "version": "4.1.4", + "version": "4.1.5", "description": "A Javascript and Typescript client for Lightrail", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -36,25 +36,25 @@ "@types/chai": "^4.1.7", "@types/chai-as-promised": "^7.1.0", "@types/dotenv-safe": "^5.0.3", - "@types/jsonwebtoken": "^8.3.0", - "@types/mocha": "^5.2.5", + "@types/jsonwebtoken": "^8.3.2", + "@types/mocha": "^5.2.6", "@types/node": "^10.12.24", "@types/parse-link-header": "^1.0.0", "@types/superagent": "^3.8.6", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", - "chai-exclude": "^1.0.12", + "chai-exclude": "^2.0.1", "dotenv-safe": "^6.1.0", "mitm": "^1.7.0", "mocha": "^5.2.0", "rimraf": "^2.6.3", - "ts-node": "^8.0.2", - "tslint": "^5.12.1", - "typescript": "^3.3.3", + "ts-node": "^8.1.0", + "tslint": "^5.15.0", + "typescript": "^3.4.3", "uuid": "^3.3.2" }, "dependencies": { - "jsonwebtoken": "^8.4.0", + "jsonwebtoken": "^8.5.1", "parse-link-header": "^1.0.1", "superagent": "^4.1.0" }, diff --git a/src/index.ts b/src/index.ts index 97f059a..7dd270c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -82,10 +82,10 @@ export function request(method: string, path: string): superagent.Request { throw new Error("apiKey not set"); } - // We can do some fancy things with superagent here like request rate - // throttling or automatic retry on particular codes. + // We can do some fancy things with superagent here like request rate throttling. let r = superagent(method, configuration.restRoot + path) - .ok(() => true); + .ok(() => true) + .retry(); if (!!configuration.apiKey) { r.set("Authorization", `Bearer ${configuration.apiKey}`); diff --git a/src/programs.test.ts b/src/programs.test.ts index 56b2be5..a5f9f3d 100644 --- a/src/programs.test.ts +++ b/src/programs.test.ts @@ -1,7 +1,7 @@ import * as chai from "chai"; import * as Lightrail from "./index"; import * as uuid from "uuid"; -import chaiExclude = require("chai-exclude"); +import chaiExclude from "chai-exclude"; import {CreateIssuanceParams, CreateProgramParams} from "./params"; chai.use(chaiExclude); diff --git a/src/values.test.ts b/src/values.test.ts index b27ba7d..e60193a 100644 --- a/src/values.test.ts +++ b/src/values.test.ts @@ -2,7 +2,7 @@ import * as chai from "chai"; import * as Lightrail from "./index"; import * as uuid from "uuid"; import {CreateContactParams, CreateValueParams} from "./params"; -import chaiExclude = require("chai-exclude"); +import chaiExclude from "chai-exclude"; chai.use(chaiExclude);