@streamr/dht 103.6.0-rc.0 → 103.7.0-rc.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/dist/exports-browser.cjs +76 -4
- package/dist/exports-browser.cjs.map +1 -1
- package/dist/exports-browser.d.ts +15 -10
- package/dist/exports-browser.js +75 -5
- package/dist/exports-browser.js.map +1 -1
- package/dist/exports-nodejs.cjs +66 -2
- package/dist/exports-nodejs.cjs.map +1 -1
- package/dist/exports-nodejs.d.ts +15 -10
- package/dist/exports-nodejs.js +65 -3
- package/dist/exports-nodejs.js.map +1 -1
- package/package.json +7 -7
package/dist/exports-nodejs.d.ts
CHANGED
|
@@ -344,8 +344,8 @@ declare class Timestamp$Type extends MessageType<Timestamp> {
|
|
|
344
344
|
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
345
345
|
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
346
346
|
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
347
|
-
* is required. A
|
|
348
|
-
* "Z") when printing the Timestamp type and a
|
|
347
|
+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
348
|
+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
349
349
|
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
350
350
|
*
|
|
351
351
|
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
@@ -367,18 +367,17 @@ declare class Timestamp$Type extends MessageType<Timestamp> {
|
|
|
367
367
|
*/
|
|
368
368
|
interface Timestamp {
|
|
369
369
|
/**
|
|
370
|
-
* Represents seconds of UTC time since Unix epoch
|
|
371
|
-
*
|
|
372
|
-
*
|
|
370
|
+
* Represents seconds of UTC time since Unix epoch
|
|
371
|
+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
372
|
+
* 9999-12-31T23:59:59Z inclusive.
|
|
373
373
|
*
|
|
374
374
|
* @generated from protobuf field: int64 seconds = 1
|
|
375
375
|
*/
|
|
376
376
|
seconds: number;
|
|
377
377
|
/**
|
|
378
|
-
* Non-negative fractions of a second at nanosecond resolution.
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
* values that count forward in time. Must be between 0 and 999,999,999
|
|
378
|
+
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
379
|
+
* second values with fractions must still have non-negative nanos values
|
|
380
|
+
* that count forward in time. Must be from 0 to 999,999,999
|
|
382
381
|
* inclusive.
|
|
383
382
|
*
|
|
384
383
|
* @generated from protobuf field: int32 nanos = 2
|
|
@@ -1322,5 +1321,11 @@ declare class Handshaker extends EventEmitter<HandshakerEvents> {
|
|
|
1322
1321
|
*/
|
|
1323
1322
|
declare function installWebrtcBridge(_worker: unknown): void;
|
|
1324
1323
|
|
|
1325
|
-
|
|
1324
|
+
declare function setGapDiagnosticsEnabled(val: boolean): void;
|
|
1325
|
+
declare function logGapDiagnosticSampled(layer: string, opts?: {
|
|
1326
|
+
detail?: Record<string, unknown>;
|
|
1327
|
+
outlierThresholdMs?: number;
|
|
1328
|
+
}): void;
|
|
1329
|
+
|
|
1330
|
+
export { ConnectionManager, ConnectionType, DataEntry, DefaultConnectorFacade, DhtCallContext, DhtNode, EXISTING_CONNECTION_TIMEOUT, LatencyType, ListeningRpcCommunicator, ManagedConnection, Message, NodeType, PeerDescriptor, PendingConnection, RoutingRpcCommunicator, RpcRemote, Simulator, SimulatorTransport, WebsocketClientConnection, areEqualPeerDescriptors, createOutgoingHandshaker, getRandomRegion, getRegionDelayMatrix, installWebrtcBridge, logGapDiagnosticSampled, randomDhtAddress, setGapDiagnosticsEnabled, toDhtAddress, toDhtAddressRaw, toNodeId };
|
|
1326
1331
|
export type { ConnectionLocker, ConnectionsView, DhtAddress, DhtAddressRaw, DhtNodeEvents, DhtNodeOptions, DhtRpcOptions, IConnection, ITransport, IceServer, LockID, PortRange, RingContacts, ServiceID, TlsCertificate, TransportEvents };
|
package/dist/exports-nodejs.js
CHANGED
|
@@ -249,6 +249,65 @@ class SendFailed extends Err {
|
|
|
249
249
|
constructor(message, originalError) { super(ErrorCode.SEND_FAILED, message, originalError); }
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
let enabled = false;
|
|
253
|
+
function setGapDiagnosticsEnabled(val) {
|
|
254
|
+
enabled = val;
|
|
255
|
+
globalThis.__dhtGapDiagEnabled = val;
|
|
256
|
+
}
|
|
257
|
+
const SUMMARY_INTERVAL_MS = 2000;
|
|
258
|
+
const accumulators = new Map();
|
|
259
|
+
function logGapDiagnosticSampled(layer, opts = {}) {
|
|
260
|
+
if (!enabled)
|
|
261
|
+
return;
|
|
262
|
+
const now = performance.now();
|
|
263
|
+
const threshold = opts.outlierThresholdMs ?? 30;
|
|
264
|
+
let acc = accumulators.get(layer);
|
|
265
|
+
if (acc === undefined) {
|
|
266
|
+
acc = { count: 0, sumDeltaMs: 0, maxDeltaMs: 0, outlierCount: 0, lastReportMs: now, lastEventMs: now };
|
|
267
|
+
accumulators.set(layer, acc);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const deltaMs = now - acc.lastEventMs;
|
|
271
|
+
acc.lastEventMs = now;
|
|
272
|
+
acc.count++;
|
|
273
|
+
if (deltaMs > acc.maxDeltaMs)
|
|
274
|
+
acc.maxDeltaMs = deltaMs;
|
|
275
|
+
acc.sumDeltaMs += deltaMs;
|
|
276
|
+
if (deltaMs > threshold)
|
|
277
|
+
acc.outlierCount++;
|
|
278
|
+
if (deltaMs > threshold) {
|
|
279
|
+
const payload = {
|
|
280
|
+
layer,
|
|
281
|
+
timestampMs: now,
|
|
282
|
+
deltaMs: +deltaMs.toFixed(2),
|
|
283
|
+
detail: opts.detail,
|
|
284
|
+
};
|
|
285
|
+
// eslint-disable-next-line no-console
|
|
286
|
+
console.log('[gap-diagnostics]', JSON.stringify(payload));
|
|
287
|
+
}
|
|
288
|
+
if (now - acc.lastReportMs >= SUMMARY_INTERVAL_MS) {
|
|
289
|
+
const summaryDetail = {
|
|
290
|
+
count: acc.count,
|
|
291
|
+
meanDeltaMs: acc.count > 0 ? +(acc.sumDeltaMs / acc.count).toFixed(2) : 0,
|
|
292
|
+
maxDeltaMs: +acc.maxDeltaMs.toFixed(2),
|
|
293
|
+
outlierCount: acc.outlierCount,
|
|
294
|
+
periodMs: +(now - acc.lastReportMs).toFixed(1),
|
|
295
|
+
};
|
|
296
|
+
const summary = {
|
|
297
|
+
layer: `${layer}.summary`,
|
|
298
|
+
timestampMs: now,
|
|
299
|
+
detail: summaryDetail,
|
|
300
|
+
};
|
|
301
|
+
// eslint-disable-next-line no-console
|
|
302
|
+
console.log('[gap-diagnostics]', JSON.stringify(summary));
|
|
303
|
+
acc.count = 0;
|
|
304
|
+
acc.sumDeltaMs = 0;
|
|
305
|
+
acc.maxDeltaMs = 0;
|
|
306
|
+
acc.outlierCount = 0;
|
|
307
|
+
acc.lastReportMs = now;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
252
311
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
253
312
|
class Empty$Type extends MessageType {
|
|
254
313
|
constructor() {
|
|
@@ -2293,6 +2352,7 @@ class ConnectionManager extends EventEmitter {
|
|
|
2293
2352
|
if ((this.state === ConnectionManagerState.STOPPED || this.state === ConnectionManagerState.STOPPING) && !opts.sendIfStopped) {
|
|
2294
2353
|
return;
|
|
2295
2354
|
}
|
|
2355
|
+
logGapDiagnosticSampled('dht.connMgr.send');
|
|
2296
2356
|
const peerDescriptor = message.targetDescriptor;
|
|
2297
2357
|
if (this.isConnectionToSelf(peerDescriptor)) {
|
|
2298
2358
|
throw new CannotConnectToSelf('Cannot send to self');
|
|
@@ -2368,6 +2428,7 @@ class ConnectionManager extends EventEmitter {
|
|
|
2368
2428
|
this.rpcCommunicator?.handleMessageFromPeer(message);
|
|
2369
2429
|
}
|
|
2370
2430
|
else {
|
|
2431
|
+
logGapDiagnosticSampled('dht.connMgr.emitMessage');
|
|
2371
2432
|
logger$B.trace('emit "message" ' + toNodeId(message.sourceDescriptor)
|
|
2372
2433
|
+ ' ' + message.serviceId + ' ' + message.messageId);
|
|
2373
2434
|
this.emit('message', message);
|
|
@@ -2377,6 +2438,7 @@ class ConnectionManager extends EventEmitter {
|
|
|
2377
2438
|
if (this.state === ConnectionManagerState.STOPPED) {
|
|
2378
2439
|
return;
|
|
2379
2440
|
}
|
|
2441
|
+
logGapDiagnosticSampled('dht.connMgr.onData');
|
|
2380
2442
|
this.metrics.receiveBytesPerSecond.record(data.byteLength);
|
|
2381
2443
|
this.metrics.receiveMessagesPerSecond.record(1);
|
|
2382
2444
|
let message;
|
|
@@ -2810,7 +2872,7 @@ const parseVersion = (version) => {
|
|
|
2810
2872
|
}
|
|
2811
2873
|
};
|
|
2812
2874
|
|
|
2813
|
-
var version = "103.
|
|
2875
|
+
var version = "103.7.0-rc.2";
|
|
2814
2876
|
|
|
2815
2877
|
const logger$z = new Logger('Handshaker');
|
|
2816
2878
|
// Optimally the Outgoing and Incoming Handshakers could be their own separate classes
|
|
@@ -5714,7 +5776,7 @@ class PeerDiscovery {
|
|
|
5714
5776
|
logger$d.debug(`Ring join on ${this.options.serviceId} timed out`);
|
|
5715
5777
|
}
|
|
5716
5778
|
finally {
|
|
5717
|
-
sessions.forEach((session) => this.
|
|
5779
|
+
sessions.forEach((session) => this.ongoingRingDiscoverySessions.delete(session.id));
|
|
5718
5780
|
}
|
|
5719
5781
|
}
|
|
5720
5782
|
async rejoinDht(entryPoint, contactedPeers = new Set(), distantJoinContactPeers = new Set()) {
|
|
@@ -7812,5 +7874,5 @@ function installWebrtcBridge(_worker) {
|
|
|
7812
7874
|
throw new Error('installWebrtcBridge is only supported in browser environments');
|
|
7813
7875
|
}
|
|
7814
7876
|
|
|
7815
|
-
export { ConnectionManager, ConnectionType, DataEntry, DefaultConnectorFacade, DhtCallContext, DhtNode, EXISTING_CONNECTION_TIMEOUT, LatencyType, ListeningRpcCommunicator, ManagedConnection, Message, NodeType, PeerDescriptor, PendingConnection, RoutingRpcCommunicator, RpcRemote, Simulator, SimulatorTransport, WebsocketClientConnection, areEqualPeerDescriptors, createOutgoingHandshaker, getRandomRegion, getRegionDelayMatrix, installWebrtcBridge, randomDhtAddress, toDhtAddress, toDhtAddressRaw, toNodeId };
|
|
7877
|
+
export { ConnectionManager, ConnectionType, DataEntry, DefaultConnectorFacade, DhtCallContext, DhtNode, EXISTING_CONNECTION_TIMEOUT, LatencyType, ListeningRpcCommunicator, ManagedConnection, Message, NodeType, PeerDescriptor, PendingConnection, RoutingRpcCommunicator, RpcRemote, Simulator, SimulatorTransport, WebsocketClientConnection, areEqualPeerDescriptors, createOutgoingHandshaker, getRandomRegion, getRegionDelayMatrix, installWebrtcBridge, logGapDiagnosticSampled, randomDhtAddress, setGapDiagnosticsEnabled, toDhtAddress, toDhtAddressRaw, toNodeId };
|
|
7816
7878
|
//# sourceMappingURL=exports-nodejs.js.map
|