Skip to content

Commit 3f8cbcd

Browse files
authored
Catch transaction.done errors (#7984)
1 parent bf59c0a commit 3f8cbcd

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.changeset/few-drinks-kiss.md

+5
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

+5-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ export async function readHeartbeatsFromIndexedDB(
6969
): Promise<HeartbeatsInIndexedDB | undefined> {
7070
try {
7171
const db = await getDbPromise();
72-
const result = await db
73-
.transaction(STORE_NAME)
74-
.objectStore(STORE_NAME)
75-
.get(computeKey(app));
72+
const tx = db.transaction(STORE_NAME);
73+
const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
74+
// We already have the value but tx.done can throw,
75+
// so we need to await it here to catch errors
76+
await tx.done;
7677
return result;
7778
} catch (e) {
7879
if (e instanceof FirebaseError) {

0 commit comments

Comments
 (0)