Skip to content

Commit

Permalink
Try caching the original req instead of clone
Browse files Browse the repository at this point in the history
Another guess for issue #32
  • Loading branch information
haukex committed Oct 13, 2024
1 parent 6c2f957 commit 812686d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/workers/dict-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ export async function loadDict(target :string[]): Promise<void> {
if (dictFromNet.ok && dictFromNet.body) console.debug(msg)
else throw new Error(msg)
// (clone because Response body can only be read once per request)
const dictForCache = dictFromNet.clone()
await response2lines(dictFromNet, progCb) // update the target with this response
await response2lines(dictFromNet.clone(), progCb) // update the target with this response
// don't store the response in cache until we know it was processed without error
cache.put(DB_URL, dictForCache) // save the response to the cache
cache.put(DB_URL, dictFromNet) // save the response to the cache
}

// Check if the dictionary is in the cache.
Expand Down

0 comments on commit 812686d

Please sign in to comment.