From e6b64b75c6704f392640be7a8cd3ee938944370b Mon Sep 17 00:00:00 2001 From: Stephen Jason Wang Date: Thu, 16 Jan 2025 02:03:52 +0800 Subject: [PATCH] fix(logging): prevent circular reference error in persistence logs - Replaced JSON.stringify with direct logging for mutation objects - Resolved "Converting circular structure to JSON" error during persistence operations - Improved log compatibility with reactive Vue structures --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index e497123..40ee094 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,7 +70,7 @@ export function createStatePersistence( return result } catch (error) { - log.error(`Failed to retrieve item ${key}: `, error) + log.error(`Failed to retrieve item ${key}:`, error) } } @@ -126,7 +126,7 @@ export function createStatePersistence( // Persist state on mutation const persistState = (mutation: any, state: S) => { if (!filter(mutation, state) || isRestoringState) { - log.info(`Skipping persistence for store: ${context.store.$id}. Mutation: ${JSON.stringify(mutation)}`) + log.info(`Skipping persistence for store: ${context.store.$id}. Mutation:`, mutation) return } @@ -141,7 +141,7 @@ export function createStatePersistence( } } catch (error) { - log.error(`Failed to persist state for key ${key}: `, error) + log.error(`Failed to persist state for key ${key}:`, error) } }