Skip to content

Commit 2d59567

Browse files
committed
Catch transaction.done errors
1 parent d8f4ea2 commit 2d59567

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/few-drinks-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/app': patch
3+
---
4+
5+
Catch `transaction.done` errors in `readHeartbeatsFromIndexedDB` and log them as a warning, because platform logging errors should never throw or block user app functionality.

packages/app/src/indexeddb.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ export async function readHeartbeatsFromIndexedDB(
6969
): Promise<HeartbeatsInIndexedDB | undefined> {
7070
try {
7171
const db = await getDbPromise();
72-
const result = await db
73-
.transaction(STORE_NAME)
72+
const tx = db.transaction(STORE_NAME);
73+
const result = await tx
7474
.objectStore(STORE_NAME)
7575
.get(computeKey(app));
76+
// We already have the value but tx.done can throw,
77+
// so we need to await it here to catch errors
78+
await tx.done;
7679
return result;
7780
} catch (e) {
7881
if (e instanceof FirebaseError) {

0 commit comments

Comments
 (0)