@fireproof/core 0.17.4 → 0.17.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/README.md +3 -2
  2. package/dist/browser/fireproof.cjs +7 -3
  3. package/dist/browser/fireproof.cjs.map +1 -1
  4. package/dist/browser/fireproof.d.cts +1 -0
  5. package/dist/browser/fireproof.d.ts +1 -0
  6. package/dist/browser/fireproof.global.js +129 -96
  7. package/dist/browser/fireproof.global.js.map +1 -1
  8. package/dist/browser/fireproof.js +7 -3
  9. package/dist/browser/fireproof.js.map +1 -1
  10. package/dist/browser/metafile-cjs.json +1 -1
  11. package/dist/browser/metafile-esm.json +1 -1
  12. package/dist/browser/metafile-iife.json +1 -1
  13. package/dist/memory/fireproof.cjs +7 -3
  14. package/dist/memory/fireproof.cjs.map +1 -1
  15. package/dist/memory/fireproof.d.cts +1 -0
  16. package/dist/memory/fireproof.d.ts +1 -0
  17. package/dist/memory/fireproof.global.js +129 -96
  18. package/dist/memory/fireproof.global.js.map +1 -1
  19. package/dist/memory/fireproof.js +7 -3
  20. package/dist/memory/fireproof.js.map +1 -1
  21. package/dist/memory/metafile-cjs.json +1 -1
  22. package/dist/memory/metafile-esm.json +1 -1
  23. package/dist/memory/metafile-iife.json +1 -1
  24. package/dist/node/fireproof.cjs +7 -3
  25. package/dist/node/fireproof.cjs.map +1 -1
  26. package/dist/node/fireproof.d.cts +1 -0
  27. package/dist/node/fireproof.d.ts +1 -0
  28. package/dist/node/fireproof.global.js +129 -96
  29. package/dist/node/fireproof.global.js.map +1 -1
  30. package/dist/node/fireproof.js +7 -3
  31. package/dist/node/fireproof.js.map +1 -1
  32. package/dist/node/metafile-cjs.json +1 -1
  33. package/dist/node/metafile-esm.json +1 -1
  34. package/dist/node/metafile-iife.json +1 -1
  35. package/package.json +3 -3
@@ -4089,7 +4089,7 @@ var Fireproof = (() => {
4089
4089
  };
4090
4090
  var parse = (source, base4) => CID.parse(source, base4);
4091
4091
 
4092
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.0/node_modules/@web3-storage/pail/src/block.js
4092
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/block.js
4093
4093
  var MemoryBlockstore = class {
4094
4094
  /** @type {Map<string, Uint8Array>} */
4095
4095
  #blocks = /* @__PURE__ */ new Map();
@@ -4136,6 +4136,22 @@ var Fireproof = (() => {
4136
4136
  }
4137
4137
  }
4138
4138
  };
4139
+ var MultiBlockFetcher = class {
4140
+ /** @type {API.BlockFetcher[]} */
4141
+ #fetchers;
4142
+ /** @param {API.BlockFetcher[]} fetchers */
4143
+ constructor(...fetchers) {
4144
+ this.#fetchers = fetchers;
4145
+ }
4146
+ /** @type {API.BlockFetcher['get']} */
4147
+ async get(link2) {
4148
+ for (const f of this.#fetchers) {
4149
+ const v = await f.get(link2);
4150
+ if (v)
4151
+ return v;
4152
+ }
4153
+ }
4154
+ };
4139
4155
 
4140
4156
  // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
4141
4157
  var Node = class {
@@ -10013,7 +10029,7 @@ You can use close({ resize: true }) to resize header`);
10013
10029
  }
10014
10030
  return bytes;
10015
10031
  }
10016
- var PACKAGE_VERSION = "0.17.3";
10032
+ var PACKAGE_VERSION = "0.17.5";
10017
10033
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
10018
10034
  if (!match)
10019
10035
  throw new Error("invalid version: " + PACKAGE_VERSION);
@@ -10083,6 +10099,7 @@ You can use close({ resize: true }) to resize header`);
10083
10099
  key;
10084
10100
  keyId;
10085
10101
  seenCompacted = /* @__PURE__ */ new Set();
10102
+ processedCars = /* @__PURE__ */ new Set();
10086
10103
  writing = Promise.resolve();
10087
10104
  getBlockCache = /* @__PURE__ */ new Map();
10088
10105
  seenMeta = /* @__PURE__ */ new Set();
@@ -10171,7 +10188,7 @@ You can use close({ resize: true }) to resize header`);
10171
10188
  // can these skip the queue? or have a file queue?
10172
10189
  async _commitInternalFiles(t, done, opts = { noLoader: false, compact: false }) {
10173
10190
  await this.ready;
10174
- const { files: roots } = this.makeFileCarHeader(done, this.carLog, !!opts.compact);
10191
+ const { files: roots } = this.makeFileCarHeader(done);
10175
10192
  const { cid, bytes } = await this.prepareCarFile(roots[0], t, !!opts.public);
10176
10193
  await this.fileStore.save({ cid, bytes });
10177
10194
  await this.remoteWAL.enqueueFile(cid, !!opts.public);
@@ -10191,7 +10208,10 @@ You can use close({ resize: true }) to resize header`);
10191
10208
  }
10192
10209
  }
10193
10210
  }
10194
- async cacheCarReader(reader) {
10211
+ async cacheCarReader(carCidStr, reader) {
10212
+ if (this.processedCars.has(carCidStr))
10213
+ return;
10214
+ this.processedCars.add(carCidStr);
10195
10215
  for await (const block of reader.blocks()) {
10196
10216
  const sBlock = block.cid.toString();
10197
10217
  if (!this.getBlockCache.has(sBlock)) {
@@ -10221,7 +10241,7 @@ You can use close({ resize: true }) to resize header`);
10221
10241
  const theKey = isPublic ? null : await this._getKey();
10222
10242
  return theKey && this.ebOpts.crypto ? await encryptedEncodeCarFile(this.ebOpts.crypto, theKey, root2, t) : await encodeCarFile([root2], t);
10223
10243
  }
10224
- makeFileCarHeader(result, cars, compact = false) {
10244
+ makeFileCarHeader(result) {
10225
10245
  const files = [];
10226
10246
  for (const [, meta] of Object.entries(result.files)) {
10227
10247
  if (meta && typeof meta === "object" && "cid" in meta && meta !== null) {
@@ -10256,10 +10276,27 @@ You can use close({ resize: true }) to resize header`);
10256
10276
  // await this.remoteWAL!.enqueue(dbMeta, { public: false })
10257
10277
  // }
10258
10278
  // }
10259
- async *entries() {
10279
+ async *entries(cache22 = true) {
10260
10280
  await this.ready;
10261
- for (const [, block] of this.getBlockCache) {
10262
- yield block;
10281
+ if (cache22) {
10282
+ for (const [, block] of this.getBlockCache) {
10283
+ yield block;
10284
+ }
10285
+ } else {
10286
+ for (const [, block] of this.getBlockCache) {
10287
+ yield block;
10288
+ }
10289
+ for (const cid of this.carLog) {
10290
+ const reader = await this.loadCar(cid);
10291
+ if (!reader)
10292
+ throw new Error(`missing car reader ${cid.toString()}`);
10293
+ for await (const block of reader.blocks()) {
10294
+ const sCid = block.cid.toString();
10295
+ if (!this.getBlockCache.has(sCid)) {
10296
+ yield block;
10297
+ }
10298
+ }
10299
+ }
10263
10300
  }
10264
10301
  }
10265
10302
  async getBlock(cid) {
@@ -10272,11 +10309,37 @@ You can use close({ resize: true }) to resize header`);
10272
10309
  if (!reader) {
10273
10310
  throw new Error(`missing car reader ${carCid.toString()}`);
10274
10311
  }
10275
- await this.cacheCarReader(reader);
10312
+ await this.cacheCarReader(carCid.toString(), reader).catch((e) => {
10313
+ });
10276
10314
  if (this.getBlockCache.has(sCid))
10277
10315
  return this.getBlockCache.get(sCid);
10278
10316
  throw new Error(`block not in reader: ${cid.toString()}`);
10279
10317
  };
10318
+ const getCompactCarCids = async (carCid) => {
10319
+ const reader = await this.loadCar(carCid);
10320
+ if (!reader) {
10321
+ throw new Error(`missing car reader ${carCid.toString()}`);
10322
+ }
10323
+ const header = await parseCarFile(reader);
10324
+ const compacts = header.compact;
10325
+ let got2;
10326
+ const batchSize2 = 5;
10327
+ for (let i = 0; i < compacts.length; i += batchSize2) {
10328
+ const promises = [];
10329
+ for (let j = i; j < Math.min(i + batchSize2, compacts.length); j++) {
10330
+ promises.push(getCarCid(compacts[j]));
10331
+ }
10332
+ try {
10333
+ got2 = await Promise.any(promises);
10334
+ } catch {
10335
+ }
10336
+ if (got2)
10337
+ break;
10338
+ }
10339
+ if (this.getBlockCache.has(sCid))
10340
+ return this.getBlockCache.get(sCid);
10341
+ throw new Error(`block not in compact reader: ${cid.toString()}`);
10342
+ };
10280
10343
  let got;
10281
10344
  const batchSize = 5;
10282
10345
  for (let i = 0; i < this.carLog.length; i += batchSize) {
@@ -10291,8 +10354,19 @@ You can use close({ resize: true }) to resize header`);
10291
10354
  if (got)
10292
10355
  break;
10293
10356
  }
10294
- if (got) {
10295
- this.getBlockCache.set(sCid, got);
10357
+ if (!got) {
10358
+ for (let i = 0; i < this.carLog.length; i += batchSize) {
10359
+ const promises = [];
10360
+ for (let j = i; j < Math.min(i + batchSize, this.carLog.length); j++) {
10361
+ promises.push(getCompactCarCids(this.carLog[j]));
10362
+ }
10363
+ try {
10364
+ got = await Promise.any(promises);
10365
+ } catch {
10366
+ }
10367
+ if (got)
10368
+ break;
10369
+ }
10296
10370
  }
10297
10371
  return got;
10298
10372
  }
@@ -10399,6 +10473,7 @@ You can use close({ resize: true }) to resize header`);
10399
10473
  compacting = false;
10400
10474
  ebOpts;
10401
10475
  transactions = /* @__PURE__ */ new Set();
10476
+ lastTxMeta = null;
10402
10477
  constructor(ebOpts) {
10403
10478
  this.ebOpts = ebOpts;
10404
10479
  const { name: name7 } = ebOpts;
@@ -10413,6 +10488,7 @@ You can use close({ resize: true }) to resize header`);
10413
10488
  async transaction(fn, opts = { noLoader: false }) {
10414
10489
  const t = new CarTransaction(this);
10415
10490
  const done = await fn(t);
10491
+ this.lastTxMeta = done;
10416
10492
  if (this.loader) {
10417
10493
  const car = await this.loader.commit(t, done, opts);
10418
10494
  if (this.ebOpts.autoCompact && this.loader.carLog.length > this.ebOpts.autoCompact) {
@@ -10458,7 +10534,7 @@ You can use close({ resize: true }) to resize header`);
10458
10534
  throw new Error("loader required to compact");
10459
10535
  if (this.loader.carLog.length < 2)
10460
10536
  return;
10461
- const compactFn = this.ebOpts.compact;
10537
+ const compactFn = this.ebOpts.compact || ((blocks) => this.defaultCompact(blocks));
10462
10538
  if (!compactFn || this.compacting)
10463
10539
  return;
10464
10540
  const blockLog = new CompactionFetcher(this);
@@ -10470,6 +10546,23 @@ You can use close({ resize: true }) to resize header`);
10470
10546
  });
10471
10547
  this.compacting = false;
10472
10548
  }
10549
+ async defaultCompact(blocks) {
10550
+ if (!this.loader) {
10551
+ throw new Error("no loader");
10552
+ }
10553
+ if (!this.lastTxMeta) {
10554
+ throw new Error("no lastTxMeta");
10555
+ }
10556
+ for await (const blk of this.loader.entries(false)) {
10557
+ blocks.loggedBlocks.putSync(blk.cid, blk.bytes);
10558
+ }
10559
+ for (const t of this.transactions) {
10560
+ for await (const blk of t.entries()) {
10561
+ blocks.loggedBlocks.putSync(blk.cid, blk.bytes);
10562
+ }
10563
+ }
10564
+ return this.lastTxMeta;
10565
+ }
10473
10566
  async *entries() {
10474
10567
  const seen = /* @__PURE__ */ new Set();
10475
10568
  if (this.loader) {
@@ -18768,7 +18861,7 @@ ${key.data.toString("base64")}
18768
18861
  var import_path = __require("path");
18769
18862
  var import_os = __require("os");
18770
18863
  var import_promises = __require("fs/promises");
18771
- var PACKAGE_VERSION2 = "0.17.3";
18864
+ var PACKAGE_VERSION2 = "0.17.5";
18772
18865
  var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
18773
18866
  if (!match2)
18774
18867
  throw new Error("invalid version: " + PACKAGE_VERSION2);
@@ -18906,7 +18999,7 @@ ${key.data.toString("base64")}
18906
18999
  const car = await this.loader.carStore.load(dbMeta.car).catch(() => null);
18907
19000
  if (!car) {
18908
19001
  if (cidListIncludes2(this.loader.carLog, dbMeta.car))
18909
- throw new Error(`missing car ${dbMeta.car.toString()}`);
19002
+ throw new Error(`missing local car ${dbMeta.car.toString()}`);
18910
19003
  } else {
18911
19004
  await this.loader.remoteCarStore.save(car);
18912
19005
  }
@@ -18919,7 +19012,7 @@ ${key.data.toString("base64")}
18919
19012
  const car = await this.loader.carStore.load(dbMeta.car).catch(() => null);
18920
19013
  if (!car) {
18921
19014
  if (cidListIncludes2(this.loader.carLog, dbMeta.car))
18922
- throw new Error(`missing car ${dbMeta.car.toString()}`);
19015
+ throw new Error(`missing local car ${dbMeta.car.toString()}`);
18923
19016
  } else {
18924
19017
  await this.loader.remoteCarStore.save(car);
18925
19018
  }
@@ -18944,7 +19037,7 @@ ${key.data.toString("base64")}
18944
19037
  const res = await Promise.allSettled(uploads);
18945
19038
  const errors = res.filter((r) => r.status === "rejected");
18946
19039
  if (errors.length) {
18947
- console.error("error uploading", JSON.stringify(errors));
19040
+ console.error("error uploading", JSON.stringify(errors.map((e) => e.reason)));
18948
19041
  throw errors[0].reason;
18949
19042
  }
18950
19043
  if (operations.length) {
@@ -19034,7 +19127,7 @@ ${key.data.toString("base64")}
19034
19127
  return await (0, import_promises.writeFile)(path, data);
19035
19128
  }
19036
19129
 
19037
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/clock/index.js
19130
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/clock/index.js
19038
19131
  var advance = async (blocks, head, event) => {
19039
19132
  const events = new EventFetcher(blocks);
19040
19133
  const headmap = new Map(head.map((cid) => [cid.toString(), cid]));
@@ -19160,7 +19253,7 @@ ${key.data.toString("base64")}
19160
19253
  };
19161
19254
  var shortLink = (l) => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`;
19162
19255
 
19163
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/shard.js
19256
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/shard.js
19164
19257
  var MaxKeyLength = 64;
19165
19258
  var MaxShardSize = 512 * 1024;
19166
19259
  var CID_TAG2 = new Token(Type.tag, 42);
@@ -19292,7 +19385,7 @@ ${key.data.toString("base64")}
19292
19385
  }
19293
19386
  };
19294
19387
 
19295
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/index.js
19388
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/index.js
19296
19389
  var put = async (blocks, root2, key, value) => {
19297
19390
  const shards = new ShardFetcher(blocks);
19298
19391
  const rshard = await shards.get(root2);
@@ -19495,71 +19588,7 @@ ${key.data.toString("base64")}
19495
19588
  return [shard];
19496
19589
  };
19497
19590
 
19498
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/block.js
19499
- var MemoryBlockstore2 = class {
19500
- /** @type {Map<string, Uint8Array>} */
19501
- #blocks = /* @__PURE__ */ new Map();
19502
- /**
19503
- * @param {Array<import('multiformats').Block>} [blocks]
19504
- */
19505
- constructor(blocks) {
19506
- if (blocks) {
19507
- this.#blocks = new Map(blocks.map((b) => [b.cid.toString(), b.bytes]));
19508
- }
19509
- }
19510
- /** @type {API.BlockFetcher['get']} */
19511
- async get(cid) {
19512
- const bytes = this.#blocks.get(cid.toString());
19513
- if (!bytes)
19514
- return;
19515
- return { cid, bytes };
19516
- }
19517
- /**
19518
- * @param {API.UnknownLink} cid
19519
- * @param {Uint8Array} bytes
19520
- */
19521
- async put(cid, bytes) {
19522
- this.#blocks.set(cid.toString(), bytes);
19523
- }
19524
- /**
19525
- * @param {API.UnknownLink} cid
19526
- * @param {Uint8Array} bytes
19527
- */
19528
- putSync(cid, bytes) {
19529
- this.#blocks.set(cid.toString(), bytes);
19530
- }
19531
- /** @param {API.UnknownLink} cid */
19532
- async delete(cid) {
19533
- this.#blocks.delete(cid.toString());
19534
- }
19535
- /** @param {API.UnknownLink} cid */
19536
- deleteSync(cid) {
19537
- this.#blocks.delete(cid.toString());
19538
- }
19539
- *entries() {
19540
- for (const [str, bytes] of this.#blocks) {
19541
- yield { cid: parse(str), bytes };
19542
- }
19543
- }
19544
- };
19545
- var MultiBlockFetcher = class {
19546
- /** @type {API.BlockFetcher[]} */
19547
- #fetchers;
19548
- /** @param {API.BlockFetcher[]} fetchers */
19549
- constructor(...fetchers) {
19550
- this.#fetchers = fetchers;
19551
- }
19552
- /** @type {API.BlockFetcher['get']} */
19553
- async get(link2) {
19554
- for (const f of this.#fetchers) {
19555
- const v = await f.get(link2);
19556
- if (v)
19557
- return v;
19558
- }
19559
- }
19560
- };
19561
-
19562
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/shard.js
19591
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/shard.js
19563
19592
  var ShardLinkByteLength = 36;
19564
19593
  var CID_TAG3 = new Token(Type.tag, 42);
19565
19594
  var create8 = (init2) => ({
@@ -19606,7 +19635,7 @@ ${key.data.toString("base64")}
19606
19635
  return tokensToLength(tokens);
19607
19636
  };
19608
19637
 
19609
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/index.js
19638
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/index.js
19610
19639
  var Batcher = class _Batcher {
19611
19640
  #committed = false;
19612
19641
  /**
@@ -19788,9 +19817,9 @@ ${key.data.toString("base64")}
19788
19817
  static code = "ERR_BATCH_COMMITTED";
19789
19818
  };
19790
19819
 
19791
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/index.js
19820
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/index.js
19792
19821
  var put3 = async (blocks, head, key, value) => {
19793
- const mblocks = new MemoryBlockstore2();
19822
+ const mblocks = new MemoryBlockstore();
19794
19823
  blocks = new MultiBlockFetcher(mblocks, blocks);
19795
19824
  if (!head.length) {
19796
19825
  const shard = await ShardBlock.create();
@@ -19874,7 +19903,7 @@ ${key.data.toString("base64")}
19874
19903
  var root = async (blocks, head) => {
19875
19904
  if (!head.length)
19876
19905
  throw new Error("cannot determine root of headless clock");
19877
- const mblocks = new MemoryBlockstore2();
19906
+ const mblocks = new MemoryBlockstore();
19878
19907
  blocks = new MultiBlockFetcher(mblocks, blocks);
19879
19908
  const events = new EventFetcher(blocks);
19880
19909
  if (head.length === 1) {
@@ -19933,7 +19962,7 @@ ${key.data.toString("base64")}
19933
19962
  return;
19934
19963
  const result = await root(blocks, head);
19935
19964
  if (result.additions.length) {
19936
- blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
19965
+ blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
19937
19966
  }
19938
19967
  return get2(blocks, result.root, key);
19939
19968
  };
@@ -19942,7 +19971,7 @@ ${key.data.toString("base64")}
19942
19971
  return;
19943
19972
  const result = await root(blocks, head);
19944
19973
  if (result.additions.length) {
19945
- blocks = new MultiBlockFetcher(new MemoryBlockstore2(result.additions), blocks);
19974
+ blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
19946
19975
  }
19947
19976
  yield* entries(blocks, result.root, options);
19948
19977
  };
@@ -20026,7 +20055,7 @@ ${key.data.toString("base64")}
20026
20055
  return acc.concat(...rest);
20027
20056
  };
20028
20057
 
20029
- // ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/crdt/batch/index.js
20058
+ // ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/batch/index.js
20030
20059
  var Batcher2 = class _Batcher {
20031
20060
  #committed = false;
20032
20061
  /**
@@ -20071,7 +20100,7 @@ ${key.data.toString("base64")}
20071
20100
  const res = await commit(this);
20072
20101
  const data = { type: "batch", ops: this.ops, root: res.root };
20073
20102
  const event = await EventBlock.create(data, this.head);
20074
- const mblocks = new MemoryBlockstore2();
20103
+ const mblocks = new MemoryBlockstore();
20075
20104
  const blocks = new MultiBlockFetcher(mblocks, this.blocks);
20076
20105
  mblocks.putSync(event.cid, event.bytes);
20077
20106
  const head = await advance(blocks, this.head, event.cid);
@@ -20111,7 +20140,7 @@ ${key.data.toString("base64")}
20111
20140
  * @param {string} init.prefix
20112
20141
  */
20113
20142
  static async create({ blocks, head, prefix }) {
20114
- const mblocks = new MemoryBlockstore2();
20143
+ const mblocks = new MemoryBlockstore();
20115
20144
  blocks = new MultiBlockFetcher(mblocks, blocks);
20116
20145
  if (!head.length) {
20117
20146
  const base5 = await ShardBlock.create();
@@ -28771,7 +28800,6 @@ ${key.data.toString("base64")}
28771
28800
  var isCompacting = false;
28772
28801
  async function doCompact(blockLog, head) {
28773
28802
  if (isCompacting) {
28774
- console.log("already compacting");
28775
28803
  return;
28776
28804
  }
28777
28805
  isCompacting = true;
@@ -29478,7 +29506,10 @@ ${key.data.toString("base64")}
29478
29506
  const task = queue.shift();
29479
29507
  if (!task)
29480
29508
  continue;
29481
- await worker(task.newHead, task.prevHead, task.updates !== null);
29509
+ await worker(task.newHead, task.prevHead, task.updates !== null).catch((e) => {
29510
+ console.error("int_applyHead worker error", e);
29511
+ throw e;
29512
+ });
29482
29513
  if (task.updates) {
29483
29514
  allUpdates.push(...task.updates);
29484
29515
  }
@@ -29501,6 +29532,9 @@ ${key.data.toString("base64")}
29501
29532
  push(task) {
29502
29533
  queue.push(task);
29503
29534
  return process2();
29535
+ },
29536
+ size() {
29537
+ return queue.length;
29504
29538
  }
29505
29539
  };
29506
29540
  }
@@ -29602,7 +29636,6 @@ ${key.data.toString("base64")}
29602
29636
  try {
29603
29637
  head = await advance(tblocks, head, cid);
29604
29638
  } catch (e) {
29605
- console.log("failed to advance head:", cid.toString());
29606
29639
  continue;
29607
29640
  }
29608
29641
  }