@fastify/reply-from
Advanced tools
Comparing version 9.6.0 to 9.7.0
@@ -166,3 +166,3 @@ 'use strict' | ||
requestImpl = createRequestRetry(request, this, (req, res, err, retries) => { | ||
return retryDelay({ err, req, res, attempt: retries, getDefaultDelay }) | ||
return retryDelay({ err, req, res, attempt: retries, getDefaultDelay, retriesCount }) | ||
}) | ||
@@ -169,0 +169,0 @@ } else { |
{ | ||
"name": "@fastify/reply-from", | ||
"version": "9.6.0", | ||
"version": "9.7.0", | ||
"description": "forward your HTTP request to another server, for fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -284,2 +284,3 @@ # @fastify/reply-from | ||
- `getDefaultRetry` refers to the default retry handler. If this callback returns not null and you wish to handle those case of errors simply invoke it as done below. | ||
- `retriesCount` refers to the retriesCount property a client passes to reply-from. Note if the client does not explicitly set this value it will default to 0. The objective value here is to avoid hard-coding and seeing the retriesCount set. It is your perogative to ensure that you ensure the value here is as you wish (and not `0` if not intended to be as a result of a lack of not setting it). | ||
@@ -286,0 +287,0 @@ Given example |
@@ -163,1 +163,25 @@ 'use strict' | ||
}) | ||
test('we handle our retries based on the retryCount', async (t) => { | ||
const attemptCounter = [] | ||
const customRetryLogic = ({ req, res, err, attempt, getDefaultDelay, retriesCount }) => { | ||
if (retriesCount < attempt) { | ||
return null | ||
} | ||
if (res && res.statusCode === 500 && req.method === 'GET') { | ||
attemptCounter.push(attempt) | ||
return 0.1 | ||
} | ||
return null | ||
} | ||
const { instance } = await setupServer(t, { retryDelay: customRetryLogic, retriesCount: 2 }, 500) | ||
const res = await got.get(`http://localhost:${instance.server.address().port}`, { retry: 5 }) | ||
t.match(attemptCounter, [0, 1]) | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
t.equal(res.statusCode, 205) | ||
t.equal(res.body.toString(), 'Hello World 5!') | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
190330
5489
497