Skip to content

Commit

Permalink
Catch more heartbeat read/write errors (#7272)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored May 1, 2023
1 parent 8051e4a commit e0551fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-dolls-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app': patch
---

Catch more heartbeat read/write errors.
7 changes: 4 additions & 3 deletions packages/app/src/indexeddb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ export async function readHeartbeatsFromIndexedDB(
): Promise<HeartbeatsInIndexedDB | undefined> {
try {
const db = await getDbPromise();
return db
const result = await db
.transaction(STORE_NAME)
.objectStore(STORE_NAME)
.get(computeKey(app)) as Promise<HeartbeatsInIndexedDB | undefined>;
.get(computeKey(app));
return result;
} catch (e) {
if (e instanceof FirebaseError) {
logger.warn(e.message);
Expand All @@ -87,7 +88,7 @@ export async function writeHeartbeatsToIndexedDB(
const tx = db.transaction(STORE_NAME, 'readwrite');
const objectStore = tx.objectStore(STORE_NAME);
await objectStore.put(heartbeatObject, computeKey(app));
return tx.done;
await tx.done;
} catch (e) {
if (e instanceof FirebaseError) {
logger.warn(e.message);
Expand Down

0 comments on commit e0551fa

Please sign in to comment.