How to use the agentkeepalive function in agentkeepalive

To help you get started, we’ve selected a few agentkeepalive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Khan / react-render-server / src / fetch_package.js View on Github external
// 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();
    }
}
github vtex / node-vtex-api / src / HttpClient / middlewares / request.ts View on Github external
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,
})

agentkeepalive

Missing keepalive http.Agent

MIT
Latest version published 12 months ago

Package Health Score

83 / 100
Full package analysis