Skip to content

Commit de95693

Browse files
Bruno-366Copilot
andauthored
wrapping the createObjectStore call in a try-catch block
The object store creation should be handled more defensively. Consider wrapping the createObjectStore call in a try-catch block since it can throw if the store already exists or if there are version conflicts. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f3cb49e commit de95693

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/storage.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ const openDB = (): Promise<IDBDatabase> => {
2929
request.onupgradeneeded = (event) => {
3030
const db = (event.target as IDBOpenDBRequest).result;
3131
if (!db.objectStoreNames.contains(STORE_NAME)) {
32-
db.createObjectStore(STORE_NAME);
32+
try {
33+
db.createObjectStore(STORE_NAME);
34+
} catch (e) {
35+
console.warn('Failed to create object store:', e);
36+
}
3337
}
3438
};
3539
});

0 commit comments

Comments
 (0)