@fireproof/core 0.19.11-dev-dryrun6 → 0.19.99-dev-100

Sign up to get free protection for your applications and to get access to all the features.
package/index.global.js CHANGED
@@ -12614,6 +12614,237 @@ ${end.comment}` : end.comment;
12614
12614
  }
12615
12615
  });
12616
12616
 
12617
+ // node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
12618
+ var require_retry_operation = __commonJS({
12619
+ "node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
12620
+ "use strict";
12621
+ function RetryOperation(timeouts, options) {
12622
+ if (typeof options === "boolean") {
12623
+ options = { forever: options };
12624
+ }
12625
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
12626
+ this._timeouts = timeouts;
12627
+ this._options = options || {};
12628
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
12629
+ this._fn = null;
12630
+ this._errors = [];
12631
+ this._attempts = 1;
12632
+ this._operationTimeout = null;
12633
+ this._operationTimeoutCb = null;
12634
+ this._timeout = null;
12635
+ this._operationStart = null;
12636
+ this._timer = null;
12637
+ if (this._options.forever) {
12638
+ this._cachedTimeouts = this._timeouts.slice(0);
12639
+ }
12640
+ }
12641
+ module2.exports = RetryOperation;
12642
+ RetryOperation.prototype.reset = function() {
12643
+ this._attempts = 1;
12644
+ this._timeouts = this._originalTimeouts.slice(0);
12645
+ };
12646
+ RetryOperation.prototype.stop = function() {
12647
+ if (this._timeout) {
12648
+ clearTimeout(this._timeout);
12649
+ }
12650
+ if (this._timer) {
12651
+ clearTimeout(this._timer);
12652
+ }
12653
+ this._timeouts = [];
12654
+ this._cachedTimeouts = null;
12655
+ };
12656
+ RetryOperation.prototype.retry = function(err) {
12657
+ if (this._timeout) {
12658
+ clearTimeout(this._timeout);
12659
+ }
12660
+ if (!err) {
12661
+ return false;
12662
+ }
12663
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
12664
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
12665
+ this._errors.push(err);
12666
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
12667
+ return false;
12668
+ }
12669
+ this._errors.push(err);
12670
+ var timeout = this._timeouts.shift();
12671
+ if (timeout === void 0) {
12672
+ if (this._cachedTimeouts) {
12673
+ this._errors.splice(0, this._errors.length - 1);
12674
+ timeout = this._cachedTimeouts.slice(-1);
12675
+ } else {
12676
+ return false;
12677
+ }
12678
+ }
12679
+ var self2 = this;
12680
+ this._timer = setTimeout(function() {
12681
+ self2._attempts++;
12682
+ if (self2._operationTimeoutCb) {
12683
+ self2._timeout = setTimeout(function() {
12684
+ self2._operationTimeoutCb(self2._attempts);
12685
+ }, self2._operationTimeout);
12686
+ if (self2._options.unref) {
12687
+ self2._timeout.unref();
12688
+ }
12689
+ }
12690
+ self2._fn(self2._attempts);
12691
+ }, timeout);
12692
+ if (this._options.unref) {
12693
+ this._timer.unref();
12694
+ }
12695
+ return true;
12696
+ };
12697
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
12698
+ this._fn = fn;
12699
+ if (timeoutOps) {
12700
+ if (timeoutOps.timeout) {
12701
+ this._operationTimeout = timeoutOps.timeout;
12702
+ }
12703
+ if (timeoutOps.cb) {
12704
+ this._operationTimeoutCb = timeoutOps.cb;
12705
+ }
12706
+ }
12707
+ var self2 = this;
12708
+ if (this._operationTimeoutCb) {
12709
+ this._timeout = setTimeout(function() {
12710
+ self2._operationTimeoutCb();
12711
+ }, self2._operationTimeout);
12712
+ }
12713
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
12714
+ this._fn(this._attempts);
12715
+ };
12716
+ RetryOperation.prototype.try = function(fn) {
12717
+ console.log("Using RetryOperation.try() is deprecated");
12718
+ this.attempt(fn);
12719
+ };
12720
+ RetryOperation.prototype.start = function(fn) {
12721
+ console.log("Using RetryOperation.start() is deprecated");
12722
+ this.attempt(fn);
12723
+ };
12724
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
12725
+ RetryOperation.prototype.errors = function() {
12726
+ return this._errors;
12727
+ };
12728
+ RetryOperation.prototype.attempts = function() {
12729
+ return this._attempts;
12730
+ };
12731
+ RetryOperation.prototype.mainError = function() {
12732
+ if (this._errors.length === 0) {
12733
+ return null;
12734
+ }
12735
+ var counts = {};
12736
+ var mainError = null;
12737
+ var mainErrorCount = 0;
12738
+ for (var i = 0; i < this._errors.length; i++) {
12739
+ var error = this._errors[i];
12740
+ var message2 = error.message;
12741
+ var count = (counts[message2] || 0) + 1;
12742
+ counts[message2] = count;
12743
+ if (count >= mainErrorCount) {
12744
+ mainError = error;
12745
+ mainErrorCount = count;
12746
+ }
12747
+ }
12748
+ return mainError;
12749
+ };
12750
+ }
12751
+ });
12752
+
12753
+ // node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
12754
+ var require_retry = __commonJS({
12755
+ "node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
12756
+ "use strict";
12757
+ var RetryOperation = require_retry_operation();
12758
+ exports2.operation = function(options) {
12759
+ var timeouts = exports2.timeouts(options);
12760
+ return new RetryOperation(timeouts, {
12761
+ forever: options && (options.forever || options.retries === Infinity),
12762
+ unref: options && options.unref,
12763
+ maxRetryTime: options && options.maxRetryTime
12764
+ });
12765
+ };
12766
+ exports2.timeouts = function(options) {
12767
+ if (options instanceof Array) {
12768
+ return [].concat(options);
12769
+ }
12770
+ var opts = {
12771
+ retries: 10,
12772
+ factor: 2,
12773
+ minTimeout: 1 * 1e3,
12774
+ maxTimeout: Infinity,
12775
+ randomize: false
12776
+ };
12777
+ for (var key in options) {
12778
+ opts[key] = options[key];
12779
+ }
12780
+ if (opts.minTimeout > opts.maxTimeout) {
12781
+ throw new Error("minTimeout is greater than maxTimeout");
12782
+ }
12783
+ var timeouts = [];
12784
+ for (var i = 0; i < opts.retries; i++) {
12785
+ timeouts.push(this.createTimeout(i, opts));
12786
+ }
12787
+ if (options && options.forever && !timeouts.length) {
12788
+ timeouts.push(this.createTimeout(i, opts));
12789
+ }
12790
+ timeouts.sort(function(a, b) {
12791
+ return a - b;
12792
+ });
12793
+ return timeouts;
12794
+ };
12795
+ exports2.createTimeout = function(attempt, opts) {
12796
+ var random = opts.randomize ? Math.random() + 1 : 1;
12797
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
12798
+ timeout = Math.min(timeout, opts.maxTimeout);
12799
+ return timeout;
12800
+ };
12801
+ exports2.wrap = function(obj, options, methods) {
12802
+ if (options instanceof Array) {
12803
+ methods = options;
12804
+ options = null;
12805
+ }
12806
+ if (!methods) {
12807
+ methods = [];
12808
+ for (var key in obj) {
12809
+ if (typeof obj[key] === "function") {
12810
+ methods.push(key);
12811
+ }
12812
+ }
12813
+ }
12814
+ for (var i = 0; i < methods.length; i++) {
12815
+ var method = methods[i];
12816
+ var original = obj[method];
12817
+ obj[method] = function retryWrapper(original2) {
12818
+ var op = exports2.operation(options);
12819
+ var args = Array.prototype.slice.call(arguments, 1);
12820
+ var callback = args.pop();
12821
+ args.push(function(err) {
12822
+ if (op.retry(err)) {
12823
+ return;
12824
+ }
12825
+ if (err) {
12826
+ arguments[0] = op.mainError();
12827
+ }
12828
+ callback.apply(this, arguments);
12829
+ });
12830
+ op.attempt(function() {
12831
+ original2.apply(obj, args);
12832
+ });
12833
+ }.bind(obj, original);
12834
+ obj[method].options = options;
12835
+ }
12836
+ };
12837
+ }
12838
+ });
12839
+
12840
+ // node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
12841
+ var require_retry2 = __commonJS({
12842
+ "node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
12843
+ "use strict";
12844
+ module2.exports = require_retry();
12845
+ }
12846
+ });
12847
+
12617
12848
  // src/runtime/gateways/indexdb/version.ts
12618
12849
  var INDEXDB_VERSION;
12619
12850
  var init_version = __esm({
@@ -24772,6 +25003,29 @@ ${end.comment}` : end.comment;
24772
25003
  }
24773
25004
  };
24774
25005
 
25006
+ // src/blockstore/store.ts
25007
+ init_cement();
25008
+
25009
+ // src/types.ts
25010
+ function isFalsy(value) {
25011
+ return value === false && value === null && value === void 0;
25012
+ }
25013
+ function throwFalsy(value) {
25014
+ if (isFalsy(value)) {
25015
+ throw new Error("value is Falsy");
25016
+ }
25017
+ return value;
25018
+ }
25019
+ function falsyToUndef(value) {
25020
+ if (isFalsy(value)) {
25021
+ return void 0;
25022
+ }
25023
+ return value;
25024
+ }
25025
+
25026
+ // src/blockstore/store.ts
25027
+ init_utils();
25028
+
24775
25029
  // node_modules/.pnpm/yocto-queue@1.1.1/node_modules/yocto-queue/index.js
24776
25030
  var Node2 = class {
24777
25031
  value;
@@ -24903,29 +25157,6 @@ ${end.comment}` : end.comment;
24903
25157
  }
24904
25158
  }
24905
25159
 
24906
- // src/blockstore/store.ts
24907
- init_cement();
24908
-
24909
- // src/types.ts
24910
- function isFalsy(value) {
24911
- return value === false && value === null && value === void 0;
24912
- }
24913
- function throwFalsy(value) {
24914
- if (isFalsy(value)) {
24915
- throw new Error("value is Falsy");
24916
- }
24917
- return value;
24918
- }
24919
- function falsyToUndef(value) {
24920
- if (isFalsy(value)) {
24921
- return void 0;
24922
- }
24923
- return value;
24924
- }
24925
-
24926
- // src/blockstore/store.ts
24927
- init_utils();
24928
-
24929
25160
  // node_modules/.pnpm/@ipld+car@5.3.2/node_modules/@ipld/car/src/decoder-common.js
24930
25161
  var import_varint2 = __toESM(require_varint(), 1);
24931
25162
  var CIDV0_BYTES = {
@@ -27111,6 +27342,232 @@ You can use close({ resize: true }) to resize header`);
27111
27342
  return sthis.txt.encode(JSON.stringify(crdtEntries));
27112
27343
  }
27113
27344
 
27345
+ // node_modules/.pnpm/p-retry@6.2.0/node_modules/p-retry/index.js
27346
+ var import_retry = __toESM(require_retry2(), 1);
27347
+
27348
+ // node_modules/.pnpm/is-network-error@1.1.0/node_modules/is-network-error/index.js
27349
+ var objectToString = Object.prototype.toString;
27350
+ var isError = (value) => objectToString.call(value) === "[object Error]";
27351
+ var errorMessages = /* @__PURE__ */ new Set([
27352
+ "network error",
27353
+ // Chrome
27354
+ "Failed to fetch",
27355
+ // Chrome
27356
+ "NetworkError when attempting to fetch resource.",
27357
+ // Firefox
27358
+ "The Internet connection appears to be offline.",
27359
+ // Safari 16
27360
+ "Load failed",
27361
+ // Safari 17+
27362
+ "Network request failed",
27363
+ // `cross-fetch`
27364
+ "fetch failed",
27365
+ // Undici (Node.js)
27366
+ "terminated"
27367
+ // Undici (Node.js)
27368
+ ]);
27369
+ function isNetworkError(error) {
27370
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
27371
+ if (!isValid) {
27372
+ return false;
27373
+ }
27374
+ if (error.message === "Load failed") {
27375
+ return error.stack === void 0;
27376
+ }
27377
+ return errorMessages.has(error.message);
27378
+ }
27379
+
27380
+ // node_modules/.pnpm/p-retry@6.2.0/node_modules/p-retry/index.js
27381
+ var AbortError3 = class extends Error {
27382
+ constructor(message2) {
27383
+ super();
27384
+ if (message2 instanceof Error) {
27385
+ this.originalError = message2;
27386
+ ({ message: message2 } = message2);
27387
+ } else {
27388
+ this.originalError = new Error(message2);
27389
+ this.originalError.stack = this.stack;
27390
+ }
27391
+ this.name = "AbortError";
27392
+ this.message = message2;
27393
+ }
27394
+ };
27395
+ var decorateErrorWithCounts = (error, attemptNumber, options) => {
27396
+ const retriesLeft = options.retries - (attemptNumber - 1);
27397
+ error.attemptNumber = attemptNumber;
27398
+ error.retriesLeft = retriesLeft;
27399
+ return error;
27400
+ };
27401
+ async function pRetry(input, options) {
27402
+ return new Promise((resolve7, reject) => {
27403
+ options = {
27404
+ onFailedAttempt() {
27405
+ },
27406
+ retries: 10,
27407
+ shouldRetry: () => true,
27408
+ ...options
27409
+ };
27410
+ const operation = import_retry.default.operation(options);
27411
+ const abortHandler = () => {
27412
+ operation.stop();
27413
+ reject(options.signal?.reason);
27414
+ };
27415
+ if (options.signal && !options.signal.aborted) {
27416
+ options.signal.addEventListener("abort", abortHandler, { once: true });
27417
+ }
27418
+ const cleanUp = () => {
27419
+ options.signal?.removeEventListener("abort", abortHandler);
27420
+ operation.stop();
27421
+ };
27422
+ operation.attempt(async (attemptNumber) => {
27423
+ try {
27424
+ const result = await input(attemptNumber);
27425
+ cleanUp();
27426
+ resolve7(result);
27427
+ } catch (error) {
27428
+ try {
27429
+ if (!(error instanceof Error)) {
27430
+ throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
27431
+ }
27432
+ if (error instanceof AbortError3) {
27433
+ throw error.originalError;
27434
+ }
27435
+ if (error instanceof TypeError && !isNetworkError(error)) {
27436
+ throw error;
27437
+ }
27438
+ decorateErrorWithCounts(error, attemptNumber, options);
27439
+ if (!await options.shouldRetry(error)) {
27440
+ operation.stop();
27441
+ reject(error);
27442
+ }
27443
+ await options.onFailedAttempt(error);
27444
+ if (!operation.retry(error)) {
27445
+ throw operation.mainError();
27446
+ }
27447
+ } catch (finalError) {
27448
+ decorateErrorWithCounts(finalError, attemptNumber, options);
27449
+ cleanUp();
27450
+ reject(finalError);
27451
+ }
27452
+ }
27453
+ });
27454
+ });
27455
+ }
27456
+
27457
+ // node_modules/.pnpm/p-map@7.0.2/node_modules/p-map/index.js
27458
+ async function pMap(iterable, mapper, {
27459
+ concurrency = Number.POSITIVE_INFINITY,
27460
+ stopOnError = true,
27461
+ signal
27462
+ } = {}) {
27463
+ return new Promise((resolve7, reject_) => {
27464
+ if (iterable[Symbol.iterator] === void 0 && iterable[Symbol.asyncIterator] === void 0) {
27465
+ throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
27466
+ }
27467
+ if (typeof mapper !== "function") {
27468
+ throw new TypeError("Mapper function is required");
27469
+ }
27470
+ if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) {
27471
+ throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
27472
+ }
27473
+ const result = [];
27474
+ const errors = [];
27475
+ const skippedIndexesMap = /* @__PURE__ */ new Map();
27476
+ let isRejected = false;
27477
+ let isResolved = false;
27478
+ let isIterableDone = false;
27479
+ let resolvingCount = 0;
27480
+ let currentIndex = 0;
27481
+ const iterator = iterable[Symbol.iterator] === void 0 ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
27482
+ const reject = (reason) => {
27483
+ isRejected = true;
27484
+ isResolved = true;
27485
+ reject_(reason);
27486
+ };
27487
+ if (signal) {
27488
+ if (signal.aborted) {
27489
+ reject(signal.reason);
27490
+ }
27491
+ signal.addEventListener("abort", () => {
27492
+ reject(signal.reason);
27493
+ });
27494
+ }
27495
+ const next = async () => {
27496
+ if (isResolved) {
27497
+ return;
27498
+ }
27499
+ const nextItem = await iterator.next();
27500
+ const index2 = currentIndex;
27501
+ currentIndex++;
27502
+ if (nextItem.done) {
27503
+ isIterableDone = true;
27504
+ if (resolvingCount === 0 && !isResolved) {
27505
+ if (!stopOnError && errors.length > 0) {
27506
+ reject(new AggregateError(errors));
27507
+ return;
27508
+ }
27509
+ isResolved = true;
27510
+ if (skippedIndexesMap.size === 0) {
27511
+ resolve7(result);
27512
+ return;
27513
+ }
27514
+ const pureResult = [];
27515
+ for (const [index3, value] of result.entries()) {
27516
+ if (skippedIndexesMap.get(index3) === pMapSkip) {
27517
+ continue;
27518
+ }
27519
+ pureResult.push(value);
27520
+ }
27521
+ resolve7(pureResult);
27522
+ }
27523
+ return;
27524
+ }
27525
+ resolvingCount++;
27526
+ (async () => {
27527
+ try {
27528
+ const element = await nextItem.value;
27529
+ if (isResolved) {
27530
+ return;
27531
+ }
27532
+ const value = await mapper(element, index2);
27533
+ if (value === pMapSkip) {
27534
+ skippedIndexesMap.set(index2, value);
27535
+ }
27536
+ result[index2] = value;
27537
+ resolvingCount--;
27538
+ await next();
27539
+ } catch (error) {
27540
+ if (stopOnError) {
27541
+ reject(error);
27542
+ } else {
27543
+ errors.push(error);
27544
+ resolvingCount--;
27545
+ try {
27546
+ await next();
27547
+ } catch (error2) {
27548
+ reject(error2);
27549
+ }
27550
+ }
27551
+ }
27552
+ })();
27553
+ };
27554
+ (async () => {
27555
+ for (let index2 = 0; index2 < concurrency; index2++) {
27556
+ try {
27557
+ await next();
27558
+ } catch (error) {
27559
+ reject(error);
27560
+ break;
27561
+ }
27562
+ if (isIterableDone || isRejected) {
27563
+ break;
27564
+ }
27565
+ }
27566
+ })();
27567
+ });
27568
+ }
27569
+ var pMapSkip = Symbol("skip");
27570
+
27114
27571
  // src/blockstore/store.ts
27115
27572
  function guardVersion(url) {
27116
27573
  if (!url.hasParam("version")) {
@@ -27371,72 +27828,82 @@ You can use close({ resize: true }) to resize header`);
27371
27828
  }
27372
27829
  async _doProcess() {
27373
27830
  if (!this.loader.remoteCarStore) return;
27374
- const rmlp = (async () => {
27375
- const operations = [...this.walState.operations];
27376
- const fileOperations = [...this.walState.fileOperations];
27377
- const uploads = [];
27378
- const noLoaderOps = [...this.walState.noLoaderOps];
27379
- const limit = pLimit(3);
27380
- if (operations.length + fileOperations.length + noLoaderOps.length === 0) return;
27381
- for (const dbMeta of noLoaderOps) {
27382
- const uploadP = limit(async () => {
27383
- for (const cid of dbMeta.cars) {
27384
- const car = await (await this.loader.carStore()).load(cid);
27385
- if (!car) {
27386
- if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars))
27387
- throw this.logger.Error().Ref("cid", cid).Msg("missing local car").AsError();
27388
- } else {
27389
- await throwFalsy(this.loader.remoteCarStore).save(car);
27831
+ const operations = [...this.walState.operations];
27832
+ const noLoaderOps = [...this.walState.noLoaderOps];
27833
+ const fileOperations = [...this.walState.fileOperations];
27834
+ if (operations.length + noLoaderOps.length + fileOperations.length === 0) return;
27835
+ const concurrencyLimit = 3;
27836
+ const retryableUpload = (fn, description) => pRetry(fn, {
27837
+ retries: 5,
27838
+ onFailedAttempt: (error) => {
27839
+ this.logger.Warn().Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
27840
+ }
27841
+ });
27842
+ try {
27843
+ await pMap(
27844
+ noLoaderOps,
27845
+ async (dbMeta) => {
27846
+ await retryableUpload(async () => {
27847
+ for (const cid of dbMeta.cars) {
27848
+ const car = await (await this.loader.carStore()).load(cid);
27849
+ if (!car) {
27850
+ if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars)) {
27851
+ throw this.logger.Error().Ref("cid", cid).Msg("missing local car").AsError();
27852
+ }
27853
+ } else {
27854
+ await throwFalsy(this.loader.remoteCarStore).save(car);
27855
+ }
27390
27856
  }
27391
27857
  this.walState.noLoaderOps = this.walState.noLoaderOps.filter((op) => op !== dbMeta);
27392
- }
27393
- });
27394
- uploads.push(uploadP);
27395
- }
27396
- for (const dbMeta of operations) {
27397
- const uploadP = limit(async () => {
27398
- for (const cid of dbMeta.cars) {
27399
- const car = await (await this.loader.carStore()).load(cid).catch(() => null);
27400
- if (!car) {
27401
- if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars))
27402
- throw this.logger.Error().Ref("cid", cid).Msg(`missing local car`).AsError();
27403
- } else {
27404
- await throwFalsy(this.loader.remoteCarStore).save(car);
27858
+ }, `noLoaderOp with dbMeta.cars=${dbMeta.cars.toString()}`);
27859
+ },
27860
+ { concurrency: concurrencyLimit }
27861
+ );
27862
+ await pMap(
27863
+ operations,
27864
+ async (dbMeta) => {
27865
+ await retryableUpload(async () => {
27866
+ for (const cid of dbMeta.cars) {
27867
+ const car = await (await this.loader.carStore()).load(cid);
27868
+ if (!car) {
27869
+ if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars)) {
27870
+ throw this.logger.Error().Ref("cid", cid).Msg(`missing local car`).AsError();
27871
+ }
27872
+ } else {
27873
+ await throwFalsy(this.loader.remoteCarStore).save(car);
27874
+ }
27405
27875
  }
27406
- }
27407
- this.walState.operations = this.walState.operations.filter((op) => op !== dbMeta);
27408
- });
27409
- uploads.push(uploadP);
27410
- }
27411
- if (fileOperations.length) {
27412
- const dbLoader = this.loader;
27413
- for (const { cid: fileCid, public: publicFile } of fileOperations) {
27414
- const uploadP = limit(async () => {
27415
- const fileBlock = await (await dbLoader.fileStore()).load(fileCid);
27416
- await dbLoader.remoteFileStore?.save(fileBlock, { public: publicFile });
27876
+ this.walState.operations = this.walState.operations.filter((op) => op !== dbMeta);
27877
+ }, `operation with dbMeta.cars=${dbMeta.cars.toString()}`);
27878
+ },
27879
+ { concurrency: concurrencyLimit }
27880
+ );
27881
+ await pMap(
27882
+ fileOperations,
27883
+ async ({ cid: fileCid, public: publicFile }) => {
27884
+ await retryableUpload(async () => {
27885
+ const fileBlock = await (await this.loader.fileStore()).load(fileCid);
27886
+ if (!fileBlock) {
27887
+ throw this.logger.Error().Ref("cid", fileCid).Msg("missing file block").AsError();
27888
+ }
27889
+ await this.loader.remoteFileStore?.save(fileBlock, { public: publicFile });
27417
27890
  this.walState.fileOperations = this.walState.fileOperations.filter((op) => op.cid !== fileCid);
27418
- });
27419
- uploads.push(uploadP);
27420
- }
27421
- }
27422
- try {
27423
- const res = await Promise.allSettled(uploads);
27424
- const errors = res.filter((r) => r.status === "rejected");
27425
- if (errors.length) {
27426
- throw this.logger.Error().Any("errors", errors).Msg("error uploading").AsError();
27427
- }
27428
- if (operations.length) {
27429
- const lastOp = operations[operations.length - 1];
27430
- await this.loader.remoteMetaStore?.save(lastOp).catch((e) => {
27431
- this.walState.operations.push(lastOp);
27432
- throw this.logger.Error().Any("error", e).Msg("error saving remote meta").AsError();
27433
- });
27434
- }
27435
- } finally {
27436
- await this.save(this.walState);
27891
+ }, `fileOperation with cid=${fileCid.toString()}`);
27892
+ },
27893
+ { concurrency: concurrencyLimit }
27894
+ );
27895
+ if (operations.length) {
27896
+ const lastOp = operations[operations.length - 1];
27897
+ await retryableUpload(async () => {
27898
+ await this.loader.remoteMetaStore?.save(lastOp);
27899
+ }, `remoteMetaStore save with dbMeta.cars=${lastOp.cars.toString()}`);
27437
27900
  }
27438
- })();
27439
- await rmlp;
27901
+ } catch (error) {
27902
+ this.logger.Error().Any("error", error).Msg("Processing failed");
27903
+ return;
27904
+ } finally {
27905
+ await this.save(this.walState);
27906
+ }
27440
27907
  }
27441
27908
  async load() {
27442
27909
  this.logger.Debug().Msg("loading");
@@ -30062,7 +30529,7 @@ You can use close({ resize: true }) to resize header`);
30062
30529
 
30063
30530
  // src/version.ts
30064
30531
  var PACKAGE_VERSION = Object.keys({
30065
- "0.19.11-dev-dryrun6": "xxxx"
30532
+ "0.19.99-dev-100": "xxxx"
30066
30533
  })[0];
30067
30534
  return __toCommonJS(src_exports6);
30068
30535
  })();