From 8667c05902c3269c7795735e0b7ccc204e2ef59a Mon Sep 17 00:00:00 2001 From: Myles Scolnick Date: Tue, 19 Mar 2024 11:58:00 -0400 Subject: [PATCH] fix: infinite loop in parseUserConfig --- frontend/src/core/config/config-schema.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.ts index 86b3504fcea..e48b17010af 100644 --- a/frontend/src/core/config/config-schema.ts +++ b/frontend/src/core/config/config-schema.ts @@ -99,12 +99,16 @@ export function parseAppConfig() { } export function parseUserConfig(): UserConfig { - try { - // For Pyodide, we use the local storage to store the user config. - if (isPyodide()) { - return UserConfigLocalStorage.get(); - } + // For Pyodide, we use the local storage to store the user config. + if (isPyodide()) { + return UserConfigLocalStorage.get(); + } + return parseUserConfigDOM(); +} + +function parseUserConfigDOM(): UserConfig { + try { const parsed = UserConfigSchema.parse(JSON.parse(getRawMarimoUserConfig())); for (const [key, value] of Object.entries(parsed.experimental)) { if (value === true) { @@ -123,7 +127,7 @@ export function parseUserConfig(): UserConfig { export const UserConfigLocalStorage = new ZodLocalStorage( "marimo:user-config", UserConfigSchema, - () => parseUserConfig(), + () => parseUserConfigDOM(), ); function setFeatureFlag(