Skip to content

Commit

Permalink
deps: make-fetch-happen@10.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf authored and lukekarrys committed Mar 28, 2022
1 parent 716a07f commit feb4446
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 29 deletions.
5 changes: 5 additions & 0 deletions node_modules/make-fetch-happen/lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const LRU = require('lru-cache')
const url = require('url')
const isLambda = require('is-lambda')
const dns = require('./dns.js')

const AGENT_CACHE = new LRU({ max: 50 })
const HttpAgent = require('agentkeepalive')
Expand Down Expand Up @@ -77,11 +78,13 @@ function getAgent (uri, opts) {
rejectUnauthorized: opts.rejectUnauthorized,
timeout: agentTimeout,
freeSocketTimeout: 15000,
lookup: dns.getLookup(opts.dns),
}) : new HttpAgent({
maxSockets: agentMaxSockets,
localAddress: opts.localAddress,
timeout: agentTimeout,
freeSocketTimeout: 15000,
lookup: dns.getLookup(opts.dns),
})
AGENT_CACHE.set(key, agent)
return agent
Expand Down Expand Up @@ -171,6 +174,8 @@ const HttpsProxyAgent = require('https-proxy-agent')
const SocksProxyAgent = require('socks-proxy-agent')
module.exports.getProxy = getProxy
function getProxy (proxyUrl, opts, isHttps) {
// our current proxy agents do not support an overridden dns lookup method, so will not
// benefit from the dns cache
const popts = {
host: proxyUrl.hostname,
port: proxyUrl.port,
Expand Down
4 changes: 2 additions & 2 deletions node_modules/make-fetch-happen/lib/cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const cacheFetch = async (request, options) => {

// otherwise, we make a request, store it and return it
const response = await remote(request, options)
const entry = new CacheEntry({ request, response, options })
return entry.store('miss')
const newEntry = new CacheEntry({ request, response, options })
return newEntry.store('miss')
}

// we have a cached response that satisfies this request, however if the cache
Expand Down
49 changes: 49 additions & 0 deletions node_modules/make-fetch-happen/lib/dns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const LRUCache = require('lru-cache')
const dns = require('dns')

const defaultOptions = exports.defaultOptions = {
family: undefined,
hints: dns.ADDRCONFIG,
all: false,
verbatim: true,
}

const lookupCache = exports.lookupCache = new LRUCache({ max: 50 })

// this is a factory so that each request can have its own opts (i.e. ttl)
// while still sharing the cache across all requests
exports.getLookup = (dnsOptions) => {
return (hostname, options, callback) => {
if (typeof options === 'function') {
callback = options
options = null
} else if (typeof options === 'number') {
options = { family: options }
}

options = { ...defaultOptions, ...options }

const key = JSON.stringify({
hostname,
family: options.family,
hints: options.hints,
all: options.all,
verbatim: options.verbatim,
})

if (lookupCache.has(key)) {
const [address, family] = lookupCache.get(key)
process.nextTick(callback, null, address, family)
return
}

dnsOptions.lookup(hostname, options, (err, address, family) => {
if (err) {
return callback(err)
}

lookupCache.set(key, [address, family], { ttl: dnsOptions.ttl })
return callback(null, address, family)
})
}
}
4 changes: 4 additions & 0 deletions node_modules/make-fetch-happen/lib/options.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const dns = require('dns')

const conditionalHeaders = [
'if-modified-since',
'if-none-match',
Expand Down Expand Up @@ -26,6 +28,8 @@ const configureOptions = (opts) => {
options.retry = { retries: 0, ...options.retry }
}

options.dns = { ttl: 5 * 60 * 1000, lookup: dns.lookup, ...options.dns }

options.cache = options.cache || 'default'
if (options.cache === 'default') {
const hasConditionalHeader = Object.keys(options.headers || {}).some((name) => {
Expand Down
32 changes: 18 additions & 14 deletions node_modules/make-fetch-happen/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "make-fetch-happen",
"version": "10.0.6",
"version": "10.1.0",
"description": "Opinionated, caching, retrying fetch client",
"main": "lib/index.js",
"files": [
"bin",
"lib"
"bin/",
"lib/"
],
"scripts": {
"preversion": "npm test",
Expand All @@ -14,13 +14,16 @@
"test": "tap",
"posttest": "npm run lint",
"eslint": "eslint",
"lint": "eslint '**/*.js'",
"lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
"postlint": "npm-template-check",
"postlint": "template-oss-check",
"snap": "tap",
"template-copy": "npm-template-copy --force"
"template-oss-apply": "template-oss-apply --force"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/make-fetch-happen.git"
},
"repository": "https://github.com/npm/make-fetch-happen",
"keywords": [
"http",
"request",
Expand All @@ -34,12 +37,12 @@
"license": "ISC",
"dependencies": {
"agentkeepalive": "^4.2.1",
"cacache": "^16.0.0",
"cacache": "^16.0.2",
"http-cache-semantics": "^4.1.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"is-lambda": "^1.0.1",
"lru-cache": "^7.5.1",
"lru-cache": "^7.7.1",
"minipass": "^3.1.6",
"minipass-collect": "^1.0.2",
"minipass-fetch": "^2.0.3",
Expand All @@ -51,24 +54,25 @@
"ssri": "^8.0.1"
},
"devDependencies": {
"@npmcli/template-oss": "^2.9.2",
"eslint": "^8.11.0",
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.1.2",
"mkdirp": "^1.0.4",
"nock": "^13.2.4",
"rimraf": "^3.0.2",
"safe-buffer": "^5.2.1",
"standard-version": "^9.3.2",
"tap": "^15.1.6"
"tap": "^16.0.0"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16"
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"tap": {
"color": 1,
"files": "test/*.js",
"check-coverage": true
},
"templateOSS": {
"version": "2.9.2"
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.1.2"
}
}
24 changes: 12 additions & 12 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"libnpmsearch": "^5.0.2",
"libnpmteam": "^4.0.2",
"libnpmversion": "^3.0.1",
"make-fetch-happen": "^10.0.6",
"make-fetch-happen": "^10.1.0",
"minipass": "^3.1.6",
"minipass-pipeline": "^1.2.4",
"mkdirp": "^1.0.4",
Expand Down Expand Up @@ -4858,18 +4858,18 @@
"peer": true
},
"node_modules/make-fetch-happen": {
"version": "10.0.6",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.0.6.tgz",
"integrity": "sha512-4Gfh6lV3TLXmj7qz79hBFuvVqjYSMW6v2+sxtdX4LFQU0rK3V/txRjE0DoZb7X0IF3t9f8NO3CxPSWlvdckhVA==",
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.1.0.tgz",
"integrity": "sha512-HeP4QlkadP/Op+hE+Une1070kcyN85FshQObku3/rmzRh4zDcKXA19d2L3AQR6UoaX3uZmhSOpTLH15b1vOFvQ==",
"inBundle": true,
"dependencies": {
"agentkeepalive": "^4.2.1",
"cacache": "^16.0.0",
"cacache": "^16.0.2",
"http-cache-semantics": "^4.1.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"is-lambda": "^1.0.1",
"lru-cache": "^7.5.1",
"lru-cache": "^7.7.1",
"minipass": "^3.1.6",
"minipass-collect": "^1.0.2",
"minipass-fetch": "^2.0.3",
Expand All @@ -4881,7 +4881,7 @@
"ssri": "^8.0.1"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16"
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
"node_modules/markdown-escapes": {
Expand Down Expand Up @@ -14471,17 +14471,17 @@
"peer": true
},
"make-fetch-happen": {
"version": "10.0.6",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.0.6.tgz",
"integrity": "sha512-4Gfh6lV3TLXmj7qz79hBFuvVqjYSMW6v2+sxtdX4LFQU0rK3V/txRjE0DoZb7X0IF3t9f8NO3CxPSWlvdckhVA==",
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.1.0.tgz",
"integrity": "sha512-HeP4QlkadP/Op+hE+Une1070kcyN85FshQObku3/rmzRh4zDcKXA19d2L3AQR6UoaX3uZmhSOpTLH15b1vOFvQ==",
"requires": {
"agentkeepalive": "^4.2.1",
"cacache": "^16.0.0",
"cacache": "^16.0.2",
"http-cache-semantics": "^4.1.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"is-lambda": "^1.0.1",
"lru-cache": "^7.5.1",
"lru-cache": "^7.7.1",
"minipass": "^3.1.6",
"minipass-collect": "^1.0.2",
"minipass-fetch": "^2.0.3",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"libnpmsearch": "^5.0.2",
"libnpmteam": "^4.0.2",
"libnpmversion": "^3.0.1",
"make-fetch-happen": "^10.0.6",
"make-fetch-happen": "^10.1.0",
"minipass": "^3.1.6",
"minipass-pipeline": "^1.2.4",
"mkdirp": "^1.0.4",
Expand Down

0 comments on commit feb4446

Please sign in to comment.