Socket
Socket
Sign inDemoInstall

@fastify/reply-from

Package Overview
Dependencies
12
Maintainers
20
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.6.0 to 9.7.0

2

index.js

@@ -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!')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc