From 669df5824286462de9baa9cc19162c067291bd15 Mon Sep 17 00:00:00 2001 From: Adriana Jara <32825533+tropicadri@users.noreply.github.com> Date: Tue, 7 Sep 2021 11:30:41 -0700 Subject: [PATCH] changing durability to relaxed (#2934) * changing durability to be relaxed * fix bug * add QueueDB add to be durability relaxed --- packages/workbox-background-sync/src/lib/QueueDb.ts | 4 +++- .../workbox-expiration/src/models/CacheTimestampsModel.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/workbox-background-sync/src/lib/QueueDb.ts b/packages/workbox-background-sync/src/lib/QueueDb.ts index 19797c2ba..62517959b 100644 --- a/packages/workbox-background-sync/src/lib/QueueDb.ts +++ b/packages/workbox-background-sync/src/lib/QueueDb.ts @@ -56,7 +56,9 @@ export class QueueDb { */ async addEntry(entry: UnidentifiedQueueStoreEntry): Promise { const db = await this.getDb(); - await db.add(REQUEST_OBJECT_STORE_NAME, entry as QueueStoreEntry); + const tx = db.transaction(REQUEST_OBJECT_STORE_NAME, 'readwrite', { durability: 'relaxed' }); + await tx.store.add(entry as QueueStoreEntry); + await tx.done; } /** diff --git a/packages/workbox-expiration/src/models/CacheTimestampsModel.ts b/packages/workbox-expiration/src/models/CacheTimestampsModel.ts index c235a8297..3b5fe0c68 100644 --- a/packages/workbox-expiration/src/models/CacheTimestampsModel.ts +++ b/packages/workbox-expiration/src/models/CacheTimestampsModel.ts @@ -111,7 +111,9 @@ class CacheTimestampsModel { id: this._getId(url), }; const db = await this.getDb(); - await db.put(CACHE_OBJECT_STORE, entry); + const tx = db.transaction(CACHE_OBJECT_STORE, 'readwrite', {durability: 'relaxed'}); + await tx.store.put(entry); + await tx.done; } /**