Skip to content

Commit

Permalink
fix(logging): prevent circular reference error in persistence logs
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
stephenjason89 committed Jan 15, 2025
1 parent bb43f41 commit e6b64b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function createStatePersistence<S extends StateTree = StateTree>(
return result
}
catch (error) {
log.error(`Failed to retrieve item ${key}: `, error)
log.error(`Failed to retrieve item ${key}:`, error)
}
}

Expand Down Expand Up @@ -126,7 +126,7 @@ export function createStatePersistence<S extends StateTree = StateTree>(
// 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
}

Expand All @@ -141,7 +141,7 @@ export function createStatePersistence<S extends StateTree = StateTree>(
}
}
catch (error) {
log.error(`Failed to persist state for key ${key}: `, error)
log.error(`Failed to persist state for key ${key}:`, error)
}
}

Expand Down

0 comments on commit e6b64b7

Please sign in to comment.