@replit/river 0.202.0 → 0.203.1
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/{chunk-BDUOHZMF.js → chunk-2FHJVQBE.js} +2 -2
- package/dist/{chunk-2T22KY5X.js → chunk-7MKTFUJO.js} +3 -3
- package/dist/{chunk-QMXUCLGE.js → chunk-AK7NTFAM.js} +31 -10
- package/dist/{chunk-QMXUCLGE.js.map → chunk-AK7NTFAM.js.map} +1 -1
- package/dist/{chunk-NSH4D6OB.js → chunk-T4WWG42M.js} +13 -3
- package/dist/chunk-T4WWG42M.js.map +1 -0
- package/dist/{chunk-W4AGHFXK.js → chunk-TMOCPK63.js} +18 -8
- package/dist/chunk-TMOCPK63.js.map +1 -0
- package/dist/{chunk-LHH5LQ7C.js → chunk-WBGKPIFS.js} +11 -1
- package/dist/chunk-WBGKPIFS.js.map +1 -0
- package/dist/{client-a32692b0.d.ts → client-5d2e41a3.d.ts} +7 -1
- package/dist/{connection-48d021ca.d.ts → connection-11a4af0f.d.ts} +1 -1
- package/dist/{context-8d263a7f.d.ts → context-d6dd8a1a.d.ts} +14 -0
- package/dist/logging/index.cjs +1 -0
- package/dist/logging/index.cjs.map +1 -1
- package/dist/logging/index.js +1 -1
- package/dist/router/index.cjs +91 -103
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +7 -7
- package/dist/router/index.d.ts +7 -7
- package/dist/router/index.js +78 -95
- package/dist/router/index.js.map +1 -1
- package/dist/{server-48d90a77.d.ts → server-e46399f9.d.ts} +1 -1
- package/dist/{services-a05f5174.d.ts → services-56cbea0d.d.ts} +2 -2
- package/dist/testUtil/index.cjs +55 -11
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +5 -5
- package/dist/testUtil/index.d.ts +5 -5
- package/dist/testUtil/index.js +5 -5
- package/dist/transport/impls/ws/client.cjs +60 -16
- 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 +5 -5
- package/dist/transport/impls/ws/server.cjs +48 -14
- 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 +5 -5
- package/dist/transport/index.cjs +62 -18
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +4 -4
- package/dist/transport/index.d.ts +4 -4
- package/dist/transport/index.js +5 -5
- package/package.json +2 -2
- package/dist/chunk-LHH5LQ7C.js.map +0 -1
- package/dist/chunk-NSH4D6OB.js.map +0 -1
- package/dist/chunk-W4AGHFXK.js.map +0 -1
- /package/dist/{chunk-BDUOHZMF.js.map → chunk-2FHJVQBE.js.map} +0 -0
- /package/dist/{chunk-2T22KY5X.js.map → chunk-7MKTFUJO.js.map} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { b as ProvidedClientTransportOptions, c as ProvidedServerTransportOptions, n as ClientHandshakeOptions, C as Connection, r as ServerHandshakeOptions, T as Transport, A as SessionOptions, m as ClientTransportOptions, e as SessionNoConnection, B as SessionBoundSendFn } from '../context-
|
|
2
|
-
import { C as ClientTransport } from '../client-
|
|
3
|
-
import { S as ServerTransport } from '../server-
|
|
1
|
+
import { b as ProvidedClientTransportOptions, c as ProvidedServerTransportOptions, n as ClientHandshakeOptions, C as Connection, r as ServerHandshakeOptions, T as Transport, A as SessionOptions, m as ClientTransportOptions, e as SessionNoConnection, B as SessionBoundSendFn } from '../context-d6dd8a1a.js';
|
|
2
|
+
import { C as ClientTransport } from '../client-5d2e41a3.js';
|
|
3
|
+
import { S as ServerTransport } from '../server-e46399f9.js';
|
|
4
4
|
import { c as TransportClientId, f as PartialTransportMessage, b as OpaqueTransportMessage } from '../message-3def9ded.js';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
|
-
import { E as BaseErrorSchemaType, u as Readable, X as ReadableIterator, Y as ReadableResult } from '../services-
|
|
6
|
+
import { E as BaseErrorSchemaType, u as Readable, X as ReadableIterator, Y as ReadableResult } from '../services-56cbea0d.js';
|
|
7
7
|
import NodeWs from 'ws';
|
|
8
8
|
import http from 'node:http';
|
|
9
9
|
import { W as WsLike } from '../wslike-e0b32dd5.js';
|
|
10
10
|
import { Duplex } from 'node:stream';
|
|
11
11
|
import '@sinclair/typebox/errors';
|
|
12
|
+
import '@opentelemetry/api';
|
|
12
13
|
import '../types-3e5768ec.js';
|
|
13
14
|
import '@sinclair/typebox/value';
|
|
14
|
-
import '@opentelemetry/api';
|
|
15
15
|
|
|
16
16
|
interface TestTransportOptions {
|
|
17
17
|
client?: ProvidedClientTransportOptions;
|
package/dist/testUtil/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { b as ProvidedClientTransportOptions, c as ProvidedServerTransportOptions, n as ClientHandshakeOptions, C as Connection, r as ServerHandshakeOptions, T as Transport, A as SessionOptions, m as ClientTransportOptions, e as SessionNoConnection, B as SessionBoundSendFn } from '../context-
|
|
2
|
-
import { C as ClientTransport } from '../client-
|
|
3
|
-
import { S as ServerTransport } from '../server-
|
|
1
|
+
import { b as ProvidedClientTransportOptions, c as ProvidedServerTransportOptions, n as ClientHandshakeOptions, C as Connection, r as ServerHandshakeOptions, T as Transport, A as SessionOptions, m as ClientTransportOptions, e as SessionNoConnection, B as SessionBoundSendFn } from '../context-d6dd8a1a.js';
|
|
2
|
+
import { C as ClientTransport } from '../client-5d2e41a3.js';
|
|
3
|
+
import { S as ServerTransport } from '../server-e46399f9.js';
|
|
4
4
|
import { c as TransportClientId, f as PartialTransportMessage, b as OpaqueTransportMessage } from '../message-3def9ded.js';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
|
-
import { E as BaseErrorSchemaType, u as Readable, X as ReadableIterator, Y as ReadableResult } from '../services-
|
|
6
|
+
import { E as BaseErrorSchemaType, u as Readable, X as ReadableIterator, Y as ReadableResult } from '../services-56cbea0d.js';
|
|
7
7
|
import NodeWs from 'ws';
|
|
8
8
|
import http from 'node:http';
|
|
9
9
|
import { W as WsLike } from '../wslike-e0b32dd5.js';
|
|
10
10
|
import { Duplex } from 'node:stream';
|
|
11
11
|
import '@sinclair/typebox/errors';
|
|
12
|
+
import '@opentelemetry/api';
|
|
12
13
|
import '../types-3e5768ec.js';
|
|
13
14
|
import '@sinclair/typebox/value';
|
|
14
|
-
import '@opentelemetry/api';
|
|
15
15
|
|
|
16
16
|
interface TestTransportOptions {
|
|
17
17
|
client?: ProvidedClientTransportOptions;
|
package/dist/testUtil/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientTransport
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-T4WWG42M.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-7MKTFUJO.js";
|
|
7
7
|
import {
|
|
8
8
|
Connection,
|
|
9
9
|
SessionStateGraph,
|
|
10
10
|
defaultClientTransportOptions,
|
|
11
11
|
defaultTransportOptions
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-TMOCPK63.js";
|
|
13
13
|
import {
|
|
14
14
|
currentProtocolVersion
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-AK7NTFAM.js";
|
|
16
|
+
import "../chunk-WBGKPIFS.js";
|
|
17
17
|
import "../chunk-AJGIY2UB.js";
|
|
18
18
|
|
|
19
19
|
// testUtil/index.ts
|
|
@@ -25,7 +25,7 @@ __export(client_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(client_exports);
|
|
26
26
|
|
|
27
27
|
// transport/client.ts
|
|
28
|
-
var
|
|
28
|
+
var import_api4 = require("@opentelemetry/api");
|
|
29
29
|
|
|
30
30
|
// transport/message.ts
|
|
31
31
|
var import_typebox = require("@sinclair/typebox");
|
|
@@ -299,6 +299,7 @@ var LeakyBucketRateLimit = class {
|
|
|
299
299
|
};
|
|
300
300
|
|
|
301
301
|
// logging/log.ts
|
|
302
|
+
var import_api = require("@opentelemetry/api");
|
|
302
303
|
var LoggingLevels = {
|
|
303
304
|
debug: -1,
|
|
304
305
|
info: 0,
|
|
@@ -307,6 +308,15 @@ var LoggingLevels = {
|
|
|
307
308
|
};
|
|
308
309
|
var cleanedLogFn = (log) => {
|
|
309
310
|
return (msg, metadata) => {
|
|
311
|
+
if (metadata && !metadata.telemetry) {
|
|
312
|
+
const span = import_api.trace.getSpan(import_api.context.active());
|
|
313
|
+
if (span) {
|
|
314
|
+
metadata.telemetry = {
|
|
315
|
+
traceId: span.spanContext().traceId,
|
|
316
|
+
spanId: span.spanContext().spanId
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
310
320
|
if (!metadata?.transportMessage) {
|
|
311
321
|
log(msg, metadata);
|
|
312
322
|
return;
|
|
@@ -398,6 +408,14 @@ var StateMachineState = class {
|
|
|
398
408
|
* and we've moved on to another state
|
|
399
409
|
*/
|
|
400
410
|
_isConsumed;
|
|
411
|
+
/**
|
|
412
|
+
* Cleanup this state machine state and mark it as consumed.
|
|
413
|
+
* After calling close, it is an error to access any properties on the state.
|
|
414
|
+
* You should never need to call this as a consumer.
|
|
415
|
+
*
|
|
416
|
+
* If you're looking to close the session from the client,
|
|
417
|
+
* use `.hardDisconnect` on the client transport.
|
|
418
|
+
*/
|
|
401
419
|
close() {
|
|
402
420
|
this._handleClose();
|
|
403
421
|
}
|
|
@@ -452,9 +470,8 @@ var CommonSession = class extends StateMachineState {
|
|
|
452
470
|
parseMsg(msg) {
|
|
453
471
|
const parsedMsg = this.options.codec.fromBuffer(msg);
|
|
454
472
|
if (parsedMsg === null) {
|
|
455
|
-
const decodedBuffer = new TextDecoder().decode(Buffer.from(msg));
|
|
456
473
|
this.log?.error(
|
|
457
|
-
`received malformed msg: ${
|
|
474
|
+
`received malformed msg: ${Buffer.from(msg).toString("base64")}`,
|
|
458
475
|
this.loggingMetadata
|
|
459
476
|
);
|
|
460
477
|
return null;
|
|
@@ -498,13 +515,13 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
498
515
|
this.protocolVersion = protocolVersion;
|
|
499
516
|
}
|
|
500
517
|
get loggingMetadata() {
|
|
501
|
-
const spanContext = this.telemetry.span.spanContext();
|
|
502
518
|
const metadata = {
|
|
503
519
|
clientId: this.from,
|
|
504
520
|
connectedTo: this.to,
|
|
505
521
|
sessionId: this.id
|
|
506
522
|
};
|
|
507
523
|
if (this.telemetry.span.isRecording()) {
|
|
524
|
+
const spanContext = this.telemetry.span.spanContext();
|
|
508
525
|
metadata.telemetry = {
|
|
509
526
|
traceId: spanContext.traceId,
|
|
510
527
|
spanId: spanContext.spanId
|
|
@@ -631,10 +648,10 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
|
|
|
631
648
|
};
|
|
632
649
|
|
|
633
650
|
// tracing/index.ts
|
|
634
|
-
var
|
|
651
|
+
var import_api2 = require("@opentelemetry/api");
|
|
635
652
|
|
|
636
653
|
// package.json
|
|
637
|
-
var version = "0.
|
|
654
|
+
var version = "0.203.1";
|
|
638
655
|
|
|
639
656
|
// tracing/index.ts
|
|
640
657
|
function getPropagationContext(ctx) {
|
|
@@ -642,11 +659,11 @@ function getPropagationContext(ctx) {
|
|
|
642
659
|
traceparent: "",
|
|
643
660
|
tracestate: ""
|
|
644
661
|
};
|
|
645
|
-
|
|
662
|
+
import_api2.propagation.inject(ctx, tracing);
|
|
646
663
|
return tracing;
|
|
647
664
|
}
|
|
648
665
|
function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
|
|
649
|
-
const parentCtx = propagationCtx ?
|
|
666
|
+
const parentCtx = propagationCtx ? import_api2.propagation.extract(import_api2.context.active(), propagationCtx) : import_api2.context.active();
|
|
650
667
|
const span = tracer.startSpan(
|
|
651
668
|
`session ${sessionId}`,
|
|
652
669
|
{
|
|
@@ -659,10 +676,25 @@ function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
|
|
|
659
676
|
},
|
|
660
677
|
parentCtx
|
|
661
678
|
);
|
|
662
|
-
const ctx =
|
|
679
|
+
const ctx = import_api2.trace.setSpan(parentCtx, span);
|
|
680
|
+
return { span, ctx };
|
|
681
|
+
}
|
|
682
|
+
function createConnectionTelemetryInfo(connection, info) {
|
|
683
|
+
const span = tracer.startSpan(
|
|
684
|
+
`connection ${connection.id}`,
|
|
685
|
+
{
|
|
686
|
+
attributes: {
|
|
687
|
+
component: "river",
|
|
688
|
+
"river.connection.id": connection.id
|
|
689
|
+
},
|
|
690
|
+
links: [{ context: info.span.spanContext() }]
|
|
691
|
+
},
|
|
692
|
+
info.ctx
|
|
693
|
+
);
|
|
694
|
+
const ctx = import_api2.trace.setSpan(info.ctx, span);
|
|
663
695
|
return { span, ctx };
|
|
664
696
|
}
|
|
665
|
-
var tracer =
|
|
697
|
+
var tracer = import_api2.trace.getTracer("river", version);
|
|
666
698
|
var tracing_default = tracer;
|
|
667
699
|
|
|
668
700
|
// transport/sessionStateMachine/SessionWaitingForHandshake.ts
|
|
@@ -769,7 +801,7 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
|
769
801
|
};
|
|
770
802
|
|
|
771
803
|
// transport/sessionStateMachine/SessionConnected.ts
|
|
772
|
-
var
|
|
804
|
+
var import_api3 = require("@opentelemetry/api");
|
|
773
805
|
var SessionConnected = class extends IdentifiedSession {
|
|
774
806
|
state = "Connected" /* Connected */;
|
|
775
807
|
conn;
|
|
@@ -873,7 +905,7 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
873
905
|
tags: ["invariant-violation"]
|
|
874
906
|
});
|
|
875
907
|
this.telemetry.span.setStatus({
|
|
876
|
-
code:
|
|
908
|
+
code: import_api3.SpanStatusCode.ERROR,
|
|
877
909
|
message: reason
|
|
878
910
|
});
|
|
879
911
|
this.closeConnection();
|
|
@@ -1045,6 +1077,7 @@ var SessionStateGraph = {
|
|
|
1045
1077
|
listeners,
|
|
1046
1078
|
...carriedState
|
|
1047
1079
|
});
|
|
1080
|
+
conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
|
|
1048
1081
|
session.log?.info(
|
|
1049
1082
|
`session ${session.id} transition from Connecting to Handshaking`,
|
|
1050
1083
|
{
|
|
@@ -1105,6 +1138,7 @@ var SessionStateGraph = {
|
|
|
1105
1138
|
listeners,
|
|
1106
1139
|
...carriedState
|
|
1107
1140
|
});
|
|
1141
|
+
conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
|
|
1108
1142
|
session.log?.info(
|
|
1109
1143
|
`session ${session.id} transition from WaitingForHandshake to Connected`,
|
|
1110
1144
|
{
|
|
@@ -1575,7 +1609,7 @@ var ClientTransport = class extends Transport {
|
|
|
1575
1609
|
}
|
|
1576
1610
|
rejectHandshakeResponse(session, reason, metadata) {
|
|
1577
1611
|
session.conn.telemetry?.span.setStatus({
|
|
1578
|
-
code:
|
|
1612
|
+
code: import_api4.SpanStatusCode.ERROR,
|
|
1579
1613
|
message: reason
|
|
1580
1614
|
});
|
|
1581
1615
|
this.log?.warn(reason, metadata);
|
|
@@ -1705,6 +1739,16 @@ var ClientTransport = class extends Transport {
|
|
|
1705
1739
|
);
|
|
1706
1740
|
this.updateSession(backingOffSession);
|
|
1707
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Manually kills all sessions to the server (including all pending state).
|
|
1744
|
+
* This is useful for when you want to close all connections to a server
|
|
1745
|
+
* and don't want to wait for the grace period to elapse.
|
|
1746
|
+
*/
|
|
1747
|
+
hardDisconnect() {
|
|
1748
|
+
for (const session of this.sessions.values()) {
|
|
1749
|
+
this.deleteSession(session);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1708
1752
|
onBackoffFinished(session) {
|
|
1709
1753
|
const connPromise = tracing_default.startActiveSpan("connect", async (span) => {
|
|
1710
1754
|
try {
|
|
@@ -1712,7 +1756,7 @@ var ClientTransport = class extends Transport {
|
|
|
1712
1756
|
} catch (err) {
|
|
1713
1757
|
const errStr = coerceErrorString(err);
|
|
1714
1758
|
span.recordException(errStr);
|
|
1715
|
-
span.setStatus({ code:
|
|
1759
|
+
span.setStatus({ code: import_api4.SpanStatusCode.ERROR });
|
|
1716
1760
|
throw err;
|
|
1717
1761
|
} finally {
|
|
1718
1762
|
span.end();
|
|
@@ -1794,8 +1838,8 @@ var Connection = class {
|
|
|
1794
1838
|
}
|
|
1795
1839
|
get loggingMetadata() {
|
|
1796
1840
|
const metadata = { connId: this.id };
|
|
1797
|
-
|
|
1798
|
-
|
|
1841
|
+
if (this.telemetry?.span.isRecording()) {
|
|
1842
|
+
const spanContext = this.telemetry.span.spanContext();
|
|
1799
1843
|
metadata.telemetry = {
|
|
1800
1844
|
traceId: spanContext.traceId,
|
|
1801
1845
|
spanId: spanContext.spanId
|