From 2f7cfa35335f982d23929adb49b8811af754eeb1 Mon Sep 17 00:00:00 2001 From: fallenbagel <98979876+Fallenbagel@users.noreply.github.com> Date: Fri, 21 Jun 2024 00:29:49 +0500 Subject: [PATCH] revert: dns caching #810 (46ee8a4) --- package.json | 1 - server/index.ts | 25 ------------------------- yarn.lock | 5 ----- 3 files changed, 31 deletions(-) diff --git a/package.json b/package.json index 32b66e19..97c02550 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "axios-rate-limit": "1.3.0", "bcrypt": "5.1.0", "bowser": "2.11.0", - "cacheable-lookup": "^7.0.0", "connect-typeorm": "1.1.4", "cookie-parser": "1.4.6", "copy-to-clipboard": "3.3.3", diff --git a/server/index.ts b/server/index.ts index a9a74656..477864c2 100644 --- a/server/index.ts +++ b/server/index.ts @@ -23,25 +23,19 @@ import imageproxy from '@server/routes/imageproxy'; import { getAppVersion } from '@server/utils/appVersion'; import restartFlag from '@server/utils/restartFlag'; import { getClientIp } from '@supercharge/request-ip'; -import type CacheableLookupType from 'cacheable-lookup'; import { TypeormStore } from 'connect-typeorm/out'; import cookieParser from 'cookie-parser'; import csurf from 'csurf'; -import { lookup } from 'dns'; import type { NextFunction, Request, Response } from 'express'; import express from 'express'; import * as OpenApiValidator from 'express-openapi-validator'; import type { Store } from 'express-session'; import session from 'express-session'; import next from 'next'; -import http from 'node:http'; -import https from 'node:https'; import path from 'path'; import swaggerUi from 'swagger-ui-express'; import YAML from 'yamljs'; -const _importDynamic = new Function('modulePath', 'return import(modulePath)'); - const API_SPEC_PATH = path.join(__dirname, '../overseerr-api.yml'); logger.info(`Starting Overseerr version ${getAppVersion()}`); @@ -52,25 +46,6 @@ const handle = app.getRequestHandler(); app .prepare() .then(async () => { - const CacheableLookup = (await _importDynamic('cacheable-lookup')) - .default as typeof CacheableLookupType; - const cacheable = new CacheableLookup(); - - const originalLookup = cacheable.lookup; - - // if hostname is localhost use dns.lookup instead of cacheable-lookup - cacheable.lookup = (...args: any) => { - const [hostname] = args; - if (hostname === 'localhost') { - lookup(...(args as Parameters)); - } else { - originalLookup(...(args as Parameters)); - } - }; - - cacheable.install(http.globalAgent); - cacheable.install(https.globalAgent); - const dbConnection = await dataSource.initialize(); // Run migrations in production diff --git a/yarn.lock b/yarn.lock index b9485510..09b5a3ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5033,11 +5033,6 @@ cacache@^16.0.0, cacache@^16.1.0, cacache@^16.1.3: tar "^6.1.11" unique-filename "^2.0.0" -cacheable-lookup@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz#3476a8215d046e5a3202a9209dd13fec1f933a27" - integrity sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w== - cachedir@2.3.0, cachedir@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/cachedir/-/cachedir-2.3.0.tgz#0c75892a052198f0b21c7c1804d8331edfcae0e8"