Gateway: unreadable store file fails loudly instead of reading as empty (S13)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-09-27 19:20:47 +00:00
1 parent eba1e1af92
commit 2b668a7f73
2 files changed
+12 -2

No files matched your search

+7 -1
View File
@@ -431,7 +431,13 @@ const requestHandler = (req: IncomingMessage, res: ServerResponse) => {
requestUrl.pathname === "/api/store/themes" ||
requestUrl.pathname.startsWith("/api/store/themes/")
) {
await handleStore(req, res, requestUrl.pathname);
await handleStore(req, res, requestUrl.pathname).catch((err) => {
console.error("[store] Request failed:", err);
if (!res.headersSent) {
res.writeHead(500, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "internal" }));
}
});
return;
}
+5 -1
View File
@@ -117,7 +117,11 @@ async function loadStoreThemes(): Promise<StoreTheme[]> {
if (storeCache) return storeCache;
try {
storeCache = JSON.parse(await readFile(STORE_DATA_FILE, "utf-8")) as StoreTheme[];
} catch {
} catch (err) {
// Only a missing file means "no themes yet". Anything else (unreadable,
// corrupt) must fail loudly - treating it as empty would let the next
// submission overwrite every stored theme.
if ((err as NodeJS.ErrnoException).code !== "ENOENT") throw err;
storeCache = [];
}
return storeCache;