Skip to content

Commit b34cc42

Browse files
authored
fix(app): return an empty icon manifest before the first data sync (#65)
iconManifestFn read manifest.json unconditionally, so a fresh install (no atlas yet) surfaced an ENOENT to the client on every launch. Return an empty manifest instead — icons fall back gracefully until a data sync builds the atlas.
1 parent 55f5926 commit b34cc42

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

app/src/server/factorio.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,14 @@ export const iconManifestFn = createServerFn({ method: "GET" }).handler(
18751875
const fs = await import("node:fs/promises");
18761876
const path = await import("node:path");
18771877
const { ICON_DATA_DIR } = await import("./paths.ts");
1878-
const raw = await fs.readFile(path.join(ICON_DATA_DIR, "manifest.json"), "utf8");
1878+
let raw: string;
1879+
try {
1880+
raw = await fs.readFile(path.join(ICON_DATA_DIR, "manifest.json"), "utf8");
1881+
} catch {
1882+
// No atlas yet (a fresh install, before the first data sync) — return an empty
1883+
// manifest so icons fall back gracefully instead of surfacing an ENOENT.
1884+
return { cell: 0, atlasSize: 0, sheets: [], icons: {} };
1885+
}
18791886
// file content is untyped input — assert the shape at this boundary only
18801887
const manifest = JSON.parse(raw) as IconManifest;
18811888
// Cache-bust the atlas sheets: the PNGs are served at stable URLs (/icons/

0 commit comments

Comments
 (0)