@amalgm/shell 0.1.164-main.42444320985 → 0.1.164-main.42698557508
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/native/cloud-files.node +0 -0
- package/dist/native/windows-fs.node +0 -0
- package/dist/patient-flush.d.ts +24 -0
- package/dist/patient-flush.js +37 -0
- package/dist/patient-flush.js.map +1 -0
- package/dist/user-ground-host.js +5 -1
- package/dist/user-ground-host.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A boundary that needs its local work accepted waits through Send failures
|
|
3
|
+
* that prove nothing. The Send line retries every failure but a refusal,
|
|
4
|
+
* forever, under the same mutation identities: a lost answer, a dropped
|
|
5
|
+
* wire, or an authority that ran past its own time limit still ends in an
|
|
6
|
+
* acceptance. So only a refusal, or an answer the authority marked final,
|
|
7
|
+
* ends the wait at once. Anything else ends it only once the patience is
|
|
8
|
+
* spent, or the caller no longer wants it; between asks it waits as the
|
|
9
|
+
* line does, doubling from the line's first backoff to its longest.
|
|
10
|
+
*/
|
|
11
|
+
/** How long a boundary waits for Send through failures that prove nothing. */
|
|
12
|
+
export declare const SEND_PATIENCE_MS: number;
|
|
13
|
+
/** Whether a failed flush settles the question: the authority refused a
|
|
14
|
+
* record, or answered with a failure it marked final. */
|
|
15
|
+
export declare function sendFailureIsFinal(error: unknown): boolean;
|
|
16
|
+
export interface FlushPatience {
|
|
17
|
+
/** How long, from the first ask, a wait may still begin before giving up. */
|
|
18
|
+
readonly patienceMs?: number;
|
|
19
|
+
/** Whether to ask again after this failure; false ends the wait with it. */
|
|
20
|
+
readonly wanted?: (error: unknown) => boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Flush until it answers, a failure is final, or the patience is spent;
|
|
23
|
+
* a failure that ends the wait is the one thrown. */
|
|
24
|
+
export declare function flushPatiently(flush: () => Promise<void>, { patienceMs, wanted }?: FlushPatience): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A boundary that needs its local work accepted waits through Send failures
|
|
3
|
+
* that prove nothing. The Send line retries every failure but a refusal,
|
|
4
|
+
* forever, under the same mutation identities: a lost answer, a dropped
|
|
5
|
+
* wire, or an authority that ran past its own time limit still ends in an
|
|
6
|
+
* acceptance. So only a refusal, or an answer the authority marked final,
|
|
7
|
+
* ends the wait at once. Anything else ends it only once the patience is
|
|
8
|
+
* spent, or the caller no longer wants it; between asks it waits as the
|
|
9
|
+
* line does, doubling from the line's first backoff to its longest.
|
|
10
|
+
*/
|
|
11
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
12
|
+
import { ENTITY_RECORD_RETRY_BASE_MS, ENTITY_RECORD_RETRY_MAX_MS, EntityRecordRefusedError, } from "@amalgm/live/records";
|
|
13
|
+
import { WireRequestError } from "./wire-client.js";
|
|
14
|
+
/** How long a boundary waits for Send through failures that prove nothing. */
|
|
15
|
+
export const SEND_PATIENCE_MS = 10 * 60_000;
|
|
16
|
+
/** Whether a failed flush settles the question: the authority refused a
|
|
17
|
+
* record, or answered with a failure it marked final. */
|
|
18
|
+
export function sendFailureIsFinal(error) {
|
|
19
|
+
return error instanceof EntityRecordRefusedError
|
|
20
|
+
|| (error instanceof WireRequestError && !error.retryable);
|
|
21
|
+
}
|
|
22
|
+
/** Flush until it answers, a failure is final, or the patience is spent;
|
|
23
|
+
* a failure that ends the wait is the one thrown. */
|
|
24
|
+
export async function flushPatiently(flush, { patienceMs = SEND_PATIENCE_MS, wanted = () => true } = {}) {
|
|
25
|
+
const deadline = performance.now() + patienceMs;
|
|
26
|
+
for (let wait = ENTITY_RECORD_RETRY_BASE_MS;; wait = Math.min(wait * 2, ENTITY_RECORD_RETRY_MAX_MS)) {
|
|
27
|
+
try {
|
|
28
|
+
return await flush();
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (sendFailureIsFinal(error) || !wanted(error) || performance.now() + wait > deadline)
|
|
32
|
+
throw error;
|
|
33
|
+
await sleep(wait);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=patient-flush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patient-flush.js","sourceRoot":"","sources":["../src/patient-flush.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,MAAM,CAAC;AAE5C;yDACyD;AACzD,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,KAAK,YAAY,wBAAwB;WAC3C,CAAC,KAAK,YAAY,gBAAgB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC/D,CAAC;AASD;qDACqD;AACrD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAA0B,EAC1B,EAAE,UAAU,GAAG,gBAAgB,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,KAAoB,EAAE;IAE1E,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC;IAChD,KAAK,IAAI,IAAI,GAAG,2BAA2B,GAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,0BAA0B,CAAC,EAAE,CAAC;QACrG,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,QAAQ;gBAAE,MAAM,KAAK,CAAC;YACpG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/user-ground-host.js
CHANGED
|
@@ -83,6 +83,7 @@ import { AcceptedFold } from "./accepted-fold.js";
|
|
|
83
83
|
import { acceptedView } from "./accepted-view.js";
|
|
84
84
|
import { placeAcceptedReferences } from "./reference-placement.js";
|
|
85
85
|
import { WireClient, WireRequestError } from "./wire-client.js";
|
|
86
|
+
import { flushPatiently } from "./patient-flush.js";
|
|
86
87
|
import { readLinkTarget } from "./link-target.js";
|
|
87
88
|
import { WireRequestScope } from './wire-request-scope.js';
|
|
88
89
|
import { sha256Hex } from "./sha256.js";
|
|
@@ -1295,7 +1296,10 @@ export class UserGroundHost {
|
|
|
1295
1296
|
if (refused !== undefined)
|
|
1296
1297
|
throw refusal(`repository state could not be captured: ${refused}`);
|
|
1297
1298
|
try {
|
|
1298
|
-
|
|
1299
|
+
// Register gives up on a refusal, never on a failure Send retries.
|
|
1300
|
+
await flushPatiently(async () => { await this.recordRail?.flush(); }, {
|
|
1301
|
+
wanted: (error) => !this.closing && !(error instanceof GroundDatabaseAway),
|
|
1302
|
+
});
|
|
1299
1303
|
}
|
|
1300
1304
|
catch (error) {
|
|
1301
1305
|
throw this.databaseCause(error);
|