From db34ef01bf4c8144e50d27f29ebc3628d2c9394a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 8 Oct 2025 16:53:54 +0200 Subject: [PATCH] Fix IndexedDB in-line vs out-of-line key handling - Check if store has keyPath before calling put() - If keyPath exists (in-line keys), only pass value: store.put(value) - If no keyPath (out-of-line keys), pass both: store.put(value, key) - Apply fix to both set() and transaction.set() - Fixes DataError when saving sessions with keyPath: 'id' --- .../backends/indexeddb-storage-backend.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/web-ui/src/storage/backends/indexeddb-storage-backend.ts b/packages/web-ui/src/storage/backends/indexeddb-storage-backend.ts index 86fc144f..e6b9f040 100644 --- a/packages/web-ui/src/storage/backends/indexeddb-storage-backend.ts +++ b/packages/web-ui/src/storage/backends/indexeddb-storage-backend.ts @@ -64,7 +64,13 @@ export class IndexedDBStorageBackend implements StorageBackend { const db = await this.getDB(); const tx = db.transaction(storeName, "readwrite"); const store = tx.objectStore(storeName); - await this.promisifyRequest(store.put(value, key)); + // If store has keyPath, only pass value (in-line key) + // Otherwise pass both value and key (out-of-line key) + if (store.keyPath) { + await this.promisifyRequest(store.put(value)); + } else { + await this.promisifyRequest(store.put(value, key)); + } } async delete(storeName: string, key: string): Promise { @@ -121,7 +127,13 @@ export class IndexedDBStorageBackend implements StorageBackend { }, set: async (storeName: string, key: string, value: T) => { const store = idbTx.objectStore(storeName); - await this.promisifyRequest(store.put(value, key)); + // If store has keyPath, only pass value (in-line key) + // Otherwise pass both value and key (out-of-line key) + if (store.keyPath) { + await this.promisifyRequest(store.put(value)); + } else { + await this.promisifyRequest(store.put(value, key)); + } }, delete: async (storeName: string, key: string) => { const store = idbTx.objectStore(storeName);