Skip to content

Commit 6445eaa

Browse files
leshniakclaude
andcommitted
fix: tighten error detection to handle DOMException not extending Error
In some environments DOMException does not inherit from Error. Use (error instanceof Error || error instanceof DOMException) for all three detection functions to avoid missing IDB errors in those envs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3fbb657 commit 6445eaa

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/storage/providers/IDBKeyValProvider/createStore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const HEAL_ATTEMPTS_MAX = 3;
1010
* internal recovery (RepairDB -> delete -> recreate) also fails.
1111
*/
1212
function isBackingStoreError(error: unknown): boolean {
13-
return error instanceof Error && error.message.includes('Internal error opening backing store');
13+
return (error instanceof Error || error instanceof DOMException) && (error as Error).message.includes('Internal error opening backing store');
1414
}
1515

1616
/**
@@ -19,13 +19,13 @@ function isBackingStoreError(error: unknown): boolean {
1919
* WebKit bugs: https://bugs.webkit.org/show_bug.cgi?id=197050, https://bugs.webkit.org/show_bug.cgi?id=201483
2020
*/
2121
function isConnectionLostError(error: unknown): boolean {
22-
if (!(error instanceof Error)) return false;
23-
const msg = error.message.toLowerCase();
22+
if (!(error instanceof Error || error instanceof DOMException)) return false;
23+
const msg = (error as Error).message.toLowerCase();
2424
return msg.includes('connection to indexed database server lost') || msg.includes('connection is closing');
2525
}
2626

2727
function isInvalidStateError(error: unknown): boolean {
28-
return error instanceof Error && error.name === 'InvalidStateError';
28+
return (error instanceof Error || error instanceof DOMException) && (error as Error).name === 'InvalidStateError';
2929
}
3030

3131
/** Errors that trigger a budgeted heal-and-retry in store(). */

0 commit comments

Comments
 (0)