Skip to content

Commit

Permalink
Node v20で動かないのを修正 Resolve #2480
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Sep 23, 2023
1 parent fe5a456 commit 29b555f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 37 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"bootstrap": "4.6.2",
"bootstrap-vue": "2.23.1",
"bull": "4.10.4",
"cacheable-lookup": "6.1.0",
"cafy": "15.2.1",
"cbor": "8.1.0",
"chalk": "4.1.2",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions src/misc/dns.ts

This file was deleted.

12 changes: 8 additions & 4 deletions src/misc/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as http from 'http';
import * as https from 'https';
import { lookup } from './dns';
import fetch from 'node-fetch';
import CacheableLookup from 'cacheable-lookup';
import { HttpProxyAgent } from 'http-proxy-agent';
import { HttpsProxyAgent } from 'https-proxy-agent';
import config from '../config';
Expand Down Expand Up @@ -75,15 +75,19 @@ function objectAssignWithLcKey(a: Record<string, string>, b: Record<string, stri
return Object.assign(lcObjectKey(a), lcObjectKey(b));
}

//#region Agent
const cache = new CacheableLookup({
maxTtl: 3600, // 1hours
errorTtl: 30, // 30secs
lookup: false, // nativeのdns.lookupにfallbackしない
});

/**
* Get http non-proxy agent
*/
const _http = new http.Agent({
keepAlive: true,
keepAliveMsecs: 30 * 1000,
lookup: lookup,
lookup: cache.lookup,
} as http.AgentOptions);

/**
Expand All @@ -92,7 +96,7 @@ const _http = new http.Agent({
const _https = new https.Agent({
keepAlive: true,
keepAliveMsecs: 30 * 1000,
lookup: lookup,
lookup: cache.lookup,
} as https.AgentOptions);

/**
Expand Down

0 comments on commit 29b555f

Please sign in to comment.