@fireproof/core 0.19.8-dev-series-1 → 0.19.8-dev-series-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +3 -1
- package/index.cjs +74 -63
- package/index.cjs.map +1 -1
- package/index.global.js +552 -85
- package/index.global.js.map +1 -1
- package/index.js +75 -64
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/package.json +4 -2
package/index.js
CHANGED
@@ -252,7 +252,6 @@ var UnixFSFileBuilder = class {
|
|
252
252
|
};
|
253
253
|
|
254
254
|
// src/blockstore/store.ts
|
255
|
-
import pLimit2 from "p-limit";
|
256
255
|
import { format as format2, parse as parse2 } from "@ipld/dag-json";
|
257
256
|
import { exception2Result, ResolveOnce as ResolveOnce3, Result as Result5 } from "@adviser/cement";
|
258
257
|
|
@@ -1667,6 +1666,8 @@ async function encodeEventsWithParents(sthis, events, parents) {
|
|
1667
1666
|
}
|
1668
1667
|
|
1669
1668
|
// src/blockstore/store.ts
|
1669
|
+
import pRetry from "p-retry";
|
1670
|
+
import pMap from "p-map";
|
1670
1671
|
function guardVersion(url) {
|
1671
1672
|
if (!url.hasParam("version")) {
|
1672
1673
|
return Result5.Err(`missing version: ${url.toString()}`);
|
@@ -1926,72 +1927,82 @@ var WALStoreImpl = class extends BaseStoreImpl {
|
|
1926
1927
|
}
|
1927
1928
|
async _doProcess() {
|
1928
1929
|
if (!this.loader.remoteCarStore) return;
|
1929
|
-
const
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1930
|
+
const operations = [...this.walState.operations];
|
1931
|
+
const noLoaderOps = [...this.walState.noLoaderOps];
|
1932
|
+
const fileOperations = [...this.walState.fileOperations];
|
1933
|
+
if (operations.length + noLoaderOps.length + fileOperations.length === 0) return;
|
1934
|
+
const concurrencyLimit = 3;
|
1935
|
+
const retryableUpload = (fn, description) => pRetry(fn, {
|
1936
|
+
retries: 5,
|
1937
|
+
onFailedAttempt: (error) => {
|
1938
|
+
this.logger.Warn().Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
|
1939
|
+
}
|
1940
|
+
});
|
1941
|
+
try {
|
1942
|
+
await pMap(
|
1943
|
+
noLoaderOps,
|
1944
|
+
async (dbMeta) => {
|
1945
|
+
await retryableUpload(async () => {
|
1946
|
+
for (const cid of dbMeta.cars) {
|
1947
|
+
const car = await (await this.loader.carStore()).load(cid);
|
1948
|
+
if (!car) {
|
1949
|
+
if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars)) {
|
1950
|
+
throw this.logger.Error().Ref("cid", cid).Msg("missing local car").AsError();
|
1951
|
+
}
|
1952
|
+
} else {
|
1953
|
+
await throwFalsy(this.loader.remoteCarStore).save(car);
|
1954
|
+
}
|
1945
1955
|
}
|
1946
1956
|
this.walState.noLoaderOps = this.walState.noLoaderOps.filter((op) => op !== dbMeta);
|
1947
|
-
}
|
1948
|
-
}
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1957
|
+
}, `noLoaderOp with dbMeta.cars=${dbMeta.cars.toString()}`);
|
1958
|
+
},
|
1959
|
+
{ concurrency: concurrencyLimit }
|
1960
|
+
);
|
1961
|
+
await pMap(
|
1962
|
+
operations,
|
1963
|
+
async (dbMeta) => {
|
1964
|
+
await retryableUpload(async () => {
|
1965
|
+
for (const cid of dbMeta.cars) {
|
1966
|
+
const car = await (await this.loader.carStore()).load(cid);
|
1967
|
+
if (!car) {
|
1968
|
+
if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars)) {
|
1969
|
+
throw this.logger.Error().Ref("cid", cid).Msg(`missing local car`).AsError();
|
1970
|
+
}
|
1971
|
+
} else {
|
1972
|
+
await throwFalsy(this.loader.remoteCarStore).save(car);
|
1973
|
+
}
|
1960
1974
|
}
|
1961
|
-
|
1962
|
-
|
1963
|
-
}
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
const fileBlock = await (await
|
1971
|
-
|
1975
|
+
this.walState.operations = this.walState.operations.filter((op) => op !== dbMeta);
|
1976
|
+
}, `operation with dbMeta.cars=${dbMeta.cars.toString()}`);
|
1977
|
+
},
|
1978
|
+
{ concurrency: concurrencyLimit }
|
1979
|
+
);
|
1980
|
+
await pMap(
|
1981
|
+
fileOperations,
|
1982
|
+
async ({ cid: fileCid, public: publicFile }) => {
|
1983
|
+
await retryableUpload(async () => {
|
1984
|
+
const fileBlock = await (await this.loader.fileStore()).load(fileCid);
|
1985
|
+
if (!fileBlock) {
|
1986
|
+
throw this.logger.Error().Ref("cid", fileCid).Msg("missing file block").AsError();
|
1987
|
+
}
|
1988
|
+
await this.loader.remoteFileStore?.save(fileBlock, { public: publicFile });
|
1972
1989
|
this.walState.fileOperations = this.walState.fileOperations.filter((op) => op.cid !== fileCid);
|
1973
|
-
});
|
1974
|
-
|
1975
|
-
}
|
1976
|
-
|
1977
|
-
|
1978
|
-
const
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
}
|
1990
|
-
} finally {
|
1991
|
-
await this.save(this.walState);
|
1992
|
-
}
|
1993
|
-
})();
|
1994
|
-
await rmlp;
|
1990
|
+
}, `fileOperation with cid=${fileCid.toString()}`);
|
1991
|
+
},
|
1992
|
+
{ concurrency: concurrencyLimit }
|
1993
|
+
);
|
1994
|
+
if (operations.length) {
|
1995
|
+
const lastOp = operations[operations.length - 1];
|
1996
|
+
await retryableUpload(async () => {
|
1997
|
+
await this.loader.remoteMetaStore?.save(lastOp);
|
1998
|
+
}, `remoteMetaStore save with dbMeta.cars=${lastOp.cars.toString()}`);
|
1999
|
+
}
|
2000
|
+
} catch (error) {
|
2001
|
+
this.logger.Error().Any("error", error).Msg("Processing failed");
|
2002
|
+
return;
|
2003
|
+
} finally {
|
2004
|
+
await this.save(this.walState);
|
2005
|
+
}
|
1995
2006
|
}
|
1996
2007
|
async load() {
|
1997
2008
|
this.logger.Debug().Msg("loading");
|
@@ -3416,7 +3427,7 @@ import { runtimeFn as runtimeFn2 } from "@adviser/cement";
|
|
3416
3427
|
|
3417
3428
|
// src/version.ts
|
3418
3429
|
var PACKAGE_VERSION = Object.keys({
|
3419
|
-
"0.19.8-dev-series-
|
3430
|
+
"0.19.8-dev-series-2": "xxxx"
|
3420
3431
|
})[0];
|
3421
3432
|
export {
|
3422
3433
|
CRDT,
|