All files / src/models isomorphic-http-with-agent.js

100% Statements 14/14
66.66% Branches 2/3
100% Functions 1/1
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15193x 193x 193x 193x 193x 193x 193x 193x 193x 10x 10x 10x 10x 10x  
import * as git from 'isomorphic-git/http/node';
import http from 'node:http';
import https from 'node:https';
 
// We use our own HTTP plugin, so we can customize the agent used for requests and configure a long timeout (default is 5 seconds).
 
const KEEP_ALIVE_TIMEOUT = 10 * 60 * 1000;
 
export function request(params) {
  const agent = params.url.startsWith('https:')
    ? new https.Agent({ keepAlive: true, timeout: KEEP_ALIVE_TIMEOUT })
    : new http.Agent({ keepAlive: true, timeout: KEEP_ALIVE_TIMEOUT });
  return git.request({ ...params, agent });
}