Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// What requests are currently in flight?
const inFlightRequests: InflightRequests = {};
/**
* Setup caching stuff. We may not use it if caching isn't enabled
* but it won't do any harm just sitting there.
*/
const cache = new cacheModule();
const superagentCache = superagentCachePlugin(cache);
/**
* Setup keep-alive so that we can make more effective use of our connection
* to request JS files.
*/
const keepaliveAgent = new Agent({
keepAlive: true,
timeout: 60000, // active socket keepalive for 60 seconds
freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
});
/**
* Flush the cache.
*/
export function flushCache() {
/**
* Guard this in case we never enabled caching.
*/
if (args.useCache) {
cache.flush();
}
}
import Agent from 'agentkeepalive'
import axios from 'axios'
import retry, { exponentialDelay } from 'axios-retry'
import { Limit } from 'p-limit'
import { stringify } from 'qs'
import { mapObjIndexed, path, sum, toLower, values } from 'ramda'
import { renameBy } from '../../utils/renameBy'
import { isAbortedOrNetworkErrorOrRouterTimeout } from '../../utils/retry'
import { MiddlewareContext } from '../typings'
const httpAgent = new Agent({
freeSocketTimeout: 15 * 1000,
keepAlive: true,
maxFreeSockets: 50,
})
const http = axios.create({
httpAgent,
})
retry(http, {
retries: 0,
retryCondition: isAbortedOrNetworkErrorOrRouterTimeout,
retryDelay: exponentialDelay,
shouldResetTimeout: true,
})