From 798339669252c5ace2c45b48a277b425527c8ce6 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 21 Oct 2026 17:20:35 -0400 Subject: [PATCH 1/2] fix: JS reliability bugs (SonarCloud S1764, S9383, S4275) - scriptui.js: replace the self-comparison NaN check (o.max === o.max) with the explicit Number.isNaN(o.max) (S1764). - sw.js: mark the fire-and-forget cache.put() with void and a .catch() so the promise rejection is handled (S9383). - prelude.js: return __err(...) from the activeCamera getter so every path yields a value (S4275); __err always throws, so behavior is unchanged. --- apps/effectcraft-web/web/sw.js | 2 +- crates/expr/src/prelude.js | 2 +- crates/script/src/scriptui.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/effectcraft-web/web/sw.js b/apps/effectcraft-web/web/sw.js index 8c7efc2e..c5605c81 100644 --- a/apps/effectcraft-web/web/sw.js +++ b/apps/effectcraft-web/web/sw.js @@ -38,7 +38,7 @@ self.addEventListener("fetch", (event) => { const hit = await cache.match(key, { ignoreSearch: req.mode === "navigate" }); if (hit) return hit; const res = await fetch(req); - if (res.ok && res.type === "basic") cache.put(req, res.clone()); + if (res.ok && res.type === "basic") void cache.put(req, res.clone()).catch(() => {}); return res; })(), ); diff --git a/crates/expr/src/prelude.js b/crates/expr/src/prelude.js index 4da7bc63..df6ed3ff 100644 --- a/crates/expr/src/prelude.js +++ b/crates/expr/src/prelude.js @@ -461,7 +461,7 @@ Comp.prototype = { var l = this.layer(i); if (l.__info[10] === 'Camera' && l.active) return l; } - __err('Composition "' + this.name + '" has no active camera'); + return __err('Composition "' + this.name + '" has no active camera'); }, layer: function (a, rel) { if (a !== null && typeof a === 'object' && a.__isLayer) return this.layer(a.index + (rel || 0)); diff --git a/crates/script/src/scriptui.js b/crates/script/src/scriptui.js index af1e14b5..52c65efb 100644 --- a/crates/script/src/scriptui.js +++ b/crates/script/src/scriptui.js @@ -840,7 +840,7 @@ function __uiJson(c, inherited) { o.value = Number(c.value) || 0; o.min = Number(c.minvalue) || 0; o.max = Number(c.maxvalue); - if (!(o.max === o.max)) o.max = 100; + if (Number.isNaN(o.max)) o.max = 100; } if (c.items) { o.items = c.items.map(function (it) { return String(it.text); }); From ec0cc83a2955cbfb16bfceba80697b1775e635fd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 22 Oct 2026 19:19:20 -0400 Subject: [PATCH 2/2] fix(web): fall back to network when caches.open fails in service worker --- apps/effectcraft-web/web/sw.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/effectcraft-web/web/sw.js b/apps/effectcraft-web/web/sw.js index c5605c81..4acbeeee 100644 --- a/apps/effectcraft-web/web/sw.js +++ b/apps/effectcraft-web/web/sw.js @@ -32,13 +32,15 @@ self.addEventListener("fetch", (event) => { if (req.method !== "GET" || url.origin !== self.location.origin) return; event.respondWith( (async () => { - const cache = await caches.open(CACHE); - // The page itself regardless of its query (?empty, ?demo…). - const key = req.mode === "navigate" ? new URL("./", self.registration.scope).href : req; - const hit = await cache.match(key, { ignoreSearch: req.mode === "navigate" }); - if (hit) return hit; + const cache = await caches.open(CACHE).catch(() => null); + if (cache) { + // The page itself regardless of its query (?empty, ?demo…). + const key = req.mode === "navigate" ? new URL("./", self.registration.scope).href : req; + const hit = await cache.match(key, { ignoreSearch: req.mode === "navigate" }).catch(() => null); + if (hit) return hit; + } const res = await fetch(req); - if (res.ok && res.type === "basic") void cache.put(req, res.clone()).catch(() => {}); + if (cache && res.ok && res.type === "basic") void cache.put(req, res.clone()).catch(() => {}); return res; })(), );