Skip to content

Commit

Permalink
Revert "fix(http): use keepAlive and agent (almost) everywhere (#3318)"
Browse files Browse the repository at this point in the history
This reverts commit f238cf9.
  • Loading branch information
bodinsamuel committed Jan 17, 2025
1 parent c11a8cd commit 94b51c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
3 changes: 0 additions & 3 deletions packages/jobs/lib/runner/render.api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { httpAgent, httpsAgent } from '@nangohq/utils';
import type { AxiosInstance, AxiosResponse } from 'axios';
import axios from 'axios';

Expand All @@ -7,8 +6,6 @@ export class RenderAPI {
constructor(apiKey: string) {
this.httpClient = axios.create({
baseURL: 'https://api.render.com/v1',
httpAgent: httpAgent,
httpsAgent: httpsAgent,
headers: {
Authorization: `Bearer ${apiKey}`,
Accept: 'application/json'
Expand Down
5 changes: 3 additions & 2 deletions packages/server/lib/helpers/tba.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios';
import type { OAuthSession } from '@nangohq/shared';
import type { Provider, IntegrationConfig as ProviderConfig } from '@nangohq/types';
import { interpolateStringFromObject } from '@nangohq/shared';
import { generateBaseString, generateSignature, getTbaMetaParams, SIGNATURE_METHOD, percentEncode, axiosInstance } from '@nangohq/utils';
import { generateBaseString, generateSignature, getTbaMetaParams, SIGNATURE_METHOD, percentEncode } from '@nangohq/utils';

export async function makeAccessTokenRequest({
provider,
Expand Down Expand Up @@ -66,7 +67,7 @@ export async function makeAccessTokenRequest({
Authorization: authHeader
};

const response = await axiosInstance.post(fullAccessTokenEndpoint, null, { headers });
const response = await axios.post(fullAccessTokenEndpoint, null, { headers });

const parsedData = new URLSearchParams(response.data);

Expand Down
12 changes: 2 additions & 10 deletions packages/utils/lib/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,8 @@ import type { Agent as HttpAgent } from 'node:http';
import type { Agent as HttpsAgent } from 'node:https';
import https from 'node:https';

const options: https.AgentOptions = {
keepAlive: true, // default to false for some reason
timeout: 60000,
maxFreeSockets: 2000,
scheduling: 'fifo', // optimize for open sockets and better for high throughput
family: 4 // Using IPV4 can reduce network error and reduce latency https://github.com/nodejs/node/issues/5436#issuecomment-189474356
};

export let httpAgent: HttpProxyAgent<string> | HttpAgent = new http.Agent(options);
export let httpsAgent: HttpsProxyAgent<string> | HttpsAgent = new https.Agent(options);
export let httpAgent: HttpProxyAgent<string> | HttpAgent = new http.Agent();
export let httpsAgent: HttpsProxyAgent<string> | HttpsAgent = new https.Agent();

const hasHttpProxy = process.env['http_proxy'] || process.env['HTTP_PROXY'];
const hasHttpsProxy = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
Expand Down

0 comments on commit 94b51c6

Please sign in to comment.