feat(utils): parallelize gamedata loader + structured fetch errors

Three improvements on top of duckietm/Dev's new JSON5 + split-aware
gamedata loader:

1. Parallel fetches inside loadGamedata: every file declared in a
   tier's manifest is now fetched with Promise.all. The merge step
   still walks the parts in declared order so override semantics
   (core -> custom -> seasonal, and within-tier declaration order)
   are preserved. Root-manifest files and per-tier manifest discovery
   also run concurrently.

2. tryFetchManifest distinguishes 404 from other failures. The
   previous tryFetchOrNull silently treated parse errors and 5xx as
   "manifest missing", so a malformed manifest.json5 made an entire
   tier vanish from the boot. Now only HTTP 404 returns null; every
   other failure propagates.

3. New ConfigJsonError class with phase ('fetch' | 'parse'),
   sourceUrl, and optional httpStatus. Exported isMissingResource()
   helper lets callers check for 404 without string-matching.

Also:
- mergeGamedata warns via NitroLogger when an array looks keyed by
  id/classname/name on >=80% of items but a few are missing the
  key (the previous behavior fell back to concat() and produced
  silent duplicates).
- Removed the dead text === null/undefined branch in parseConfigJson
  (Response.text() never returns null).

Verified: tsgo clean, 138/138 tests pass on the renderer, 207/207
tests pass on the client (no behavioral change to existing callers).
This commit is contained in:
simoleo89
2026-05-19 17:14:13 +02:00
parent 807efcff8f
commit ce561bd5b3
3 changed files with 165 additions and 59 deletions
+53 -10
View File
@@ -369,7 +369,7 @@
resolved "https://registry.yarnpkg.com/@standard-schema/spec/-/spec-1.1.0.tgz#a79b55dbaf8604812f52d140b2c9ab41bc150bb8"
integrity sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==
"@thumbmarkjs/thumbmarkjs@^1.8.1":
"@thumbmarkjs/thumbmarkjs@^1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@thumbmarkjs/thumbmarkjs/-/thumbmarkjs-1.9.0.tgz#a6444ac1f924f061cfc1507a21dcaf83ee705cab"
integrity sha512-6LooyYk8i5L2zEZgDMLE6m2sGDcIHHBiZfxdFp0A16Q4ZXafEmhHmt+zCqQEBMiQHi+08e/v5q77IY2KhvAJwg==
@@ -527,6 +527,54 @@
"@typescript-eslint/types" "8.59.3"
eslint-visitor-keys "^5.0.0"
"@typescript/native-preview-darwin-arm64@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-darwin-arm64/-/native-preview-darwin-arm64-7.0.0-dev.20260519.1.tgz#deaa14299366a79917a6ec19fc7f240304c36afe"
integrity sha512-c9zdG6sGJf25Jpz04JgE23zhYeprqFypDGuqiX94yMTvR8IWXjq3R2oMnim66YLBDon/V1nCEy6cFixeSd/4fg==
"@typescript/native-preview-darwin-x64@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-darwin-x64/-/native-preview-darwin-x64-7.0.0-dev.20260519.1.tgz#a6348c134204afdcdfa8f9a0925091788fc994d7"
integrity sha512-N16V3wiM0tsNmSSA7nZrxqXXt5OCJxBwiCVn35rnA7fr4WzJw6rJmwf9heNNhZ6Gh4ne3+Pexajf5akzuHR75Q==
"@typescript/native-preview-linux-arm64@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-linux-arm64/-/native-preview-linux-arm64-7.0.0-dev.20260519.1.tgz#04f2f0b314e646a6921cc818db6bac92364bab24"
integrity sha512-ltf91vAwKdbu0SlRQbFgi1h5ZrLLrBn6a4qIeN2VILGbtYrCXnARHRznLBv81yUETQ7aVr/LSQcmsWo1ejCK0w==
"@typescript/native-preview-linux-arm@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-linux-arm/-/native-preview-linux-arm-7.0.0-dev.20260519.1.tgz#ad10403fb8ae6e2ed120cb9f81a029328a00e995"
integrity sha512-8v4BExeeuCTrhaSGfeIJqm3qQkTzlZix/Qd/FkPlWoz9f7d7COvXb3Z4qhbaVolL0MMnUvQ7m005Z4kYsZ645A==
"@typescript/native-preview-linux-x64@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-linux-x64/-/native-preview-linux-x64-7.0.0-dev.20260519.1.tgz#dde79208611da3855f995e595b9b790c622f726f"
integrity sha512-AVD0tczTtFCHNa4RQRVPvu8Hnw4P3hQ+OlUAjnz/lHowvc6o1pYB46elMqfDuaoWqIpv+EAkAPP4ipFCofJ5IA==
"@typescript/native-preview-win32-arm64@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-win32-arm64/-/native-preview-win32-arm64-7.0.0-dev.20260519.1.tgz#74d0cf98c75e2df20772ae2fa4c8139066e2cf7f"
integrity sha512-TM+qatljyejqjHevCta3WIH53i0oGC7K8SoJ6t+mf4cGMTpZTyd7NhC1ts7e6/aydZnG53Bsta2iQi1SMIlQEw==
"@typescript/native-preview-win32-x64@7.0.0-dev.20260519.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview-win32-x64/-/native-preview-win32-x64-7.0.0-dev.20260519.1.tgz#a8cfe9f730399cdc21a20c40a59aee15eef75a18"
integrity sha512-r9LEsoY7JC/82gXo8hlOmpQaUXcqmngCVOv+mUx1UeMt9f+1S6oNO0W48o75mlBqqC7jfcMHqw8YS4LfVxPRGw==
"@typescript/native-preview@^7.0.0-dev.20260510.1":
version "7.0.0-dev.20260519.1"
resolved "https://registry.yarnpkg.com/@typescript/native-preview/-/native-preview-7.0.0-dev.20260519.1.tgz#0d865f5cc6d376d896fc031dfbb38ed0004153c6"
integrity sha512-VVER7vFUDdfm5k3jbH5765tVEJa7+0rTUkFeXyGYrXPxpw9BIjA0QDxdtdlRyaU8MCZV9IKZUo6doxeAQRAjPg==
optionalDependencies:
"@typescript/native-preview-darwin-arm64" "7.0.0-dev.20260519.1"
"@typescript/native-preview-darwin-x64" "7.0.0-dev.20260519.1"
"@typescript/native-preview-linux-arm" "7.0.0-dev.20260519.1"
"@typescript/native-preview-linux-arm64" "7.0.0-dev.20260519.1"
"@typescript/native-preview-linux-x64" "7.0.0-dev.20260519.1"
"@typescript/native-preview-win32-arm64" "7.0.0-dev.20260519.1"
"@typescript/native-preview-win32-x64" "7.0.0-dev.20260519.1"
"@vitest/coverage-v8@^4.0.18":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-4.1.6.tgz#1eacee5def68dfcb08c3ed5355edbad2a4c869b3"
@@ -1681,15 +1729,10 @@ typescript-eslint@^8.26.1:
"@typescript-eslint/typescript-estree" "8.59.3"
"@typescript-eslint/utils" "8.59.3"
typescript@~5.5.4:
version "5.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==
typescript@~5.8.2:
version "5.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==
typescript@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-6.0.3.tgz#90251dc007916e972786cb94d74d15b185577d21"
integrity sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==
undici-types@~6.21.0:
version "6.21.0"