@rljson/fs-agent 0.0.66 → 0.0.67
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/dist/fs-agent.d.ts +35 -0
- package/dist/fs-agent.js +28 -5
- package/package.json +1 -1
package/dist/fs-agent.d.ts
CHANGED
|
@@ -239,6 +239,35 @@ export declare class PartialRestoreError extends RestoreIncompleteError {
|
|
|
239
239
|
readonly lockedPaths: string[];
|
|
240
240
|
constructor(lockedPaths: string[]);
|
|
241
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Thrown when a restore finished but at least one file's bytes could not be
|
|
244
|
+
* fetched at all.
|
|
245
|
+
*
|
|
246
|
+
* The difference from {@link PartialRestoreError} is "not yet" versus "never".
|
|
247
|
+
* A locked file's bytes exist and the file is merely busy, so retrying is the
|
|
248
|
+
* right answer. A blob that cannot be retrieved may never become retrievable —
|
|
249
|
+
* a file larger than the transport's `maxHttpBufferSize` is the case that
|
|
250
|
+
* produced this class, and no number of retries makes 63 MB fit through a
|
|
251
|
+
* 50 MB socket.
|
|
252
|
+
*
|
|
253
|
+
* It exists because the failure used to be a bare `throw` in the middle of
|
|
254
|
+
* `_restoreTree`, which abandoned the ENTIRE tree: no other file in it was
|
|
255
|
+
* written, and — the part that actually hurt — `_pruneExtraneous` never ran,
|
|
256
|
+
* so no deletion in that tree was ever applied. The node then retried, failed
|
|
257
|
+
* on the same blob, and its state never advanced past that ref. Once its
|
|
258
|
+
* ancestry no longer matched any state its peers were in, every later apply
|
|
259
|
+
* came through with `mayPrune=false`, and it accepted additions forever while
|
|
260
|
+
* silently ignoring every delete.
|
|
261
|
+
*
|
|
262
|
+
* Measured on four nodes: one 63 MB file (120% of the cap) left three of them
|
|
263
|
+
* holding a file the fourth had deleted, permanently, and `projekte-shape`'s
|
|
264
|
+
* deletion had still not propagated after 300 seconds. The customer's largest
|
|
265
|
+
* file is 45.9 MB against the same 50 MB cap.
|
|
266
|
+
*/
|
|
267
|
+
export declare class BlobUnavailableError extends RestoreIncompleteError {
|
|
268
|
+
readonly unavailablePaths: string[];
|
|
269
|
+
constructor(unavailablePaths: string[]);
|
|
270
|
+
}
|
|
242
271
|
/**
|
|
243
272
|
* Thrown when `cleanTarget` would have deleted most of the folder.
|
|
244
273
|
*
|
|
@@ -339,6 +368,12 @@ export declare class FsAgent {
|
|
|
339
368
|
private _restorePruned;
|
|
340
369
|
/** Paths the current {@link restore} could not write because they were held open. */
|
|
341
370
|
private _restoreLocked;
|
|
371
|
+
/**
|
|
372
|
+
* Paths the current {@link restore} could not write because their blob could
|
|
373
|
+
* not be fetched — collected rather than thrown, so one unfetchable file
|
|
374
|
+
* cannot abandon the rest of the tree and, above all, cannot stop the prune.
|
|
375
|
+
*/
|
|
376
|
+
private _restoreUnavailable;
|
|
342
377
|
/**
|
|
343
378
|
* What this agent last wrote to each absolute path, so a repeat restore can
|
|
344
379
|
* recognise its own work without re-reading the file.
|
package/dist/fs-agent.js
CHANGED
|
@@ -1124,6 +1124,15 @@ class PartialRestoreError extends RestoreIncompleteError {
|
|
|
1124
1124
|
this.name = "PartialRestoreError";
|
|
1125
1125
|
}
|
|
1126
1126
|
}
|
|
1127
|
+
class BlobUnavailableError extends RestoreIncompleteError {
|
|
1128
|
+
constructor(unavailablePaths) {
|
|
1129
|
+
super(
|
|
1130
|
+
`restore could not fetch ${unavailablePaths.length} blob${unavailablePaths.length === 1 ? "" : "s"}: ${unavailablePaths.join(", ")}`
|
|
1131
|
+
);
|
|
1132
|
+
this.unavailablePaths = unavailablePaths;
|
|
1133
|
+
this.name = "BlobUnavailableError";
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1127
1136
|
class MassDeleteRefusedError extends RestoreIncompleteError {
|
|
1128
1137
|
constructor(wouldPrune, totalFiles, incomingFiles) {
|
|
1129
1138
|
super(
|
|
@@ -1219,6 +1228,12 @@ class FsAgent {
|
|
|
1219
1228
|
_restorePruned = 0;
|
|
1220
1229
|
/** Paths the current {@link restore} could not write because they were held open. */
|
|
1221
1230
|
_restoreLocked = [];
|
|
1231
|
+
/**
|
|
1232
|
+
* Paths the current {@link restore} could not write because their blob could
|
|
1233
|
+
* not be fetched — collected rather than thrown, so one unfetchable file
|
|
1234
|
+
* cannot abandon the rest of the tree and, above all, cannot stop the prune.
|
|
1235
|
+
*/
|
|
1236
|
+
_restoreUnavailable = [];
|
|
1222
1237
|
/**
|
|
1223
1238
|
* What this agent last wrote to each absolute path, so a repeat restore can
|
|
1224
1239
|
* recognise its own work without re-reading the file.
|
|
@@ -1549,6 +1564,7 @@ ${err.stack}` : String(err);
|
|
|
1549
1564
|
this._restoreSkipped = 0;
|
|
1550
1565
|
this._restorePruned = 0;
|
|
1551
1566
|
this._restoreLocked = [];
|
|
1567
|
+
this._restoreUnavailable = [];
|
|
1552
1568
|
await this._restoreTree(
|
|
1553
1569
|
tree.rootHash,
|
|
1554
1570
|
tree.trees,
|
|
@@ -1591,6 +1607,9 @@ ${err.stack}` : String(err);
|
|
|
1591
1607
|
if (this._restoreLocked.length > 0) {
|
|
1592
1608
|
throw new PartialRestoreError([...this._restoreLocked]);
|
|
1593
1609
|
}
|
|
1610
|
+
if (this._restoreUnavailable.length > 0) {
|
|
1611
|
+
throw new BlobUnavailableError([...this._restoreUnavailable]);
|
|
1612
|
+
}
|
|
1594
1613
|
}
|
|
1595
1614
|
/**
|
|
1596
1615
|
* Recursively collects the absolute paths of all files under `currentDir`.
|
|
@@ -1649,14 +1668,18 @@ ${err.stack}` : String(err);
|
|
|
1649
1668
|
try {
|
|
1650
1669
|
fileBlob = await this._bs.getBlob(meta.blobId);
|
|
1651
1670
|
} catch (error) {
|
|
1652
|
-
|
|
1653
|
-
`
|
|
1671
|
+
console.warn(
|
|
1672
|
+
`[FsAgent] cannot fetch blob for "${meta.relativePath}" (blobId: ${meta.blobId}): ${error instanceof Error ? error.message : String(error)} — skipping this file and applying the rest of the tree.`
|
|
1654
1673
|
);
|
|
1674
|
+
this._restoreUnavailable.push(meta.relativePath);
|
|
1675
|
+
return;
|
|
1655
1676
|
}
|
|
1656
1677
|
if (!fileBlob || !fileBlob.content) {
|
|
1657
|
-
|
|
1658
|
-
`
|
|
1678
|
+
console.warn(
|
|
1679
|
+
`[FsAgent] missing blob content for "${meta.relativePath}" (blobId: ${meta.blobId}) — skipping this file and applying the rest of the tree.`
|
|
1659
1680
|
);
|
|
1681
|
+
this._restoreUnavailable.push(meta.relativePath);
|
|
1682
|
+
return;
|
|
1660
1683
|
}
|
|
1661
1684
|
await mkdir(dirname(filePath), { recursive: true });
|
|
1662
1685
|
try {
|
|
@@ -2690,7 +2713,7 @@ ${err.stack}` : String(err);
|
|
|
2690
2713
|
await this._readvertiseAfterRefusal(connector);
|
|
2691
2714
|
return;
|
|
2692
2715
|
}
|
|
2693
|
-
if (err instanceof PartialRestoreError) {
|
|
2716
|
+
if (err instanceof PartialRestoreError || err instanceof BlobUnavailableError) {
|
|
2694
2717
|
try {
|
|
2695
2718
|
const halfApplied = await this._scanner.scan();
|
|
2696
2719
|
this._lastSentContentKey = this._contentKeyFromTree(halfApplied);
|