Skip to content

Commit

Permalink
Node v20で動かないのを修正 Resolve #4707
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Sep 18, 2023
1 parent 274bf54 commit 4cf1426
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 36 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"bootstrap-vue": "2.23.1",
"browser-image-resizer": "2.4.1",
"bull": "4.10.4",
"cacheable-lookup": "6.1.0",
"cafy": "15.2.1",
"chalk": "4.1.2",
"content-disposition": "0.5.4",
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: 9 additions & 3 deletions src/misc/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as http from 'http';
import * as https from 'https';
import { lookup } from './dns';
import CacheableLookup from 'cacheable-lookup';
import got, * as Got from 'got';
import { HttpProxyAgent } from 'http-proxy-agent';
import { HttpsProxyAgent } from 'https-proxy-agent';
Expand Down Expand Up @@ -132,13 +132,19 @@ function objectAssignWithLcKey(a: Record<string, string>, b: Record<string, stri
return Object.assign(lcObjectKey(a), lcObjectKey(b));
}

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 @@ -147,7 +153,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 4cf1426

Please sign in to comment.