@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,4 +1,4 @@
|
|
|
1
|
-
import { C as Connection, w as CommonSession, d as SessionState, x as CommonSessionProps, T as Transport, y as ServerTransportOptions, r as ServerHandshakeOptions, q as ParsedMetadata, z as ServerSession, c as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './context-
|
|
1
|
+
import { C as Connection, w as CommonSession, d as SessionState, x as CommonSessionProps, T as Transport, y as ServerTransportOptions, r as ServerHandshakeOptions, q as ParsedMetadata, z as ServerSession, c as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './context-d6dd8a1a.js';
|
|
2
2
|
import { P as ProtocolVersion, b as OpaqueTransportMessage, e as Tags, a as TransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId } from './message-3def9ded.js';
|
|
3
3
|
import * as _sinclair_typebox_errors from '@sinclair/typebox/errors';
|
|
4
4
|
import { Static } from '@sinclair/typebox';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TObject, TString, TSchema, TUnion, TLiteral, TNever, Static } from '@sinclair/typebox';
|
|
2
|
-
import { C as Connection, n as ClientHandshakeOptions, t as ProcedureHandlerContext, s as ServiceContext } from './context-
|
|
2
|
+
import { C as Connection, n as ClientHandshakeOptions, t as ProcedureHandlerContext, s as ServiceContext } from './context-d6dd8a1a.js';
|
|
3
3
|
import { c as TransportClientId } from './message-3def9ded.js';
|
|
4
|
-
import { C as ClientTransport } from './client-
|
|
4
|
+
import { C as ClientTransport } from './client-5d2e41a3.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
|
package/dist/testUtil/index.cjs
CHANGED
|
@@ -289,6 +289,14 @@ var StateMachineState = class {
|
|
|
289
289
|
* and we've moved on to another state
|
|
290
290
|
*/
|
|
291
291
|
_isConsumed;
|
|
292
|
+
/**
|
|
293
|
+
* Cleanup this state machine state and mark it as consumed.
|
|
294
|
+
* After calling close, it is an error to access any properties on the state.
|
|
295
|
+
* You should never need to call this as a consumer.
|
|
296
|
+
*
|
|
297
|
+
* If you're looking to close the session from the client,
|
|
298
|
+
* use `.hardDisconnect` on the client transport.
|
|
299
|
+
*/
|
|
292
300
|
close() {
|
|
293
301
|
this._handleClose();
|
|
294
302
|
}
|
|
@@ -343,9 +351,8 @@ var CommonSession = class extends StateMachineState {
|
|
|
343
351
|
parseMsg(msg) {
|
|
344
352
|
const parsedMsg = this.options.codec.fromBuffer(msg);
|
|
345
353
|
if (parsedMsg === null) {
|
|
346
|
-
const decodedBuffer = new TextDecoder().decode(Buffer.from(msg));
|
|
347
354
|
this.log?.error(
|
|
348
|
-
`received malformed msg: ${
|
|
355
|
+
`received malformed msg: ${Buffer.from(msg).toString("base64")}`,
|
|
349
356
|
this.loggingMetadata
|
|
350
357
|
);
|
|
351
358
|
return null;
|
|
@@ -389,13 +396,13 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
389
396
|
this.protocolVersion = protocolVersion;
|
|
390
397
|
}
|
|
391
398
|
get loggingMetadata() {
|
|
392
|
-
const spanContext = this.telemetry.span.spanContext();
|
|
393
399
|
const metadata = {
|
|
394
400
|
clientId: this.from,
|
|
395
401
|
connectedTo: this.to,
|
|
396
402
|
sessionId: this.id
|
|
397
403
|
};
|
|
398
404
|
if (this.telemetry.span.isRecording()) {
|
|
405
|
+
const spanContext = this.telemetry.span.spanContext();
|
|
399
406
|
metadata.telemetry = {
|
|
400
407
|
traceId: spanContext.traceId,
|
|
401
408
|
spanId: spanContext.spanId
|
|
@@ -525,7 +532,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
|
|
|
525
532
|
var import_api = require("@opentelemetry/api");
|
|
526
533
|
|
|
527
534
|
// package.json
|
|
528
|
-
var version = "0.
|
|
535
|
+
var version = "0.203.1";
|
|
529
536
|
|
|
530
537
|
// tracing/index.ts
|
|
531
538
|
function getPropagationContext(ctx) {
|
|
@@ -553,6 +560,21 @@ function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
|
|
|
553
560
|
const ctx = import_api.trace.setSpan(parentCtx, span);
|
|
554
561
|
return { span, ctx };
|
|
555
562
|
}
|
|
563
|
+
function createConnectionTelemetryInfo(connection, info) {
|
|
564
|
+
const span = tracer.startSpan(
|
|
565
|
+
`connection ${connection.id}`,
|
|
566
|
+
{
|
|
567
|
+
attributes: {
|
|
568
|
+
component: "river",
|
|
569
|
+
"river.connection.id": connection.id
|
|
570
|
+
},
|
|
571
|
+
links: [{ context: info.span.spanContext() }]
|
|
572
|
+
},
|
|
573
|
+
info.ctx
|
|
574
|
+
);
|
|
575
|
+
const ctx = import_api.trace.setSpan(info.ctx, span);
|
|
576
|
+
return { span, ctx };
|
|
577
|
+
}
|
|
556
578
|
var tracer = import_api.trace.getTracer("river", version);
|
|
557
579
|
var tracing_default = tracer;
|
|
558
580
|
|
|
@@ -936,6 +958,7 @@ var SessionStateGraph = {
|
|
|
936
958
|
listeners,
|
|
937
959
|
...carriedState
|
|
938
960
|
});
|
|
961
|
+
conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
|
|
939
962
|
session.log?.info(
|
|
940
963
|
`session ${session.id} transition from Connecting to Handshaking`,
|
|
941
964
|
{
|
|
@@ -996,6 +1019,7 @@ var SessionStateGraph = {
|
|
|
996
1019
|
listeners,
|
|
997
1020
|
...carriedState
|
|
998
1021
|
});
|
|
1022
|
+
conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
|
|
999
1023
|
session.log?.info(
|
|
1000
1024
|
`session ${session.id} transition from WaitingForHandshake to Connected`,
|
|
1001
1025
|
{
|
|
@@ -1122,7 +1146,7 @@ var ServerSessionStateGraph = {
|
|
|
1122
1146
|
};
|
|
1123
1147
|
|
|
1124
1148
|
// transport/client.ts
|
|
1125
|
-
var
|
|
1149
|
+
var import_api4 = require("@opentelemetry/api");
|
|
1126
1150
|
|
|
1127
1151
|
// transport/rateLimit.ts
|
|
1128
1152
|
var LeakyBucketRateLimit = class {
|
|
@@ -1192,6 +1216,7 @@ var LeakyBucketRateLimit = class {
|
|
|
1192
1216
|
};
|
|
1193
1217
|
|
|
1194
1218
|
// logging/log.ts
|
|
1219
|
+
var import_api3 = require("@opentelemetry/api");
|
|
1195
1220
|
var LoggingLevels = {
|
|
1196
1221
|
debug: -1,
|
|
1197
1222
|
info: 0,
|
|
@@ -1200,6 +1225,15 @@ var LoggingLevels = {
|
|
|
1200
1225
|
};
|
|
1201
1226
|
var cleanedLogFn = (log) => {
|
|
1202
1227
|
return (msg, metadata) => {
|
|
1228
|
+
if (metadata && !metadata.telemetry) {
|
|
1229
|
+
const span = import_api3.trace.getSpan(import_api3.context.active());
|
|
1230
|
+
if (span) {
|
|
1231
|
+
metadata.telemetry = {
|
|
1232
|
+
traceId: span.spanContext().traceId,
|
|
1233
|
+
spanId: span.spanContext().spanId
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1203
1237
|
if (!metadata?.transportMessage) {
|
|
1204
1238
|
log(msg, metadata);
|
|
1205
1239
|
return;
|
|
@@ -1627,7 +1661,7 @@ var ClientTransport = class extends Transport {
|
|
|
1627
1661
|
}
|
|
1628
1662
|
rejectHandshakeResponse(session, reason, metadata) {
|
|
1629
1663
|
session.conn.telemetry?.span.setStatus({
|
|
1630
|
-
code:
|
|
1664
|
+
code: import_api4.SpanStatusCode.ERROR,
|
|
1631
1665
|
message: reason
|
|
1632
1666
|
});
|
|
1633
1667
|
this.log?.warn(reason, metadata);
|
|
@@ -1757,6 +1791,16 @@ var ClientTransport = class extends Transport {
|
|
|
1757
1791
|
);
|
|
1758
1792
|
this.updateSession(backingOffSession);
|
|
1759
1793
|
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Manually kills all sessions to the server (including all pending state).
|
|
1796
|
+
* This is useful for when you want to close all connections to a server
|
|
1797
|
+
* and don't want to wait for the grace period to elapse.
|
|
1798
|
+
*/
|
|
1799
|
+
hardDisconnect() {
|
|
1800
|
+
for (const session of this.sessions.values()) {
|
|
1801
|
+
this.deleteSession(session);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1760
1804
|
onBackoffFinished(session) {
|
|
1761
1805
|
const connPromise = tracing_default.startActiveSpan("connect", async (span) => {
|
|
1762
1806
|
try {
|
|
@@ -1764,7 +1808,7 @@ var ClientTransport = class extends Transport {
|
|
|
1764
1808
|
} catch (err) {
|
|
1765
1809
|
const errStr = coerceErrorString(err);
|
|
1766
1810
|
span.recordException(errStr);
|
|
1767
|
-
span.setStatus({ code:
|
|
1811
|
+
span.setStatus({ code: import_api4.SpanStatusCode.ERROR });
|
|
1768
1812
|
throw err;
|
|
1769
1813
|
} finally {
|
|
1770
1814
|
span.end();
|
|
@@ -1846,8 +1890,8 @@ var Connection = class {
|
|
|
1846
1890
|
}
|
|
1847
1891
|
get loggingMetadata() {
|
|
1848
1892
|
const metadata = { connId: this.id };
|
|
1849
|
-
|
|
1850
|
-
|
|
1893
|
+
if (this.telemetry?.span.isRecording()) {
|
|
1894
|
+
const spanContext = this.telemetry.span.spanContext();
|
|
1851
1895
|
metadata.telemetry = {
|
|
1852
1896
|
traceId: spanContext.traceId,
|
|
1853
1897
|
spanId: spanContext.spanId
|
|
@@ -1909,7 +1953,7 @@ var Connection = class {
|
|
|
1909
1953
|
};
|
|
1910
1954
|
|
|
1911
1955
|
// transport/server.ts
|
|
1912
|
-
var
|
|
1956
|
+
var import_api5 = require("@opentelemetry/api");
|
|
1913
1957
|
var import_value3 = require("@sinclair/typebox/value");
|
|
1914
1958
|
var ServerTransport = class extends Transport {
|
|
1915
1959
|
/**
|
|
@@ -2019,7 +2063,7 @@ var ServerTransport = class extends Transport {
|
|
|
2019
2063
|
}
|
|
2020
2064
|
rejectHandshakeRequest(session, to, reason, code, metadata) {
|
|
2021
2065
|
session.conn.telemetry?.span.setStatus({
|
|
2022
|
-
code:
|
|
2066
|
+
code: import_api5.SpanStatusCode.ERROR,
|
|
2023
2067
|
message: reason
|
|
2024
2068
|
});
|
|
2025
2069
|
this.log?.warn(reason, metadata);
|