Add metadata timeout (#287)

* Add metadata timeout

* Fix lint
This commit is contained in:
DecDuck
2025-11-20 00:17:58 +00:00
committed by GitHub
parent 8f41024be2
commit beb824c8d9
9 changed files with 2790 additions and 784 deletions

View File

@ -1,4 +1,3 @@
import type { RouteLocationNormalized } from "vue-router";
import type { NavigationItem } from "./types"; import type { NavigationItem } from "./types";
export const useCurrentNavigationIndex = ( export const useCurrentNavigationIndex = (
@ -9,7 +8,7 @@ export const useCurrentNavigationIndex = (
const currentNavigation = ref(-1); const currentNavigation = ref(-1);
function calculateCurrentNavIndex(to: RouteLocationNormalized) { function calculateCurrentNavIndex(to: typeof route) {
const validOptions = navigation const validOptions = navigation
.map((e, i) => ({ ...e, index: i })) .map((e, i) => ({ ...e, index: i }))
.filter((e) => to.fullPath.startsWith(e.prefix)); .filter((e) => to.fullPath.startsWith(e.prefix));

View File

@ -37,6 +37,7 @@
"bcryptjs": "^3.0.2", "bcryptjs": "^3.0.2",
"cheerio": "^1.0.0", "cheerio": "^1.0.0",
"cookie-es": "^2.0.0", "cookie-es": "^2.0.0",
"dotenv": "^17.2.3",
"fast-fuzzy": "^1.12.0", "fast-fuzzy": "^1.12.0",
"file-type-mime": "^0.4.3", "file-type-mime": "^0.4.3",
"jdenticon": "^3.3.0", "jdenticon": "^3.3.0",
@ -65,7 +66,6 @@
"@nuxt/eslint": "^1.3.0", "@nuxt/eslint": "^1.3.0",
"@tailwindcss/forms": "^0.5.9", "@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15", "@tailwindcss/typography": "^0.5.15",
"@types/bcryptjs": "^3.0.0",
"@types/luxon": "^3.6.2", "@types/luxon": "^3.6.2",
"@types/node": "^22.13.16", "@types/node": "^22.13.16",
"@types/semver": "^7.7.0", "@types/semver": "^7.7.0",

3529
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
onlyBuiltDependencies: onlyBuiltDependencies:
- '@prisma/client' - "@prisma/client"
- '@prisma/engines' - "@prisma/engines"
- '@tailwindcss/oxide' - "@tailwindcss/oxide"
- esbuild - esbuild
- prisma - prisma

View File

@ -1,6 +1,9 @@
import { config } from "dotenv";
import type { PrismaConfig } from "prisma"; import type { PrismaConfig } from "prisma";
import path from "node:path"; import path from "node:path";
config();
export default { export default {
schema: path.join("prisma"), schema: path.join("prisma"),
earlyAccess: true, earlyAccess: true,

View File

@ -42,7 +42,7 @@ export default defineEventHandler(async (h3) => {
) )
throw createError({ throw createError({
statusCode: 400, statusCode: 400,
statusMessage: "Invalid capabilities.", message: "Invalid capabilities.",
}); });
if ( if (

View File

@ -17,21 +17,10 @@ export default defineClientEventHandler(async (h3) => {
orderBy: { orderBy: {
versionIndex: "desc", // Latest one first versionIndex: "desc", // Latest one first
}, },
omit: {
dropletManifest: true,
},
}); });
const mappedVersions = versions return versions;
.map((version) => {
if (!version.dropletManifest) return undefined;
const newVersion = { ...version, dropletManifest: undefined };
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore idk why we delete an undefined object
delete newVersion.dropletManifest;
return {
...newVersion,
};
})
.filter((e) => e);
return mappedVersions;
}); });

View File

@ -4,6 +4,8 @@ class SystemConfig {
private libraryFolder = process.env.LIBRARY ?? "./.data/library"; private libraryFolder = process.env.LIBRARY ?? "./.data/library";
private dataFolder = process.env.DATA ?? "./.data/data"; private dataFolder = process.env.DATA ?? "./.data/data";
private metadataTimeout = parseInt(process.env.METADATA_TIMEOUT ?? "5000");
private externalUrl = normalizeUrl( private externalUrl = normalizeUrl(
process.env.EXTERNAL_URL ?? "http://localhost:3000", process.env.EXTERNAL_URL ?? "http://localhost:3000",
{ stripWWW: false }, { stripWWW: false },
@ -28,6 +30,10 @@ class SystemConfig {
return this.dataFolder; return this.dataFolder;
} }
getMetadataTimeout() {
return this.metadataTimeout;
}
getDropVersion() { getDropVersion() {
return this.dropVersion; return this.dropVersion;
} }

View File

@ -82,6 +82,10 @@ export class MetadataHandler {
// TODO: fix eslint error // TODO: fix eslint error
// eslint-disable-next-line no-async-promise-executor // eslint-disable-next-line no-async-promise-executor
>(async (resolve, reject) => { >(async (resolve, reject) => {
setTimeout(
() => reject(new Error("Timeout while fetching results")),
systemConfig.getMetadataTimeout(),
);
try { try {
const results = await provider.search(query); const results = await provider.search(query);
const mappedResults: InternalGameMetadataResult[] = results.map( const mappedResults: InternalGameMetadataResult[] = results.map(