@replit/river 0.203.0 → 0.204.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/dist/{chunk-DGT3MPD4.js → chunk-3V7VMJNA.js} +19 -16
- package/dist/chunk-3V7VMJNA.js.map +1 -0
- package/dist/{chunk-FG22HHCY.js → chunk-6YUDEFCS.js} +47 -10
- package/dist/chunk-6YUDEFCS.js.map +1 -0
- package/dist/chunk-LJCR3ADI.js +1955 -0
- package/dist/chunk-LJCR3ADI.js.map +1 -0
- package/dist/{chunk-XBPEUVWN.js → chunk-QSW7AWEP.js} +5 -11
- package/dist/chunk-QSW7AWEP.js.map +1 -0
- package/dist/{chunk-LHH5LQ7C.js → chunk-WBGKPIFS.js} +11 -1
- package/dist/chunk-WBGKPIFS.js.map +1 -0
- package/dist/{chunk-D5EIDBUT.js → chunk-YODW2ZMU.js} +4 -3
- package/dist/chunk-YODW2ZMU.js.map +1 -0
- package/dist/{client-5d2e41a3.d.ts → client-0c0a4a5e.d.ts} +1 -1
- package/dist/{connection-11a4af0f.d.ts → connection-7b62dfec.d.ts} +1 -1
- package/dist/{context-d6dd8a1a.d.ts → context-3cf1ed4e.d.ts} +8 -2
- 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 +109 -111
- 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 +18 -1629
- package/dist/router/index.js.map +1 -1
- package/dist/{server-e46399f9.d.ts → server-a287de55.d.ts} +1 -1
- package/dist/{services-56cbea0d.d.ts → services-51980ecd.d.ts} +2 -2
- package/dist/testUtil/index.cjs +103 -36
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +4 -4
- package/dist/testUtil/index.d.ts +4 -4
- package/dist/testUtil/index.js +9 -7
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.cjs +107 -48
- 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 +92 -35
- 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 +107 -41
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +3 -3
- package/dist/transport/index.d.ts +3 -3
- package/dist/transport/index.js +5 -5
- package/package.json +3 -3
- package/dist/chunk-D5EIDBUT.js.map +0 -1
- package/dist/chunk-DGT3MPD4.js.map +0 -1
- package/dist/chunk-FG22HHCY.js.map +0 -1
- package/dist/chunk-LHH5LQ7C.js.map +0 -1
- package/dist/chunk-SZHNMLKC.js +0 -310
- package/dist/chunk-SZHNMLKC.js.map +0 -1
- package/dist/chunk-XBPEUVWN.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as TelemetryInfo, M as MessageMetadata, c as TransportClientId, L as Logger, b as OpaqueTransportMessage, P as ProtocolVersion, f as PartialTransportMessage, a as TransportMessage, e as Tags, H as HandshakeErrorResponseCodes, h as LogFn, j as LoggingLevel, k as HandshakeErrorCustomHandlerFatalResponseCodes } from './message-3def9ded.js';
|
|
2
2
|
import { Static, TSchema } from '@sinclair/typebox';
|
|
3
3
|
import * as _sinclair_typebox_errors from '@sinclair/typebox/errors';
|
|
4
|
-
import { Span } from '@opentelemetry/api';
|
|
4
|
+
import { Tracer, Span } from '@opentelemetry/api';
|
|
5
5
|
import { C as Codec } from './types-3e5768ec.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -21,6 +21,9 @@ declare abstract class Connection {
|
|
|
21
21
|
get dataListeners(): ((msg: Uint8Array) => void)[];
|
|
22
22
|
get closeListeners(): (() => void)[];
|
|
23
23
|
get errorListeners(): ((err: Error) => void)[];
|
|
24
|
+
onData(msg: Uint8Array): void;
|
|
25
|
+
onError(err: Error): void;
|
|
26
|
+
onClose(): void;
|
|
24
27
|
/**
|
|
25
28
|
* Handle adding a callback for when a message is received.
|
|
26
29
|
* @param msg The message that was received.
|
|
@@ -121,14 +124,16 @@ interface SessionOptions {
|
|
|
121
124
|
interface CommonSessionProps {
|
|
122
125
|
from: TransportClientId;
|
|
123
126
|
options: SessionOptions;
|
|
127
|
+
tracer: Tracer;
|
|
124
128
|
log: Logger | undefined;
|
|
125
129
|
}
|
|
126
130
|
declare abstract class CommonSession extends StateMachineState {
|
|
127
131
|
readonly from: TransportClientId;
|
|
128
132
|
readonly options: SessionOptions;
|
|
133
|
+
tracer: Tracer;
|
|
129
134
|
log?: Logger;
|
|
130
135
|
abstract get loggingMetadata(): MessageMetadata;
|
|
131
|
-
constructor({ from, options, log }: CommonSessionProps);
|
|
136
|
+
constructor({ from, options, log, tracer }: CommonSessionProps);
|
|
132
137
|
parseMsg(msg: Uint8Array): OpaqueTransportMessage | null;
|
|
133
138
|
}
|
|
134
139
|
type SessionId = string;
|
|
@@ -461,6 +466,7 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
461
466
|
*/
|
|
462
467
|
protected options: TransportOptions;
|
|
463
468
|
log?: Logger;
|
|
469
|
+
tracer: Tracer;
|
|
464
470
|
sessions: Map<TransportClientId, Session<ConnType>>;
|
|
465
471
|
/**
|
|
466
472
|
* Creates a new Transport instance.
|
package/dist/logging/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(logging_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(logging_exports);
|
|
28
28
|
|
|
29
29
|
// logging/log.ts
|
|
30
|
+
var import_api = require("@opentelemetry/api");
|
|
30
31
|
var stringLogger = (msg, ctx, level = "info") => {
|
|
31
32
|
const from = ctx?.clientId ? `${ctx.clientId} -- ` : "";
|
|
32
33
|
console.log(`[river:${level}] ${from}${msg}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../logging/index.ts","../../logging/log.ts"],"sourcesContent":["export { stringLogger, coloredStringLogger, jsonLogger } from './log';\nexport type { Logger, LogFn, MessageMetadata } from './log';\n","import { ValueError } from '@sinclair/typebox/value';\nimport { OpaqueTransportMessage, ProtocolVersion } from '../transport/message';\n\nconst LoggingLevels = {\n debug: -1,\n info: 0,\n warn: 1,\n error: 2,\n} as const;\nexport type LoggingLevel = keyof typeof LoggingLevels;\n\nexport type LogFn = (\n msg: string,\n ctx?: MessageMetadata,\n level?: LoggingLevel,\n) => void;\nexport type Logger = {\n [key in LoggingLevel]: (msg: string, metadata?: MessageMetadata) => void;\n};\n\nexport type Tags =\n | 'invariant-violation'\n | 'state-transition'\n | 'invalid-request'\n | 'unhealthy-session'\n | 'uncaught-handler-error';\n\nconst cleanedLogFn = (log: LogFn) => {\n return (msg: string, metadata?: MessageMetadata) => {\n // skip cloning object if metadata has no transportMessage\n if (!metadata?.transportMessage) {\n log(msg, metadata);\n\n return;\n }\n\n // clone metadata and clean transportMessage\n const { payload, ...rest } = metadata.transportMessage;\n metadata.transportMessage = rest;\n log(msg, metadata);\n };\n};\n\nexport type MessageMetadata = Partial<{\n protocolVersion: ProtocolVersion;\n clientId: string;\n connectedTo: string;\n sessionId: string;\n connId: string;\n transportMessage: Partial<OpaqueTransportMessage>;\n validationErrors: Array<ValueError>;\n tags: Array<Tags>;\n telemetry: {\n traceId: string;\n spanId: string;\n };\n extras?: Record<string, unknown>;\n}>;\n\nexport class BaseLogger implements Logger {\n minLevel: LoggingLevel;\n private output: LogFn;\n\n constructor(output: LogFn, minLevel: LoggingLevel = 'info') {\n this.minLevel = minLevel;\n this.output = output;\n }\n\n debug(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.debug) {\n this.output(msg, metadata ?? {}, 'debug');\n }\n }\n\n info(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.info) {\n this.output(msg, metadata ?? {}, 'info');\n }\n }\n\n warn(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.warn) {\n this.output(msg, metadata ?? {}, 'warn');\n }\n }\n\n error(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.error) {\n this.output(msg, metadata ?? {}, 'error');\n }\n }\n}\n\nexport const stringLogger: LogFn = (msg, ctx, level = 'info') => {\n const from = ctx?.clientId ? `${ctx.clientId} -- ` : '';\n console.log(`[river:${level}] ${from}${msg}`);\n};\n\nconst colorMap = {\n debug: '\\u001b[34m',\n info: '\\u001b[32m',\n warn: '\\u001b[33m',\n error: '\\u001b[31m',\n};\n\nexport const coloredStringLogger: LogFn = (msg, ctx, level = 'info') => {\n const color = colorMap[level];\n const from = ctx?.clientId ? `${ctx.clientId} -- ` : '';\n console.log(`[river:${color}${level}\\u001b[0m] ${from}${msg}`);\n};\n\nexport const jsonLogger: LogFn = (msg, ctx, level) => {\n console.log(JSON.stringify({ msg, ctx, level }));\n};\n\nexport const createLogProxy = (log: Logger) => ({\n debug: cleanedLogFn(log.debug.bind(log)),\n info: cleanedLogFn(log.info.bind(log)),\n warn: cleanedLogFn(log.warn.bind(log)),\n error: cleanedLogFn(log.error.bind(log)),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../logging/index.ts","../../logging/log.ts"],"sourcesContent":["export { stringLogger, coloredStringLogger, jsonLogger } from './log';\nexport type { Logger, LogFn, MessageMetadata } from './log';\n","import { ValueError } from '@sinclair/typebox/value';\nimport { OpaqueTransportMessage, ProtocolVersion } from '../transport/message';\nimport { context, trace } from '@opentelemetry/api';\n\nconst LoggingLevels = {\n debug: -1,\n info: 0,\n warn: 1,\n error: 2,\n} as const;\nexport type LoggingLevel = keyof typeof LoggingLevels;\n\nexport type LogFn = (\n msg: string,\n ctx?: MessageMetadata,\n level?: LoggingLevel,\n) => void;\nexport type Logger = {\n [key in LoggingLevel]: (msg: string, metadata?: MessageMetadata) => void;\n};\n\nexport type Tags =\n | 'invariant-violation'\n | 'state-transition'\n | 'invalid-request'\n | 'unhealthy-session'\n | 'uncaught-handler-error';\n\nconst cleanedLogFn = (log: LogFn) => {\n return (msg: string, metadata?: MessageMetadata) => {\n // try to infer telemetry\n if (metadata && !metadata.telemetry) {\n const span = trace.getSpan(context.active());\n if (span) {\n metadata.telemetry = {\n traceId: span.spanContext().traceId,\n spanId: span.spanContext().spanId,\n };\n }\n }\n\n // skip cloning object if metadata has no transportMessage\n if (!metadata?.transportMessage) {\n log(msg, metadata);\n\n return;\n }\n\n // clone metadata and clean transportMessage\n const { payload, ...rest } = metadata.transportMessage;\n metadata.transportMessage = rest;\n\n log(msg, metadata);\n };\n};\n\nexport type MessageMetadata = Partial<{\n protocolVersion: ProtocolVersion;\n clientId: string;\n connectedTo: string;\n sessionId: string;\n connId: string;\n transportMessage: Partial<OpaqueTransportMessage>;\n validationErrors: Array<ValueError>;\n tags: Array<Tags>;\n telemetry: {\n traceId: string;\n spanId: string;\n };\n extras?: Record<string, unknown>;\n}>;\n\nexport class BaseLogger implements Logger {\n minLevel: LoggingLevel;\n private output: LogFn;\n\n constructor(output: LogFn, minLevel: LoggingLevel = 'info') {\n this.minLevel = minLevel;\n this.output = output;\n }\n\n debug(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.debug) {\n this.output(msg, metadata ?? {}, 'debug');\n }\n }\n\n info(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.info) {\n this.output(msg, metadata ?? {}, 'info');\n }\n }\n\n warn(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.warn) {\n this.output(msg, metadata ?? {}, 'warn');\n }\n }\n\n error(msg: string, metadata?: MessageMetadata) {\n if (LoggingLevels[this.minLevel] <= LoggingLevels.error) {\n this.output(msg, metadata ?? {}, 'error');\n }\n }\n}\n\nexport const stringLogger: LogFn = (msg, ctx, level = 'info') => {\n const from = ctx?.clientId ? `${ctx.clientId} -- ` : '';\n console.log(`[river:${level}] ${from}${msg}`);\n};\n\nconst colorMap = {\n debug: '\\u001b[34m',\n info: '\\u001b[32m',\n warn: '\\u001b[33m',\n error: '\\u001b[31m',\n};\n\nexport const coloredStringLogger: LogFn = (msg, ctx, level = 'info') => {\n const color = colorMap[level];\n const from = ctx?.clientId ? `${ctx.clientId} -- ` : '';\n console.log(`[river:${color}${level}\\u001b[0m] ${from}${msg}`);\n};\n\nexport const jsonLogger: LogFn = (msg, ctx, level) => {\n console.log(JSON.stringify({ msg, ctx, level }));\n};\n\nexport const createLogProxy = (log: Logger) => ({\n debug: cleanedLogFn(log.debug.bind(log)),\n info: cleanedLogFn(log.info.bind(log)),\n warn: cleanedLogFn(log.warn.bind(log)),\n error: cleanedLogFn(log.error.bind(log)),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,iBAA+B;AAwGxB,IAAM,eAAsB,CAAC,KAAK,KAAK,QAAQ,WAAW;AAC/D,QAAM,OAAO,KAAK,WAAW,GAAG,IAAI,QAAQ,SAAS;AACrD,UAAQ,IAAI,UAAU,KAAK,KAAK,IAAI,GAAG,GAAG,EAAE;AAC9C;AAEA,IAAM,WAAW;AAAA,EACf,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAEO,IAAM,sBAA6B,CAAC,KAAK,KAAK,QAAQ,WAAW;AACtE,QAAM,QAAQ,SAAS,KAAK;AAC5B,QAAM,OAAO,KAAK,WAAW,GAAG,IAAI,QAAQ,SAAS;AACrD,UAAQ,IAAI,UAAU,KAAK,GAAG,KAAK,YAAc,IAAI,GAAG,GAAG,EAAE;AAC/D;AAEO,IAAM,aAAoB,CAAC,KAAK,KAAK,UAAU;AACpD,UAAQ,IAAI,KAAK,UAAU,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC;AACjD;","names":[]}
|
package/dist/logging/index.js
CHANGED
package/dist/router/index.cjs
CHANGED
|
@@ -609,11 +609,6 @@ function unwrapOrThrow(result) {
|
|
|
609
609
|
|
|
610
610
|
// tracing/index.ts
|
|
611
611
|
var import_api = require("@opentelemetry/api");
|
|
612
|
-
|
|
613
|
-
// package.json
|
|
614
|
-
var version = "0.203.0";
|
|
615
|
-
|
|
616
|
-
// tracing/index.ts
|
|
617
612
|
function getPropagationContext(ctx) {
|
|
618
613
|
const tracing = {
|
|
619
614
|
traceparent: "",
|
|
@@ -622,10 +617,10 @@ function getPropagationContext(ctx) {
|
|
|
622
617
|
import_api.propagation.inject(ctx, tracing);
|
|
623
618
|
return tracing;
|
|
624
619
|
}
|
|
625
|
-
function createProcTelemetryInfo(
|
|
620
|
+
function createProcTelemetryInfo(tracer, session, kind, serviceName, procedureName, streamId) {
|
|
626
621
|
const baseCtx = import_api.context.active();
|
|
627
622
|
const span = tracer.startSpan(
|
|
628
|
-
`
|
|
623
|
+
`river.client.${serviceName}.${procedureName}`,
|
|
629
624
|
{
|
|
630
625
|
attributes: {
|
|
631
626
|
component: "river",
|
|
@@ -635,28 +630,32 @@ function createProcTelemetryInfo(transport, kind, serviceName, procedureName, st
|
|
|
635
630
|
"river.streamId": streamId,
|
|
636
631
|
"span.kind": "client"
|
|
637
632
|
},
|
|
633
|
+
links: [{ context: session.telemetry.span.spanContext() }],
|
|
638
634
|
kind: import_api.SpanKind.CLIENT
|
|
639
635
|
},
|
|
640
636
|
baseCtx
|
|
641
637
|
);
|
|
642
638
|
const ctx = import_api.trace.setSpan(baseCtx, span);
|
|
643
|
-
|
|
644
|
-
|
|
639
|
+
const metadata = {
|
|
640
|
+
...session.loggingMetadata,
|
|
645
641
|
transportMessage: {
|
|
646
642
|
procedureName,
|
|
647
643
|
serviceName
|
|
648
|
-
}
|
|
649
|
-
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
if (span.isRecording()) {
|
|
647
|
+
metadata.telemetry = {
|
|
650
648
|
traceId: span.spanContext().traceId,
|
|
651
649
|
spanId: span.spanContext().spanId
|
|
652
|
-
}
|
|
653
|
-
}
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
session.log?.info(`invoked ${serviceName}.${procedureName}`, metadata);
|
|
654
653
|
return { span, ctx };
|
|
655
654
|
}
|
|
656
|
-
function createHandlerSpan(kind, serviceName, procedureName, streamId, tracing, fn) {
|
|
655
|
+
function createHandlerSpan(tracer, session, kind, serviceName, procedureName, streamId, tracing, fn) {
|
|
657
656
|
const ctx = tracing ? import_api.propagation.extract(import_api.context.active(), tracing) : import_api.context.active();
|
|
658
657
|
return tracer.startActiveSpan(
|
|
659
|
-
`
|
|
658
|
+
`river.server.${serviceName}.${procedureName}`,
|
|
660
659
|
{
|
|
661
660
|
attributes: {
|
|
662
661
|
component: "river",
|
|
@@ -666,13 +665,23 @@ function createHandlerSpan(kind, serviceName, procedureName, streamId, tracing,
|
|
|
666
665
|
"river.streamId": streamId,
|
|
667
666
|
"span.kind": "server"
|
|
668
667
|
},
|
|
668
|
+
links: [{ context: session.telemetry.span.spanContext() }],
|
|
669
669
|
kind: import_api.SpanKind.SERVER
|
|
670
670
|
},
|
|
671
671
|
ctx,
|
|
672
672
|
fn
|
|
673
673
|
);
|
|
674
674
|
}
|
|
675
|
-
|
|
675
|
+
function recordRiverError(span, error) {
|
|
676
|
+
span.setStatus({
|
|
677
|
+
code: import_api.SpanStatusCode.ERROR,
|
|
678
|
+
message: error.message
|
|
679
|
+
});
|
|
680
|
+
span.setAttributes({
|
|
681
|
+
"river.error_code": error.code,
|
|
682
|
+
"river.error_message": error.message
|
|
683
|
+
});
|
|
684
|
+
}
|
|
676
685
|
|
|
677
686
|
// router/streams.ts
|
|
678
687
|
var ReadableBrokenError = {
|
|
@@ -947,7 +956,8 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
947
956
|
const procClosesWithInit = procType === "rpc" || procType === "subscription";
|
|
948
957
|
const streamId = generateId();
|
|
949
958
|
const { span, ctx } = createProcTelemetryInfo(
|
|
950
|
-
transport,
|
|
959
|
+
transport.tracer,
|
|
960
|
+
session,
|
|
951
961
|
procType,
|
|
952
962
|
serviceName,
|
|
953
963
|
procedureName,
|
|
@@ -1165,7 +1175,6 @@ function coerceErrorString(err) {
|
|
|
1165
1175
|
}
|
|
1166
1176
|
|
|
1167
1177
|
// router/server.ts
|
|
1168
|
-
var import_api2 = require("@opentelemetry/api");
|
|
1169
1178
|
var CancelResultSchema = ErrResultSchema(
|
|
1170
1179
|
import_typebox6.Type.Object({
|
|
1171
1180
|
code: import_typebox6.Type.Literal(CANCEL_CODE),
|
|
@@ -1232,10 +1241,18 @@ var RiverServer = class {
|
|
|
1232
1241
|
if (!newStreamProps) {
|
|
1233
1242
|
return;
|
|
1234
1243
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1244
|
+
createHandlerSpan(
|
|
1245
|
+
transport.tracer,
|
|
1246
|
+
newStreamProps.initialSession,
|
|
1247
|
+
newStreamProps.procedure.type,
|
|
1248
|
+
newStreamProps.serviceName,
|
|
1249
|
+
newStreamProps.procedureName,
|
|
1250
|
+
newStreamProps.streamId,
|
|
1251
|
+
newStreamProps.tracingCtx,
|
|
1252
|
+
(span) => {
|
|
1253
|
+
this.createNewProcStream(span, newStreamProps);
|
|
1254
|
+
}
|
|
1255
|
+
);
|
|
1239
1256
|
};
|
|
1240
1257
|
const handleSessionStatus = (evt) => {
|
|
1241
1258
|
if (evt.status !== "disconnect")
|
|
@@ -1269,7 +1286,7 @@ var RiverServer = class {
|
|
|
1269
1286
|
this.transport.addEventListener("sessionStatus", handleSessionStatus);
|
|
1270
1287
|
this.transport.addEventListener("transportStatus", handleTransportStatus);
|
|
1271
1288
|
}
|
|
1272
|
-
createNewProcStream(props) {
|
|
1289
|
+
createNewProcStream(span, props) {
|
|
1273
1290
|
const {
|
|
1274
1291
|
streamId,
|
|
1275
1292
|
initialSession,
|
|
@@ -1279,7 +1296,6 @@ var RiverServer = class {
|
|
|
1279
1296
|
sessionMetadata,
|
|
1280
1297
|
serviceContext,
|
|
1281
1298
|
initPayload,
|
|
1282
|
-
tracingCtx,
|
|
1283
1299
|
procClosesWithInit,
|
|
1284
1300
|
passInitAsDataForBackwardsCompat
|
|
1285
1301
|
} = props;
|
|
@@ -1289,6 +1305,10 @@ var RiverServer = class {
|
|
|
1289
1305
|
protocolVersion,
|
|
1290
1306
|
id: sessionId
|
|
1291
1307
|
} = initialSession;
|
|
1308
|
+
loggingMetadata.telemetry = {
|
|
1309
|
+
traceId: span.spanContext().traceId,
|
|
1310
|
+
spanId: span.spanContext().spanId
|
|
1311
|
+
};
|
|
1292
1312
|
let cleanClose = true;
|
|
1293
1313
|
const onMessage = (msg) => {
|
|
1294
1314
|
if (msg.from !== from) {
|
|
@@ -1401,6 +1421,7 @@ var RiverServer = class {
|
|
|
1401
1421
|
this.cancelStream(from, sessionScopedSend, streamId2, payload);
|
|
1402
1422
|
};
|
|
1403
1423
|
const onServerCancel = (e) => {
|
|
1424
|
+
recordRiverError(span, e);
|
|
1404
1425
|
if (reqReadable.isClosed() && resWritable.isClosed()) {
|
|
1405
1426
|
return;
|
|
1406
1427
|
}
|
|
@@ -1435,6 +1456,9 @@ var RiverServer = class {
|
|
|
1435
1456
|
}
|
|
1436
1457
|
const resWritable = new WritableImpl({
|
|
1437
1458
|
writeCb: (response) => {
|
|
1459
|
+
if (!response.ok) {
|
|
1460
|
+
recordRiverError(span, response.payload);
|
|
1461
|
+
}
|
|
1438
1462
|
sessionScopedSend({
|
|
1439
1463
|
streamId,
|
|
1440
1464
|
controlFlags: procClosesWithResponse ? getStreamCloseBackwardsCompat(protocolVersion) : 0,
|
|
@@ -1461,10 +1485,9 @@ var RiverServer = class {
|
|
|
1461
1485
|
}
|
|
1462
1486
|
}
|
|
1463
1487
|
});
|
|
1464
|
-
const onHandlerError = (err,
|
|
1488
|
+
const onHandlerError = (err, span2) => {
|
|
1465
1489
|
const errorMsg = coerceErrorString(err);
|
|
1466
|
-
|
|
1467
|
-
span.setStatus({ code: import_api2.SpanStatusCode.ERROR });
|
|
1490
|
+
span2.recordException(err instanceof Error ? err : new Error(errorMsg));
|
|
1468
1491
|
this.log?.error(
|
|
1469
1492
|
`${serviceName}.${procedureName} handler threw an uncaught error`,
|
|
1470
1493
|
{
|
|
@@ -1488,12 +1511,12 @@ var RiverServer = class {
|
|
|
1488
1511
|
if (procClosesWithInit) {
|
|
1489
1512
|
closeReadable();
|
|
1490
1513
|
}
|
|
1491
|
-
const handlerContextWithSpan = (
|
|
1514
|
+
const handlerContextWithSpan = (span2) => ({
|
|
1492
1515
|
...serviceContext,
|
|
1493
1516
|
from,
|
|
1494
1517
|
sessionId,
|
|
1495
1518
|
metadata: sessionMetadata,
|
|
1496
|
-
span,
|
|
1519
|
+
span: span2,
|
|
1497
1520
|
cancel: () => {
|
|
1498
1521
|
onServerCancel({
|
|
1499
1522
|
code: CANCEL_CODE,
|
|
@@ -1504,100 +1527,72 @@ var RiverServer = class {
|
|
|
1504
1527
|
});
|
|
1505
1528
|
switch (procedure.type) {
|
|
1506
1529
|
case "rpc":
|
|
1507
|
-
void
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
const responsePayload = await procedure.handler({
|
|
1516
|
-
ctx: handlerContextWithSpan(span),
|
|
1517
|
-
reqInit: initPayload
|
|
1518
|
-
});
|
|
1519
|
-
if (resWritable.isClosed()) {
|
|
1520
|
-
return;
|
|
1521
|
-
}
|
|
1522
|
-
resWritable.write(responsePayload);
|
|
1523
|
-
} catch (err) {
|
|
1524
|
-
onHandlerError(err, span);
|
|
1525
|
-
} finally {
|
|
1526
|
-
span.end();
|
|
1530
|
+
void (async () => {
|
|
1531
|
+
try {
|
|
1532
|
+
const responsePayload = await procedure.handler({
|
|
1533
|
+
ctx: handlerContextWithSpan(span),
|
|
1534
|
+
reqInit: initPayload
|
|
1535
|
+
});
|
|
1536
|
+
if (resWritable.isClosed()) {
|
|
1537
|
+
return;
|
|
1527
1538
|
}
|
|
1539
|
+
resWritable.write(responsePayload);
|
|
1540
|
+
} catch (err) {
|
|
1541
|
+
onHandlerError(err, span);
|
|
1542
|
+
} finally {
|
|
1543
|
+
span.end();
|
|
1528
1544
|
}
|
|
1529
|
-
);
|
|
1545
|
+
})();
|
|
1530
1546
|
break;
|
|
1531
1547
|
case "stream":
|
|
1532
|
-
void
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
resWritable
|
|
1545
|
-
});
|
|
1546
|
-
} catch (err) {
|
|
1547
|
-
onHandlerError(err, span);
|
|
1548
|
-
} finally {
|
|
1549
|
-
span.end();
|
|
1550
|
-
}
|
|
1548
|
+
void (async () => {
|
|
1549
|
+
try {
|
|
1550
|
+
await procedure.handler({
|
|
1551
|
+
ctx: handlerContextWithSpan(span),
|
|
1552
|
+
reqInit: initPayload,
|
|
1553
|
+
reqReadable,
|
|
1554
|
+
resWritable
|
|
1555
|
+
});
|
|
1556
|
+
} catch (err) {
|
|
1557
|
+
onHandlerError(err, span);
|
|
1558
|
+
} finally {
|
|
1559
|
+
span.end();
|
|
1551
1560
|
}
|
|
1552
|
-
);
|
|
1561
|
+
})();
|
|
1553
1562
|
break;
|
|
1554
1563
|
case "subscription":
|
|
1555
|
-
void
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
resWritable
|
|
1567
|
-
});
|
|
1568
|
-
} catch (err) {
|
|
1569
|
-
onHandlerError(err, span);
|
|
1570
|
-
} finally {
|
|
1571
|
-
span.end();
|
|
1572
|
-
}
|
|
1564
|
+
void (async () => {
|
|
1565
|
+
try {
|
|
1566
|
+
await procedure.handler({
|
|
1567
|
+
ctx: handlerContextWithSpan(span),
|
|
1568
|
+
reqInit: initPayload,
|
|
1569
|
+
resWritable
|
|
1570
|
+
});
|
|
1571
|
+
} catch (err) {
|
|
1572
|
+
onHandlerError(err, span);
|
|
1573
|
+
} finally {
|
|
1574
|
+
span.end();
|
|
1573
1575
|
}
|
|
1574
|
-
);
|
|
1576
|
+
})();
|
|
1575
1577
|
break;
|
|
1576
1578
|
case "upload":
|
|
1577
|
-
void
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
ctx: handlerContextWithSpan(span),
|
|
1587
|
-
reqInit: initPayload,
|
|
1588
|
-
reqReadable
|
|
1589
|
-
});
|
|
1590
|
-
if (resWritable.isClosed()) {
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
resWritable.write(responsePayload);
|
|
1594
|
-
} catch (err) {
|
|
1595
|
-
onHandlerError(err, span);
|
|
1596
|
-
} finally {
|
|
1597
|
-
span.end();
|
|
1579
|
+
void (async () => {
|
|
1580
|
+
try {
|
|
1581
|
+
const responsePayload = await procedure.handler({
|
|
1582
|
+
ctx: handlerContextWithSpan(span),
|
|
1583
|
+
reqInit: initPayload,
|
|
1584
|
+
reqReadable
|
|
1585
|
+
});
|
|
1586
|
+
if (resWritable.isClosed()) {
|
|
1587
|
+
return;
|
|
1598
1588
|
}
|
|
1589
|
+
resWritable.write(responsePayload);
|
|
1590
|
+
} catch (err) {
|
|
1591
|
+
onHandlerError(err, span);
|
|
1592
|
+
} finally {
|
|
1593
|
+
span.end();
|
|
1599
1594
|
}
|
|
1600
|
-
);
|
|
1595
|
+
})();
|
|
1601
1596
|
break;
|
|
1602
1597
|
}
|
|
1603
1598
|
if (!finishedController.signal.aborted) {
|
|
@@ -1861,6 +1856,9 @@ function createClientHandshakeOptions(schema, construct) {
|
|
|
1861
1856
|
function createServerHandshakeOptions(schema, validate) {
|
|
1862
1857
|
return { schema, validate };
|
|
1863
1858
|
}
|
|
1859
|
+
|
|
1860
|
+
// package.json
|
|
1861
|
+
var version = "0.204.0";
|
|
1864
1862
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1865
1863
|
0 && (module.exports = {
|
|
1866
1864
|
CANCEL_CODE,
|