Skip to content

Commit

Permalink
Catch transaction.done errors (#7984)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Jan 29, 2024
1 parent bf59c0a commit 3f8cbcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-drinks-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app': patch
---

Catch `transaction.done` errors in `readHeartbeatsFromIndexedDB` and log them as a warning, because platform logging errors should never throw or block user app functionality.
9 changes: 5 additions & 4 deletions packages/app/src/indexeddb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ export async function readHeartbeatsFromIndexedDB(
): Promise<HeartbeatsInIndexedDB | undefined> {
try {
const db = await getDbPromise();
const result = await db
.transaction(STORE_NAME)
.objectStore(STORE_NAME)
.get(computeKey(app));
const tx = db.transaction(STORE_NAME);
const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
// We already have the value but tx.done can throw,
// so we need to await it here to catch errors
await tx.done;
return result;
} catch (e) {
if (e instanceof FirebaseError) {
Expand Down

0 comments on commit 3f8cbcd

Please sign in to comment.