@serfab/cadre-core 0.12.0 → 1.0.0
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/README.md +23 -8
- package/dist/bootstrap-peer-store-file.js +2 -2
- package/dist/bootstrap-peer-store.d.ts +32 -12
- package/dist/bootstrap-peer-store.js +41 -15
- package/dist/bootstrap-peer-store.js.map +1 -1
- package/dist/cadre-node.d.ts +883 -102
- package/dist/cadre-node.js +1800 -209
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +2 -2
- package/dist/control-authorization.js +1 -0
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.d.ts +13 -26
- package/dist/control-cohort.js +0 -26
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +318 -44
- package/dist/control-database.js +516 -74
- package/dist/control-database.js.map +1 -1
- package/dist/control-read-retry.d.ts +40 -11
- package/dist/control-read-retry.js +48 -15
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-retry.d.ts +58 -3
- package/dist/control-retry.js +58 -3
- package/dist/control-retry.js.map +1 -1
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +133 -21
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +80 -11
- package/dist/control-write-retry.js +168 -29
- package/dist/control-write-retry.js.map +1 -1
- package/dist/enrolled-machine-store-file.d.ts +13 -0
- package/dist/enrolled-machine-store-file.js +41 -0
- package/dist/enrolled-machine-store-file.js.map +1 -0
- package/dist/enrolled-machine-store.d.ts +81 -0
- package/dist/enrolled-machine-store.js +225 -0
- package/dist/enrolled-machine-store.js.map +1 -0
- package/dist/file-durable-slot.js +5 -3
- package/dist/file-durable-slot.js.map +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.js +54 -9
- package/dist/index.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +15 -1
- package/dist/membership-connection-gater.js +9 -3
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/node-local-snapshot.d.ts +21 -7
- package/dist/node-local-snapshot.js +30 -9
- package/dist/node-local-snapshot.js.map +1 -1
- package/dist/peer-dial.d.ts +143 -0
- package/dist/peer-dial.js +176 -0
- package/dist/peer-dial.js.map +1 -0
- package/dist/{strand-backfill.d.ts → peer-join-backfill.d.ts} +49 -20
- package/dist/{strand-backfill.js → peer-join-backfill.js} +133 -52
- package/dist/peer-join-backfill.js.map +1 -0
- package/dist/relay-addrs.d.ts +160 -49
- package/dist/relay-addrs.js +287 -60
- package/dist/relay-addrs.js.map +1 -1
- package/dist/relay-reservation.d.ts +71 -3
- package/dist/relay-reservation.js +116 -8
- package/dist/relay-reservation.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +30 -1
- package/dist/seed-bootstrap.js +62 -17
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/storage-scope.d.ts +62 -0
- package/dist/storage-scope.js +75 -0
- package/dist/storage-scope.js.map +1 -0
- package/dist/strand-database.d.ts +41 -11
- package/dist/strand-database.js +48 -18
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +152 -0
- package/dist/strand-first-sync-gate.js +208 -0
- package/dist/strand-first-sync-gate.js.map +1 -0
- package/dist/strand-formation-manager.d.ts +99 -5
- package/dist/strand-formation-manager.js +119 -8
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +97 -3
- package/dist/strand-formation-protocol.js +108 -2
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +389 -19
- package/dist/strand-instance-manager.js +678 -65
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-key.d.ts +20 -12
- package/dist/strand-member-key.js +20 -12
- package/dist/strand-member-key.js.map +1 -1
- package/dist/strand-member-registry.js +3 -0
- package/dist/strand-member-registry.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +361 -0
- package/dist/strand-membership-reconciler.js +548 -0
- package/dist/strand-membership-reconciler.js.map +1 -0
- package/dist/strand-membership-writer.d.ts +143 -11
- package/dist/strand-membership-writer.js +419 -135
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-network-config.d.ts +116 -0
- package/dist/strand-network-config.js +192 -0
- package/dist/strand-network-config.js.map +1 -0
- package/dist/strand-revocation-enforcer.d.ts +392 -0
- package/dist/strand-revocation-enforcer.js +533 -0
- package/dist/strand-revocation-enforcer.js.map +1 -0
- package/dist/strand-solicitation.d.ts +17 -1
- package/dist/strand-solicitation.js +13 -2
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-wake-protocol.d.ts +11 -7
- package/dist/strand-wake-protocol.js +20 -52
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/strand-watcher.js +12 -1
- package/dist/strand-watcher.js.map +1 -1
- package/dist/timed-step.d.ts +12 -0
- package/dist/timed-step.js +28 -0
- package/dist/timed-step.js.map +1 -0
- package/dist/timeout-scheduler.d.ts +19 -0
- package/dist/timeout-scheduler.js +22 -0
- package/dist/timeout-scheduler.js.map +1 -0
- package/dist/types.d.ts +472 -46
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/package.json +16 -8
- package/src/bootstrap-peer-store-file.ts +2 -2
- package/src/bootstrap-peer-store.ts +69 -27
- package/src/cadre-node.ts +1926 -228
- package/src/control-authorization.ts +2 -1
- package/src/control-cohort.ts +122 -130
- package/src/control-database.ts +586 -74
- package/src/control-read-retry.ts +202 -167
- package/src/control-retry.ts +297 -190
- package/src/control-schema.ts +133 -21
- package/src/control-write-retry.ts +525 -383
- package/src/enrolled-machine-store-file.ts +43 -0
- package/src/enrolled-machine-store.ts +280 -0
- package/src/file-durable-slot.ts +5 -3
- package/src/index.ts +134 -15
- package/src/membership-connection-gater.ts +9 -3
- package/src/node-local-snapshot.ts +38 -9
- package/src/peer-addr-book.ts +251 -250
- package/src/peer-dial.ts +215 -0
- package/src/{strand-backfill.ts → peer-join-backfill.ts} +478 -389
- package/src/relay-addrs.ts +458 -218
- package/src/relay-reservation.ts +951 -828
- package/src/seed-bootstrap.ts +76 -18
- package/src/storage-scope.ts +78 -0
- package/src/strand-database.ts +61 -21
- package/src/strand-first-sync-gate.ts +258 -0
- package/src/strand-formation-manager.ts +162 -8
- package/src/strand-formation-protocol.ts +850 -692
- package/src/strand-instance-manager.ts +877 -74
- package/src/strand-member-key.ts +20 -12
- package/src/strand-member-registry.ts +3 -0
- package/src/strand-membership-reconciler.ts +680 -0
- package/src/strand-membership-writer.ts +550 -190
- package/src/strand-network-config.ts +250 -0
- package/src/strand-revocation-enforcer.ts +653 -0
- package/src/strand-solicitation.ts +499 -471
- package/src/strand-wake-protocol.ts +21 -66
- package/src/strand-watcher.ts +325 -314
- package/src/timed-step.ts +28 -0
- package/src/timeout-scheduler.ts +28 -0
- package/src/types.ts +487 -52
- package/dist/strand-backfill.js.map +0 -1
|
@@ -42,8 +42,10 @@ export declare const WAKE_PROTOCOL = "/sereus/strand-wake/1.0.0";
|
|
|
42
42
|
*
|
|
43
43
|
* This makes the TARGET PEER the unit rather than the address — the same
|
|
44
44
|
* decision, for the same reason, as
|
|
45
|
-
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `
|
|
46
|
-
*
|
|
45
|
+
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `peer-dial.ts`, though not the same
|
|
46
|
+
* number: that one is sized to fit several dead addresses ahead of a working one,
|
|
47
|
+
* while a wake target is expected to be awake and reachable on its first or second
|
|
48
|
+
* address. 20 s is deliberately wider than one attempt timeout so a
|
|
47
49
|
* reachable peer whose signaling address is stale still gets a genuine try at
|
|
48
50
|
* its direct one; a peer needing longer than that is not "asleep and reachable",
|
|
49
51
|
* which is the only case a wake is for. The last attempt inside the budget gets
|
|
@@ -147,15 +149,17 @@ export interface DialWakeOptions {
|
|
|
147
149
|
* dropped.
|
|
148
150
|
*
|
|
149
151
|
* Throws if no address is dialable — with an error naming EVERY candidate and
|
|
150
|
-
* why it failed, not merely the last one. That
|
|
151
|
-
* with only the last candidate's message the
|
|
152
|
-
* signaling address, tried first) is
|
|
153
|
-
*
|
|
152
|
+
* why it failed, not merely the last one ({@link tryAddrsInTurn}). That
|
|
153
|
+
* distinction is not cosmetic: with only the last candidate's message the
|
|
154
|
+
* failure that mattered (usually the signaling address, tried first) is
|
|
155
|
+
* invisible outside a debug log, and the surfaced message points at whichever
|
|
156
|
+
* address happened to be tried last.
|
|
154
157
|
*
|
|
155
158
|
* The candidate loop is deliberately explicit rather than one
|
|
156
159
|
* `dialProtocol(addrs)` call. libp2p sorts any multi-address dial with
|
|
157
160
|
* `defaultAddressSorter`, whose `circuitRelayAddressesLast` pass would demote
|
|
158
161
|
* exactly the signaling address this ordering puts first — silently inverting
|
|
159
|
-
* it, with no per-dial sorter override to opt out of.
|
|
162
|
+
* it, with no per-dial sorter override to opt out of. For the same reason this
|
|
163
|
+
* does not use `dialPeerAddrs`, which puts relayed addresses last.
|
|
160
164
|
*/
|
|
161
165
|
export declare function dialWake(node: Libp2p, addrs: Multiaddr[], request: WakeRequest, options?: DialWakeOptions): Promise<WakeAck>;
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import debug from 'debug';
|
|
28
28
|
import { decodeLengthPrefixedFrame } from './seed-bootstrap.js';
|
|
29
|
-
import { writeFrame,
|
|
29
|
+
import { writeFrame, exchangeFrame, readStreamToEnd } from './control-stream.js';
|
|
30
|
+
import { tryAddrsInTurn } from './peer-dial.js';
|
|
30
31
|
const log = debug('sereus:cadre:strand-wake');
|
|
31
32
|
/** Protocol id for control-network push-wake (parallel to `/sereus/seed/1.0.0`). */
|
|
32
33
|
export const WAKE_PROTOCOL = '/sereus/strand-wake/1.0.0';
|
|
@@ -51,8 +52,10 @@ const DEFAULT_WAKE_TIMEOUT_MS = 10000;
|
|
|
51
52
|
*
|
|
52
53
|
* This makes the TARGET PEER the unit rather than the address — the same
|
|
53
54
|
* decision, for the same reason, as
|
|
54
|
-
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `
|
|
55
|
-
*
|
|
55
|
+
* `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `peer-dial.ts`, though not the same
|
|
56
|
+
* number: that one is sized to fit several dead addresses ahead of a working one,
|
|
57
|
+
* while a wake target is expected to be awake and reachable on its first or second
|
|
58
|
+
* address. 20 s is deliberately wider than one attempt timeout so a
|
|
56
59
|
* reachable peer whose signaling address is stale still gets a genuine try at
|
|
57
60
|
* its direct one; a peer needing longer than that is not "asleep and reachable",
|
|
58
61
|
* which is the only case a wake is for. The last attempt inside the budget gets
|
|
@@ -220,66 +223,31 @@ export class StrandWakeService {
|
|
|
220
223
|
* dropped.
|
|
221
224
|
*
|
|
222
225
|
* Throws if no address is dialable — with an error naming EVERY candidate and
|
|
223
|
-
* why it failed, not merely the last one. That
|
|
224
|
-
* with only the last candidate's message the
|
|
225
|
-
* signaling address, tried first) is
|
|
226
|
-
*
|
|
226
|
+
* why it failed, not merely the last one ({@link tryAddrsInTurn}). That
|
|
227
|
+
* distinction is not cosmetic: with only the last candidate's message the
|
|
228
|
+
* failure that mattered (usually the signaling address, tried first) is
|
|
229
|
+
* invisible outside a debug log, and the surfaced message points at whichever
|
|
230
|
+
* address happened to be tried last.
|
|
227
231
|
*
|
|
228
232
|
* The candidate loop is deliberately explicit rather than one
|
|
229
233
|
* `dialProtocol(addrs)` call. libp2p sorts any multi-address dial with
|
|
230
234
|
* `defaultAddressSorter`, whose `circuitRelayAddressesLast` pass would demote
|
|
231
235
|
* exactly the signaling address this ordering puts first — silently inverting
|
|
232
|
-
* it, with no per-dial sorter override to opt out of.
|
|
236
|
+
* it, with no per-dial sorter override to opt out of. For the same reason this
|
|
237
|
+
* does not use `dialPeerAddrs`, which puts relayed addresses last.
|
|
233
238
|
*/
|
|
234
239
|
export async function dialWake(node, addrs, request, options = {}) {
|
|
235
240
|
if (addrs.length === 0) {
|
|
236
241
|
throw new Error('No dialable address for wake target');
|
|
237
242
|
}
|
|
238
243
|
const protocolId = options.protocolId ?? WAKE_PROTOCOL;
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const remaining = deadline - Date.now();
|
|
247
|
-
if (remaining <= 0) {
|
|
248
|
-
failures.push({ addr, error: new Error(`not tried — the ${budgetMs}ms wake dial budget was spent on earlier addresses`) });
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
const attemptMs = Math.min(timeoutMs, remaining);
|
|
252
|
-
try {
|
|
253
|
-
// One deadline per attempt: its signal aborts the in-flight dialProtocol and
|
|
254
|
-
// resets the live stream, so neither the connect nor the ack-read leaks.
|
|
255
|
-
return await withDeadline(attemptMs, `Wake dial ${addr.toString()}`, (signal) => sendWake(node, addr, protocolId, request, attemptMs, signal));
|
|
256
|
-
}
|
|
257
|
-
catch (err) {
|
|
258
|
-
failures.push({ addr, error: err instanceof Error ? err : new Error(String(err)) });
|
|
259
|
-
log('Wake dial to %s failed: %o', addr.toString(), err);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
throw wakeDialError(failures);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Fold every candidate's failure into the one error {@link dialWake} throws.
|
|
266
|
-
*
|
|
267
|
-
* A single candidate throws its own error unchanged, so a one-address wake reads
|
|
268
|
-
* exactly as it always has (and `rejects.toThrow(/timed out/)` still means what
|
|
269
|
-
* it says). Several candidates produce one message naming each address and its
|
|
270
|
-
* cause, with the FIRST failure as `cause` — the first candidate is the
|
|
271
|
-
* signaling address, which is the one that matters when a relayed peer goes
|
|
272
|
-
* unreachable.
|
|
273
|
-
*/
|
|
274
|
-
function wakeDialError(failures) {
|
|
275
|
-
if (failures.length === 0) {
|
|
276
|
-
return new Error('Wake dial failed');
|
|
277
|
-
}
|
|
278
|
-
if (failures.length === 1) {
|
|
279
|
-
return failures[0].error;
|
|
280
|
-
}
|
|
281
|
-
const detail = failures.map((f) => `${f.addr.toString()} — ${f.error.message}`).join('; ');
|
|
282
|
-
return new Error(`Wake dial failed for all ${failures.length} candidate addresses: ${detail}`, { cause: failures[0].error });
|
|
244
|
+
const budget = {
|
|
245
|
+
perAddressMs: options.timeoutMs ?? DEFAULT_WAKE_TIMEOUT_MS,
|
|
246
|
+
totalMs: options.budgetMs ?? DEFAULT_WAKE_DIAL_BUDGET_MS,
|
|
247
|
+
};
|
|
248
|
+
// The attempt's signal aborts the in-flight dialProtocol and resets the live
|
|
249
|
+
// stream, so neither the connect nor the ack-read leaks.
|
|
250
|
+
return await tryAddrsInTurn(addrs, budget, 'Wake dial', (addr, signal, attemptMs) => sendWake(node, addr, protocolId, request, attemptMs, signal));
|
|
283
251
|
}
|
|
284
252
|
/**
|
|
285
253
|
* Open one stream, send the request, half-close, and read the ack.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-wake-protocol.js","sourceRoot":"","sources":["../src/strand-wake-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAsB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"strand-wake-protocol.js","sourceRoot":"","sources":["../src/strand-wake-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAsB,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE9C,oFAAoF;AACpF,MAAM,CAAC,MAAM,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1D,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,2BAA2B;KACzD,CAAC;IACF,6EAA6E;IAC7E,yDAAyD;IACzD,OAAO,MAAM,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAClF,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,QAAQ,CACrB,IAAY,EACZ,IAAe,EACf,UAAkB,EAClB,OAAoB,EACpB,SAAiB,EACjB,MAAmB;IAEnB,0EAA0E;IAC1E,0EAA0E;IAC1E,4EAA4E;IAC5E,6EAA6E;IAC7E,uDAAuD;IACvD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtG,MAAM,GAAG,GAAG,MAAM,aAAa,CAC7B,SAAqC,EACrC,MAAM,EACN,OAAO,EACP,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAU,MAAM,EAAE,SAAS,CAAC,EACjD,8BAA8B,CAC/B,CAAC;IAEF,GAAG,CAAC,yCAAyC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;IACjG,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/strand-watcher.js
CHANGED
|
@@ -110,7 +110,12 @@ export class StrandWatcher {
|
|
|
110
110
|
log('Error handling strand add for %s: %o', strand.Id, error);
|
|
111
111
|
// A failed launch leaves nothing running (StrandInstanceManager drops the
|
|
112
112
|
// record), so forget the strand and let a later poll retry it — gated by
|
|
113
|
-
// the backoff recorded here.
|
|
113
|
+
// the backoff recorded here. One case does leave something running: a row
|
|
114
|
+
// this machine published lands on an instance something else already
|
|
115
|
+
// attached, and honouring the founder request on it (CadreNode.launchStrand
|
|
116
|
+
// → StrandInstanceManager.foundExistingStrand) throws. The instance stays up
|
|
117
|
+
// as a joiner and the retry re-attempts the bootstrap on it, which is what
|
|
118
|
+
// should happen — but do not read the line above as "nothing is running".
|
|
114
119
|
this.knownStrands.delete(strand.Id);
|
|
115
120
|
this.provisional.delete(strand.Id);
|
|
116
121
|
this.recordFailure(strand.Id);
|
|
@@ -166,6 +171,12 @@ export class StrandWatcher {
|
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
catch (error) {
|
|
174
|
+
// NOTE: a machine cut off from its party before it ever received the `Strand` block
|
|
175
|
+
// fails this read `cohort-unreachable` on every poll and logs here (observed in
|
|
176
|
+
// `control-cohort-edge-carries-data`). Harmless: nothing was ever launched from a block
|
|
177
|
+
// this machine never held, and this catch keeps the known set. Do not answer it as
|
|
178
|
+
// empty the way `ControlDatabase.queryRevokedStamps` does for `Revocation` — an empty
|
|
179
|
+
// answer here runs the removed-strand loop above. Revisit if the log volume matters.
|
|
169
180
|
log('Error polling strands: %o', error);
|
|
170
181
|
}
|
|
171
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-watcher.js","sourceRoot":"","sources":["../src/strand-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,GAAG,GAAG,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAUjD;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AA0C3C;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAwBxB,YACE,SAA0B,EAC1B,SAAiC,EACjC,SAAuB,EAAE,IAAI,EAAE,KAAK,EAAE,EACtC,eAAuB,IAAI,EAC3B,YAA2B,EAC3B,MAAoB,IAAI,CAAC,GAAG;QAftB,iBAAY,GA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I,CAAC,SAAS,CAAC,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Await one step of a longer operation between two `sereus:cadre:timing` lines:
|
|
3
|
+
* `[<scope>:<id>] <step>: start` before it, then `<step>: <n>ms` — or
|
|
4
|
+
* `<step>: failed after <n>ms` — once it settles. The start line is what matters on a
|
|
5
|
+
* device: a step that never settles leaves a start with no matching end, so a trace
|
|
6
|
+
* names the step that hung rather than only the last one that finished.
|
|
7
|
+
*
|
|
8
|
+
* The text is built here rather than passed as `%s`/`%d` arguments: `debug`'s browser
|
|
9
|
+
* build, which React Native bundles, leaves placeholders for the console to fill, and
|
|
10
|
+
* RN's console prints them unfilled, so a device trace would read `[%s:%s] %s: start`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function timedStep<T>(scope: string, id: string, step: string, op: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
const timing = debug('sereus:cadre:timing');
|
|
3
|
+
/**
|
|
4
|
+
* Await one step of a longer operation between two `sereus:cadre:timing` lines:
|
|
5
|
+
* `[<scope>:<id>] <step>: start` before it, then `<step>: <n>ms` — or
|
|
6
|
+
* `<step>: failed after <n>ms` — once it settles. The start line is what matters on a
|
|
7
|
+
* device: a step that never settles leaves a start with no matching end, so a trace
|
|
8
|
+
* names the step that hung rather than only the last one that finished.
|
|
9
|
+
*
|
|
10
|
+
* The text is built here rather than passed as `%s`/`%d` arguments: `debug`'s browser
|
|
11
|
+
* build, which React Native bundles, leaves placeholders for the console to fill, and
|
|
12
|
+
* RN's console prints them unfilled, so a device trace would read `[%s:%s] %s: start`.
|
|
13
|
+
*/
|
|
14
|
+
export async function timedStep(scope, id, step, op) {
|
|
15
|
+
const label = `[${scope}:${id}] ${step}`;
|
|
16
|
+
timing(`${label}: start`);
|
|
17
|
+
const t0 = performance.now();
|
|
18
|
+
try {
|
|
19
|
+
const result = await op();
|
|
20
|
+
timing(`${label}: ${Math.round(performance.now() - t0)}ms`);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
timing(`${label}: failed after ${Math.round(performance.now() - t0)}ms`);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=timed-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timed-step.js","sourceRoot":"","sources":["../src/timed-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,KAAa,EAAE,EAAU,EAAE,IAAY,EAAE,EAAoB;IAC/F,MAAM,KAAK,GAAG,IAAI,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;IACzC,MAAM,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;IAC1B,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,KAAK,kBAAkB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACzE,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The timer seam shared by the strand bring-up loops that re-arm themselves one step at a
|
|
3
|
+
* time — the first-sync write gate's probe loop (`strand-first-sync-gate.ts`) and the
|
|
4
|
+
* membership reconciler's retry ladder (`strand-membership-reconciler.ts`). `setTimeout`
|
|
5
|
+
* rather than a repeating interval because the next step is armed only once the previous
|
|
6
|
+
* one settles, so a slow network read never stacks steps behind it, and because the delay
|
|
7
|
+
* can differ per step.
|
|
8
|
+
*
|
|
9
|
+
* Tests inject a hand-cranked clock; production omits it and gets real timers, `unref`'d so
|
|
10
|
+
* a loop that is only waiting never holds a Node process open (the call is optional —
|
|
11
|
+
* browsers and React Native return a plain handle with no `unref`).
|
|
12
|
+
*/
|
|
13
|
+
/** Timer seam for a self-rescheduling loop; omit for real (unref'd) timeouts. */
|
|
14
|
+
export interface TimeoutScheduler {
|
|
15
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
16
|
+
clearTimeout(handle: unknown): void;
|
|
17
|
+
}
|
|
18
|
+
/** Real timers, `unref`'d where the runtime supports it. */
|
|
19
|
+
export declare const defaultTimeoutScheduler: TimeoutScheduler;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The timer seam shared by the strand bring-up loops that re-arm themselves one step at a
|
|
3
|
+
* time — the first-sync write gate's probe loop (`strand-first-sync-gate.ts`) and the
|
|
4
|
+
* membership reconciler's retry ladder (`strand-membership-reconciler.ts`). `setTimeout`
|
|
5
|
+
* rather than a repeating interval because the next step is armed only once the previous
|
|
6
|
+
* one settles, so a slow network read never stacks steps behind it, and because the delay
|
|
7
|
+
* can differ per step.
|
|
8
|
+
*
|
|
9
|
+
* Tests inject a hand-cranked clock; production omits it and gets real timers, `unref`'d so
|
|
10
|
+
* a loop that is only waiting never holds a Node process open (the call is optional —
|
|
11
|
+
* browsers and React Native return a plain handle with no `unref`).
|
|
12
|
+
*/
|
|
13
|
+
/** Real timers, `unref`'d where the runtime supports it. */
|
|
14
|
+
export const defaultTimeoutScheduler = {
|
|
15
|
+
setTimeout: (fn, ms) => {
|
|
16
|
+
const handle = setTimeout(fn, ms);
|
|
17
|
+
handle.unref?.();
|
|
18
|
+
return handle;
|
|
19
|
+
},
|
|
20
|
+
clearTimeout: (handle) => clearTimeout(handle)
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=timeout-scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout-scheduler.js","sourceRoot":"","sources":["../src/timeout-scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACvD,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACjC,MAAiC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAA4C,CAAC;CACrF,CAAC"}
|