T47 Ship: a gallery whose wasm fetch fails retries, then tells the host; the host shows it at once and waits a minute for a slow start

This commit is contained in:
ZacharyZhang-NY committed 2026-10-01 08:49:10 -04:00
1 parent 293ab76a0f
commit ed2904ce60
4 files changed
+42 -4

No files matched your search

+14 -1
View File
@@ -45,7 +45,20 @@
addEventListener("message", ({ data }) => {
if (data && data.ely === "theme") setTheme(data.theme);
});
await init();
// Frames that fetch the wasm at once can fail one; the next try finds it cached.
for (let attempt = 1; ; attempt++) {
try {
await init();
break;
} catch (error) {
console.warn(`gallery: start failed, try ${attempt}`, error);
if (attempt === 3) {
window.parent.postMessage({ ely: "failed", error: String(error) }, "*");
throw error;
}
await new Promise((wake) => setTimeout(wake, 1000 * attempt));
}
}
apply = set_theme;
if (early) set_theme(early);
// Tells the host that a mode it sends now lands.