From cbfb9283d10f248976d28f8ab55b5d1c83ca1980 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Mon, 7 Jul 2025 17:24:43 -0400 Subject: [PATCH] fix: add safeguard in case server response is wrong --- src/puter-js/src/modules/KV.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/puter-js/src/modules/KV.js b/src/puter-js/src/modules/KV.js index 4c7383a70..2e43ca76e 100644 --- a/src/puter-js/src/modules/KV.js +++ b/src/puter-js/src/modules/KV.js @@ -51,6 +51,13 @@ class KV{ }), }); const arr_values = await resp.json(); + if ( ! Array.isArray(arr_values?.result) ) { + this.gui_cached.resolve({}); + setTimeout(() => { + this.gui_cached = null; + }, 4000); + return; + } const obj = {}; for (let i = 0; i < gui_cache_keys.length; i++) { obj[gui_cache_keys[i]] = arr_values.result[i];