diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af3c28..d3e9389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.11.5 +* use ServiceClientError type for Errors in shouldRetry and onRetry options. + ## 0.11.3 * Use `timing` option from client if `timing` is not set in the request options. #91 diff --git a/lib/client.ts b/lib/client.ts index 54fbad1..0b3bc11 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -92,10 +92,13 @@ export class ServiceClientOptions { minTimeout?: number; maxTimeout?: number; randomize?: boolean; - shouldRetry?: (err?: Error, req?: ServiceClientRequestOptions) => boolean; + shouldRetry?: ( + err?: ServiceClientError, + req?: ServiceClientRequestOptions + ) => boolean; onRetry?: ( currentAttempt?: number, - err?: Error, + err?: ServiceClientError, req?: ServiceClientRequestOptions ) => void; }; @@ -117,10 +120,13 @@ class ServiceClientStrictOptions { minTimeout: number; maxTimeout: number; randomize: boolean; - shouldRetry: (err?: Error, req?: ServiceClientRequestOptions) => boolean; + shouldRetry: ( + err?: ServiceClientError, + req?: ServiceClientRequestOptions + ) => boolean; onRetry: ( currentAttempt?: number, - err?: Error, + err?: ServiceClientError, req?: ServiceClientRequestOptions ) => void; }; diff --git a/lib/request.ts b/lib/request.ts index aba685a..fbf574c 100644 --- a/lib/request.ts +++ b/lib/request.ts @@ -81,7 +81,7 @@ export class ServiceClientResponse { constructor( public statusCode: number, public headers: IncomingHttpHeaders, - public body: Buffer | string | object, + public body: Buffer | string | object | object[], public request: ServiceClientRequestOptions ) { this.retryErrors = []; diff --git a/package-lock.json b/package-lock.json index 5476041..14d51c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "perron", - "version": "0.11.4", + "version": "0.11.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "perron", - "version": "0.11.4", + "version": "0.11.5", "license": "MIT", "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/package.json b/package.json index 843114d..4899267 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perron", - "version": "0.11.4", + "version": "0.11.5", "description": "A sane client for web services", "engines": { "node": ">=12.0.0"