We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 25ffa0a commit e5c1d47Copy full SHA for e5c1d47
packages/idb-cache/src/index.ts
@@ -552,6 +552,16 @@ export class IDBCache implements AsyncStorage {
552
if (!this.dbReadyPromise) return;
553
await this.ensureWorkerInitialized();
554
555
+ // Check if the new item's chunks would exceed maxTotalChunks config
556
+ if (this.maxTotalChunks !== undefined) {
557
+ const newItemChunks = Math.ceil(value.length / this.chunkSize);
558
+ if (newItemChunks > this.maxTotalChunks) {
559
+ throw new IDBCacheError(
560
+ `Cannot store item: chunks needed (${newItemChunks}) exceeds maxTotalChunks (${this.maxTotalChunks})`
561
+ );
562
+ }
563
564
+
565
if (this.priority === "low") {
566
await waitForAnimationFrame();
567
}
0 commit comments