mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
fix: remove DNS caching (#837)
* fix: remove DNS caching DNS caching was initially implemented to avoid too many DNS requests, as Node.js does not cache them. However, the cacheable-lookup library we used to implement this cache created more problems than it solved, as it caused many unresolved DNS request errors that weren't occurring before. * fix: add PNPM lock file to Prettier ignore list * revert: prettier on PNPM
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
dist/
|
dist/
|
||||||
config/
|
config/
|
||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
|
pnpm-lock.yaml
|
||||||
|
|
||||||
# assets
|
# assets
|
||||||
src/assets/
|
src/assets/
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
"axios-rate-limit": "1.3.0",
|
"axios-rate-limit": "1.3.0",
|
||||||
"bcrypt": "5.1.0",
|
"bcrypt": "5.1.0",
|
||||||
"bowser": "2.11.0",
|
"bowser": "2.11.0",
|
||||||
"cacheable-lookup": "^7.0.0",
|
|
||||||
"connect-typeorm": "1.1.4",
|
"connect-typeorm": "1.1.4",
|
||||||
"cookie-parser": "1.4.6",
|
"cookie-parser": "1.4.6",
|
||||||
"copy-to-clipboard": "3.3.3",
|
"copy-to-clipboard": "3.3.3",
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -52,9 +52,6 @@ importers:
|
|||||||
bowser:
|
bowser:
|
||||||
specifier: 2.11.0
|
specifier: 2.11.0
|
||||||
version: 2.11.0
|
version: 2.11.0
|
||||||
cacheable-lookup:
|
|
||||||
specifier: ^7.0.0
|
|
||||||
version: 7.0.0
|
|
||||||
connect-typeorm:
|
connect-typeorm:
|
||||||
specifier: 1.1.4
|
specifier: 1.1.4
|
||||||
version: 1.1.4(typeorm@0.3.12(sqlite3@5.1.4(encoding@0.1.13))(ts-node@10.9.1(@swc/core@1.6.5(@swc/helpers@0.5.11))(@types/node@17.0.36)(typescript@4.9.5)))
|
version: 1.1.4(typeorm@0.3.12(sqlite3@5.1.4(encoding@0.1.13))(ts-node@10.9.1(@swc/core@1.6.5(@swc/helpers@0.5.11))(@types/node@17.0.36)(typescript@4.9.5)))
|
||||||
@@ -5764,13 +5761,6 @@ packages:
|
|||||||
}
|
}
|
||||||
engines: { node: ^12.13.0 || ^14.15.0 || >=16.0.0 }
|
engines: { node: ^12.13.0 || ^14.15.0 || >=16.0.0 }
|
||||||
|
|
||||||
cacheable-lookup@7.0.0:
|
|
||||||
resolution:
|
|
||||||
{
|
|
||||||
integrity: sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==,
|
|
||||||
}
|
|
||||||
engines: { node: '>=14.16' }
|
|
||||||
|
|
||||||
cachedir@2.3.0:
|
cachedir@2.3.0:
|
||||||
resolution:
|
resolution:
|
||||||
{
|
{
|
||||||
@@ -19815,8 +19805,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- bluebird
|
- bluebird
|
||||||
|
|
||||||
cacheable-lookup@7.0.0: {}
|
|
||||||
|
|
||||||
cachedir@2.3.0: {}
|
cachedir@2.3.0: {}
|
||||||
|
|
||||||
cachedir@2.4.0: {}
|
cachedir@2.4.0: {}
|
||||||
|
|||||||
@@ -23,25 +23,19 @@ import imageproxy from '@server/routes/imageproxy';
|
|||||||
import { getAppVersion } from '@server/utils/appVersion';
|
import { getAppVersion } from '@server/utils/appVersion';
|
||||||
import restartFlag from '@server/utils/restartFlag';
|
import restartFlag from '@server/utils/restartFlag';
|
||||||
import { getClientIp } from '@supercharge/request-ip';
|
import { getClientIp } from '@supercharge/request-ip';
|
||||||
import type CacheableLookupType from 'cacheable-lookup';
|
|
||||||
import { TypeormStore } from 'connect-typeorm/out';
|
import { TypeormStore } from 'connect-typeorm/out';
|
||||||
import cookieParser from 'cookie-parser';
|
import cookieParser from 'cookie-parser';
|
||||||
import csurf from 'csurf';
|
import csurf from 'csurf';
|
||||||
import { lookup } from 'dns';
|
|
||||||
import type { NextFunction, Request, Response } from 'express';
|
import type { NextFunction, Request, Response } from 'express';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import * as OpenApiValidator from 'express-openapi-validator';
|
import * as OpenApiValidator from 'express-openapi-validator';
|
||||||
import type { Store } from 'express-session';
|
import type { Store } from 'express-session';
|
||||||
import session from 'express-session';
|
import session from 'express-session';
|
||||||
import next from 'next';
|
import next from 'next';
|
||||||
import http from 'node:http';
|
|
||||||
import https from 'node:https';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import swaggerUi from 'swagger-ui-express';
|
import swaggerUi from 'swagger-ui-express';
|
||||||
import YAML from 'yamljs';
|
import YAML from 'yamljs';
|
||||||
|
|
||||||
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
|
|
||||||
|
|
||||||
const API_SPEC_PATH = path.join(__dirname, '../overseerr-api.yml');
|
const API_SPEC_PATH = path.join(__dirname, '../overseerr-api.yml');
|
||||||
|
|
||||||
logger.info(`Starting Overseerr version ${getAppVersion()}`);
|
logger.info(`Starting Overseerr version ${getAppVersion()}`);
|
||||||
@@ -52,25 +46,6 @@ const handle = app.getRequestHandler();
|
|||||||
app
|
app
|
||||||
.prepare()
|
.prepare()
|
||||||
.then(async () => {
|
.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<typeof lookup>));
|
|
||||||
} else {
|
|
||||||
originalLookup(...(args as Parameters<typeof originalLookup>));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
cacheable.install(http.globalAgent);
|
|
||||||
cacheable.install(https.globalAgent);
|
|
||||||
|
|
||||||
const dbConnection = await dataSource.initialize();
|
const dbConnection = await dataSource.initialize();
|
||||||
|
|
||||||
// Run migrations in production
|
// Run migrations in production
|
||||||
|
|||||||
Reference in New Issue
Block a user