Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Remove async-lru cache for jsonld

Chocobozzzc900788e5999
diff --git a/package.json b/package.json
index 859491f647..b503b19deb 100644
--- a/package.json
+++ b/package.json
@@ -109,7 +109,6 @@
"@peertube/http-signature": "^1.7.0",
"@smithy/node-http-handler": "^2.1.7",
"@uploadx/core": "^6.0.0",
- "async-lru": "^1.1.1",
"async-mutex": "^0.4.0",
"bcrypt": "5.1.1",
"bencode": "^4.0.0",
diff --git a/server/core/helpers/custom-jsonld-signature.ts b/server/core/helpers/custom-jsonld-signature.ts
index 0bbe682daa..402c1e13ed 100644
--- a/server/core/helpers/custom-jsonld-signature.ts
+++ b/server/core/helpers/custom-jsonld-signature.ts
@@ -1,6 +1,4 @@
-import AsyncLRU from 'async-lru'
import jsonld from 'jsonld'
-import { logger } from './logger.js'
const CACHE = {
'https://w3id.org/security/v1': {
@@ -55,36 +53,19 @@ const CACHE = {
}
}
-const nodeDocumentLoader = (jsonld as any).documentLoaders.node()
-
-const lru = new AsyncLRU({
- max: 10,
- load: (url, cb) => {
- if (CACHE[url] !== undefined) {
- logger.debug('Using cache for JSON-LD %s.', url)
-
- return cb(null, {
- contextUrl: null,
- document: CACHE[url],
- documentUrl: url
- })
- }
-
- nodeDocumentLoader(url)
- .then(value => cb(null, value))
- .catch(err => cb(err))
- }
-});
+const nodeDocumentLoader = (jsonld as any).documentLoaders.node();
/* eslint-disable no-import-assign */
(jsonld as any).documentLoader = (url) => {
- return new Promise((res, rej) => {
- lru.get(url, (err, value) => {
- if (err) return rej(err)
-
- return res(value)
+ if (url in CACHE) {
+ return Promise.resolve({
+ contextUrl: null,
+ document: CACHE[url],
+ documentUrl: url
})
- })
+ }
+
+ return nodeDocumentLoader(url)
}
export { jsonld }
diff --git a/server/core/initializers/constants.ts b/server/core/initializers/constants.ts
index 5d9eb96347..2f436ec7f8 100644
--- a/server/core/initializers/constants.ts
+++ b/server/core/initializers/constants.ts
@@ -988,7 +988,7 @@ const WORKER_THREADS = {
},
BUILD_DIGEST: {
CONCURRENCY: 1,
- MAX_THREADS: Math.min(totalCPUs, 2)
+ MAX_THREADS: 1
}
}
diff --git a/yarn.lock b/yarn.lock
index 98ba6f3fa3..cf41bebff9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3199,13 +3199,6 @@ assertion-error@^1.1.0:
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
-async-lru@^1.1.1:
- version "1.1.3"
- resolved "https://registry.yarnpkg.com/async-lru/-/async-lru-1.1.3.tgz#38f1a99379d4872d969136858be098ca2550f4c6"
- integrity sha512-tPoYtjE2HCZqZHgOqFJLbgLP+IzY0V1qldIvH/lYd2opuMtO9OURxaCgNBhy5m4lUs3mz4R5iG+xI2uuqoOlwQ==
- dependencies:
- lru "^3.1.0"
-
async-mutex@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/async-mutex/-/async-mutex-0.4.0.tgz#ae8048cd4d04ace94347507504b3cf15e631c25f"