Skip to content

Commit 213480b

Browse files
leshniakclaude
andcommitted
fix: align comments and logs with actual behavior (drop cache, not close)
The heal path clears the cached dbp and reopens via indexedDB.open(), but does not call db.close() on the old IDBDatabase. Updated comments and log messages from 'close + reopen' to 'drop cached connection and reopen' to match what the code actually does. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a2c8ea7 commit 213480b

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/storage/providers/IDBKeyValProvider/createStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function createStore(dbName: string, storeName: string): UseStore {
109109
// Handles two recoverable error classes:
110110
// 1. InvalidStateError — connection closed between getDB() resolving and db.transaction().
111111
// Retry once with a fresh connection.
112-
// 2. Backing store corruption (Chromium UnknownError) — close + reopen the IDB connection.
112+
// 2. Backing store corruption (Chromium UnknownError) — drop cached connection and reopen the IDB connection.
113113
// Bounded by a shared heal budget (3 attempts, reset on success).
114114
// Mirrors Dexie's PR1398_maxLoop pattern: https://github.com/dexie/Dexie.js/blob/master/src/functions/temp-transaction.ts
115115
// Note: concurrent store() calls share the budget. Under overlapping failures each caller
@@ -132,7 +132,7 @@ function createStore(dbName: string, storeName: string): UseStore {
132132

133133
if (isBackingStoreError(error) && healAttemptsRemaining > 0) {
134134
healAttemptsRemaining--;
135-
Logger.logInfo('IDB heal: backing store error, attempting close + reopen', {
135+
Logger.logInfo('IDB heal: backing store error, attempting drop cached connection and reopen', {
136136
dbName,
137137
storeName,
138138
healAttemptsRemaining,

tests/unit/storage/providers/createStoreTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ describe('createStore', () => {
254254
return new DOMException('Internal error opening backing store for indexedDB.open.', 'UnknownError');
255255
}
256256

257-
it('should heal mid-session by closing and reopening the connection', async () => {
257+
it('should heal mid-session by dropping cached connection and reopening', async () => {
258258
const store = createStore(uniqueDBName(), STORE_NAME);
259259

260260
await store('readwrite', (s) => {
@@ -275,7 +275,7 @@ describe('createStore', () => {
275275
const result = await store('readonly', (s) => IDB.promisifyRequest(s.get('key1')));
276276
expect(result).toBe('value');
277277
expect(callCount).toBe(2);
278-
expect(logInfoSpy).toHaveBeenCalledWith('IDB heal: backing store error, attempting close + reopen', expect.objectContaining({healAttemptsRemaining: 2}));
278+
expect(logInfoSpy).toHaveBeenCalledWith('IDB heal: backing store error, attempting drop cached connection and reopen', expect.objectContaining({healAttemptsRemaining: 2}));
279279
});
280280

281281
it('should heal on init when indexedDB.open() rejects with UnknownError', async () => {

0 commit comments

Comments
 (0)