@replit/river 0.23.5 → 0.23.7
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 +10 -3
- package/dist/{chunk-42ON4GTR.js → chunk-2KC75LS4.js} +2 -2
- package/dist/{chunk-SPP7ACQN.js → chunk-6LCL2ZZF.js} +18 -32
- package/dist/chunk-6LCL2ZZF.js.map +1 -0
- package/dist/{chunk-JJWZ5EHY.js → chunk-M3TGXFWT.js} +33 -31
- package/dist/chunk-M3TGXFWT.js.map +1 -0
- package/dist/{chunk-6GPJFN7T.js → chunk-MFF6IPBA.js} +24 -11
- package/dist/{chunk-6GPJFN7T.js.map → chunk-MFF6IPBA.js.map} +1 -1
- package/dist/{chunk-DZLXTSL5.js → chunk-RLVU5DRX.js} +2 -2
- package/dist/{chunk-N7OICPYR.js → chunk-XYFXRL7Q.js} +165 -101
- package/dist/chunk-XYFXRL7Q.js.map +1 -0
- package/dist/{connection-e257f6b7.d.ts → connection-6ce35bd5.d.ts} +1 -1
- package/dist/{connection-5331d77f.d.ts → connection-a3fdfa3a.d.ts} +1 -1
- package/dist/{index-926aea33.d.ts → index-60f03cb7.d.ts} +5 -2
- package/dist/logging/index.cjs +6 -73
- package/dist/logging/index.cjs.map +1 -1
- package/dist/logging/index.d.cts +1 -1
- package/dist/logging/index.d.ts +1 -1
- package/dist/logging/index.js +1 -3
- package/dist/router/index.cjs +47 -33
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +6 -6
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.js +2 -3
- package/dist/{services-3f99f5d2.d.ts → services-fd8a9894.d.ts} +2 -2
- package/dist/transport/impls/uds/client.cjs +195 -81
- package/dist/transport/impls/uds/client.cjs.map +1 -1
- package/dist/transport/impls/uds/client.d.cts +3 -3
- package/dist/transport/impls/uds/client.d.ts +3 -3
- package/dist/transport/impls/uds/client.js +5 -7
- package/dist/transport/impls/uds/client.js.map +1 -1
- package/dist/transport/impls/uds/server.cjs +170 -73
- package/dist/transport/impls/uds/server.cjs.map +1 -1
- package/dist/transport/impls/uds/server.d.cts +3 -3
- package/dist/transport/impls/uds/server.d.ts +3 -3
- package/dist/transport/impls/uds/server.js +4 -4
- package/dist/transport/impls/ws/client.cjs +194 -80
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +3 -3
- package/dist/transport/impls/ws/client.d.ts +3 -3
- package/dist/transport/impls/ws/client.js +6 -8
- package/dist/transport/impls/ws/client.js.map +1 -1
- package/dist/transport/impls/ws/server.cjs +170 -73
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +3 -3
- package/dist/transport/impls/ws/server.d.ts +3 -3
- package/dist/transport/impls/ws/server.js +4 -4
- package/dist/transport/index.cjs +219 -105
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/transport/index.js +3 -3
- package/dist/{transport-cbe70659.d.ts → transport-3d34f714.d.ts} +11 -6
- package/dist/util/testHelpers.cjs +27 -18
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +5 -4
- package/dist/util/testHelpers.d.ts +5 -4
- package/dist/util/testHelpers.js +5 -4
- package/dist/util/testHelpers.js.map +1 -1
- package/package.json +5 -3
- package/dist/chunk-JJWZ5EHY.js.map +0 -1
- package/dist/chunk-N7OICPYR.js.map +0 -1
- package/dist/chunk-SPP7ACQN.js.map +0 -1
- /package/dist/{chunk-42ON4GTR.js.map → chunk-2KC75LS4.js.map} +0 -0
- /package/dist/{chunk-DZLXTSL5.js.map → chunk-RLVU5DRX.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as Codec } from './types-3e5768ec.js';
|
|
2
|
-
import { a as TelemetryInfo, T as TransportClientId, b as PropagationContext,
|
|
2
|
+
import { a as TelemetryInfo, M as MessageMetadata, T as TransportClientId, b as PropagationContext, L as Logger, P as PartialTransportMessage, c as TransportMessage, O as OpaqueTransportMessage, g as LogFn, h as LoggingLevel } from './index-60f03cb7.js';
|
|
3
3
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -12,6 +12,7 @@ declare abstract class Connection {
|
|
|
12
12
|
id: string;
|
|
13
13
|
telemetry?: TelemetryInfo;
|
|
14
14
|
constructor();
|
|
15
|
+
get loggingMetadata(): MessageMetadata;
|
|
15
16
|
/**
|
|
16
17
|
* Handle adding a callback for when a message is received.
|
|
17
18
|
* @param msg The message that was received.
|
|
@@ -26,7 +27,7 @@ declare abstract class Connection {
|
|
|
26
27
|
abstract addCloseListener(cb: () => void): void;
|
|
27
28
|
/**
|
|
28
29
|
* Handle adding a callback for when an error is received.
|
|
29
|
-
* This should only be used for logging errors, all cleanup
|
|
30
|
+
* This should only be used for this.logging errors, all cleanup
|
|
30
31
|
* should be delegated to addCloseListener.
|
|
31
32
|
*
|
|
32
33
|
* The implementer should take care such that the implemented
|
|
@@ -117,8 +118,10 @@ declare class Session<ConnType extends Connection> {
|
|
|
117
118
|
* The interval for sending heartbeats.
|
|
118
119
|
*/
|
|
119
120
|
private heartbeat;
|
|
121
|
+
private log?;
|
|
120
122
|
constructor(conn: ConnType | undefined, from: TransportClientId, to: TransportClientId, options: SessionOptions, propagationCtx?: PropagationContext);
|
|
121
|
-
|
|
123
|
+
bindLogger(log: Logger): void;
|
|
124
|
+
get loggingMetadata(): MessageMetadata;
|
|
122
125
|
/**
|
|
123
126
|
* Sends a message over the session's connection.
|
|
124
127
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
@@ -391,6 +394,7 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
391
394
|
* The options for this transport.
|
|
392
395
|
*/
|
|
393
396
|
protected options: TransportOptions;
|
|
397
|
+
log?: Logger;
|
|
394
398
|
/**
|
|
395
399
|
* Creates a new Transport instance.
|
|
396
400
|
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
@@ -398,6 +402,7 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
398
402
|
* @param clientId The client ID of this transport.
|
|
399
403
|
*/
|
|
400
404
|
constructor(clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
|
|
405
|
+
bindLogger(fn: LogFn | Logger, level?: LoggingLevel): void;
|
|
401
406
|
/**
|
|
402
407
|
* This is called immediately after a new connection is established and we
|
|
403
408
|
* may or may not know the identity of the connected client.
|
|
@@ -430,13 +435,13 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
430
435
|
* @param msg The message to parse.
|
|
431
436
|
* @returns The parsed message, or null if the message is malformed or invalid.
|
|
432
437
|
*/
|
|
433
|
-
protected parseMsg(msg: Uint8Array): OpaqueTransportMessage | null;
|
|
438
|
+
protected parseMsg(msg: Uint8Array, conn: ConnType): OpaqueTransportMessage | null;
|
|
434
439
|
/**
|
|
435
440
|
* Called when a message is received by this transport.
|
|
436
441
|
* You generally shouldn't need to override this in downstream transport implementations.
|
|
437
442
|
* @param msg The received message.
|
|
438
443
|
*/
|
|
439
|
-
protected handleMsg(msg: OpaqueTransportMessage): void;
|
|
444
|
+
protected handleMsg(msg: OpaqueTransportMessage, conn: ConnType): void;
|
|
440
445
|
/**
|
|
441
446
|
* Adds a listener to this transport.
|
|
442
447
|
* @param the type of event to listen for
|
|
@@ -534,4 +539,4 @@ declare abstract class ServerTransport<ConnType extends Connection> extends Tran
|
|
|
534
539
|
receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): Promise<Session<ConnType> | false>;
|
|
535
540
|
}
|
|
536
541
|
|
|
537
|
-
export { Connection as C, EventMap as E, ProvidedClientTransportOptions as P, SessionOptions as S, Transport as T,
|
|
542
|
+
export { Connection as C, EventMap as E, ProvidedClientTransportOptions as P, SessionOptions as S, Transport as T, Session as a, ServiceContext as b, ClientTransport as c, ServerTransport as d, ProvidedServerTransportOptions as e, ServerHandshakeOptions as f, ParsedMetadata as g, ServiceContextWithState as h, ServiceContextWithTransportInfo as i, createClientHandshakeOptions as j, createServerHandshakeOptions as k, ClientHandshakeOptions as l, ProvidedTransportOptions as m, TransportStatus as n, EventTypes as o, EventHandler as p, ProtocolError as q, ProtocolErrorType as r };
|
|
@@ -37,6 +37,7 @@ __export(testHelpers_exports, {
|
|
|
37
37
|
createDummyTransportMessage: () => createDummyTransportMessage,
|
|
38
38
|
createLocalWebSocketClient: () => createLocalWebSocketClient,
|
|
39
39
|
createWebSocketServer: () => createWebSocketServer,
|
|
40
|
+
dummySession: () => dummySession,
|
|
40
41
|
getUnixSocketPath: () => getUnixSocketPath,
|
|
41
42
|
iterNext: () => iterNext,
|
|
42
43
|
onUdsServeReady: () => onUdsServeReady,
|
|
@@ -348,18 +349,15 @@ function Err(error) {
|
|
|
348
349
|
};
|
|
349
350
|
}
|
|
350
351
|
|
|
351
|
-
// logging/log.ts
|
|
352
|
-
var log = void 0;
|
|
353
|
-
|
|
354
352
|
// tracing/index.ts
|
|
355
353
|
var import_api = require("@opentelemetry/api");
|
|
356
354
|
|
|
357
355
|
// package.json
|
|
358
|
-
var version = "0.23.
|
|
356
|
+
var version = "0.23.7";
|
|
359
357
|
|
|
360
358
|
// tracing/index.ts
|
|
361
359
|
function createSessionTelemetryInfo(session, propagationCtx) {
|
|
362
|
-
const
|
|
360
|
+
const parentCtx = propagationCtx ? import_api.propagation.extract(import_api.context.active(), propagationCtx) : import_api.context.active();
|
|
363
361
|
const span = tracer.startSpan(
|
|
364
362
|
`session ${session.id}`,
|
|
365
363
|
{
|
|
@@ -370,8 +368,9 @@ function createSessionTelemetryInfo(session, propagationCtx) {
|
|
|
370
368
|
"river.session.from": session.from
|
|
371
369
|
}
|
|
372
370
|
},
|
|
373
|
-
|
|
371
|
+
parentCtx
|
|
374
372
|
);
|
|
373
|
+
const ctx = import_api.trace.setSpan(parentCtx, span);
|
|
375
374
|
return { span, ctx };
|
|
376
375
|
}
|
|
377
376
|
var tracer = import_api.trace.getTracer("river", version);
|
|
@@ -436,6 +435,7 @@ var Session = class {
|
|
|
436
435
|
* The interval for sending heartbeats.
|
|
437
436
|
*/
|
|
438
437
|
heartbeat;
|
|
438
|
+
log;
|
|
439
439
|
constructor(conn, from, to, options, propagationCtx) {
|
|
440
440
|
this.id = `session-${nanoid(12)}`;
|
|
441
441
|
this.options = options;
|
|
@@ -450,12 +450,20 @@ var Session = class {
|
|
|
450
450
|
);
|
|
451
451
|
this.telemetry = createSessionTelemetryInfo(this, propagationCtx);
|
|
452
452
|
}
|
|
453
|
+
bindLogger(log) {
|
|
454
|
+
this.log = log;
|
|
455
|
+
}
|
|
453
456
|
get loggingMetadata() {
|
|
457
|
+
const spanContext = this.telemetry.span.spanContext();
|
|
454
458
|
return {
|
|
455
459
|
clientId: this.from,
|
|
456
460
|
connectedTo: this.to,
|
|
457
461
|
sessionId: this.id,
|
|
458
|
-
connId: this.connection?.id
|
|
462
|
+
connId: this.connection?.id,
|
|
463
|
+
telemetry: {
|
|
464
|
+
traceId: spanContext.traceId,
|
|
465
|
+
spanId: spanContext.spanId
|
|
466
|
+
}
|
|
459
467
|
};
|
|
460
468
|
}
|
|
461
469
|
/**
|
|
@@ -468,7 +476,7 @@ var Session = class {
|
|
|
468
476
|
*/
|
|
469
477
|
send(msg) {
|
|
470
478
|
const fullMsg = this.constructMsg(msg);
|
|
471
|
-
log?.debug(`sending msg`, {
|
|
479
|
+
this.log?.debug(`sending msg`, {
|
|
472
480
|
...this.loggingMetadata,
|
|
473
481
|
transportMessage: fullMsg
|
|
474
482
|
});
|
|
@@ -476,7 +484,7 @@ var Session = class {
|
|
|
476
484
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
477
485
|
if (ok)
|
|
478
486
|
return fullMsg.id;
|
|
479
|
-
log?.info(
|
|
487
|
+
this.log?.info(
|
|
480
488
|
`failed to send msg to ${fullMsg.to}, connection is probably dead`,
|
|
481
489
|
{
|
|
482
490
|
...this.loggingMetadata,
|
|
@@ -484,8 +492,8 @@ var Session = class {
|
|
|
484
492
|
}
|
|
485
493
|
);
|
|
486
494
|
} else {
|
|
487
|
-
log?.
|
|
488
|
-
`
|
|
495
|
+
this.log?.debug(
|
|
496
|
+
`buffering msg to ${fullMsg.to}, connection not ready yet`,
|
|
489
497
|
{ ...this.loggingMetadata, transportMessage: fullMsg }
|
|
490
498
|
);
|
|
491
499
|
}
|
|
@@ -496,7 +504,7 @@ var Session = class {
|
|
|
496
504
|
const missDuration = misses * this.options.heartbeatIntervalMs;
|
|
497
505
|
if (misses > this.options.heartbeatsUntilDead) {
|
|
498
506
|
if (this.connection) {
|
|
499
|
-
log?.info(
|
|
507
|
+
this.log?.info(
|
|
500
508
|
`closing connection to ${this.to} due to inactivity (missed ${misses} heartbeats which is ${missDuration}ms)`,
|
|
501
509
|
this.loggingMetadata
|
|
502
510
|
);
|
|
@@ -520,12 +528,12 @@ var Session = class {
|
|
|
520
528
|
this.ack = 0;
|
|
521
529
|
}
|
|
522
530
|
sendBufferedMessages(conn) {
|
|
523
|
-
log?.info(`resending ${this.sendBuffer.length} buffered messages`, {
|
|
531
|
+
this.log?.info(`resending ${this.sendBuffer.length} buffered messages`, {
|
|
524
532
|
...this.loggingMetadata,
|
|
525
533
|
connId: conn.id
|
|
526
534
|
});
|
|
527
535
|
for (const msg of this.sendBuffer) {
|
|
528
|
-
log?.debug(`resending msg`, {
|
|
536
|
+
this.log?.debug(`resending msg`, {
|
|
529
537
|
...this.loggingMetadata,
|
|
530
538
|
transportMessage: msg,
|
|
531
539
|
connId: conn.id
|
|
@@ -537,7 +545,7 @@ var Session = class {
|
|
|
537
545
|
code: import_api2.SpanStatusCode.ERROR,
|
|
538
546
|
message: errMsg
|
|
539
547
|
});
|
|
540
|
-
log?.error(errMsg, {
|
|
548
|
+
this.log?.error(errMsg, {
|
|
541
549
|
...this.loggingMetadata,
|
|
542
550
|
transportMessage: msg,
|
|
543
551
|
connId: conn.id,
|
|
@@ -550,7 +558,7 @@ var Session = class {
|
|
|
550
558
|
}
|
|
551
559
|
updateBookkeeping(ack, seq) {
|
|
552
560
|
if (seq + 1 < this.ack) {
|
|
553
|
-
log?.error(`received stale seq ${seq} + 1 < ${this.ack}`, {
|
|
561
|
+
this.log?.error(`received stale seq ${seq} + 1 < ${this.ack}`, {
|
|
554
562
|
...this.loggingMetadata,
|
|
555
563
|
tags: ["invariant-violation"]
|
|
556
564
|
});
|
|
@@ -562,7 +570,7 @@ var Session = class {
|
|
|
562
570
|
closeStaleConnection(conn) {
|
|
563
571
|
if (this.connection === void 0 || this.connection === conn)
|
|
564
572
|
return;
|
|
565
|
-
log?.info(
|
|
573
|
+
this.log?.info(
|
|
566
574
|
`closing old inner connection from session to ${this.to}`,
|
|
567
575
|
this.loggingMetadata
|
|
568
576
|
);
|
|
@@ -576,7 +584,7 @@ var Session = class {
|
|
|
576
584
|
this.connection = newConn;
|
|
577
585
|
}
|
|
578
586
|
beginGrace(cb) {
|
|
579
|
-
log?.info(
|
|
587
|
+
this.log?.info(
|
|
580
588
|
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
581
589
|
this.loggingMetadata
|
|
582
590
|
);
|
|
@@ -840,6 +848,7 @@ var getUnixSocketPath = () => {
|
|
|
840
848
|
createDummyTransportMessage,
|
|
841
849
|
createLocalWebSocketClient,
|
|
842
850
|
createWebSocketServer,
|
|
851
|
+
dummySession,
|
|
843
852
|
getUnixSocketPath,
|
|
844
853
|
iterNext,
|
|
845
854
|
onUdsServeReady,
|