@replit/river 0.26.2 → 0.26.3

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.
Files changed (52) hide show
  1. package/dist/{chunk-MREEJE3X.js → chunk-3JCZNGF7.js} +2 -2
  2. package/dist/{chunk-IV27BICV.js → chunk-BB2E5L4U.js} +12 -13
  3. package/dist/chunk-BB2E5L4U.js.map +1 -0
  4. package/dist/{chunk-M5X4JTU3.js → chunk-JI6FFDY5.js} +5 -4
  5. package/dist/{chunk-M5X4JTU3.js.map → chunk-JI6FFDY5.js.map} +1 -1
  6. package/dist/{chunk-M75K5TJS.js → chunk-MZELCWJK.js} +2 -2
  7. package/dist/{chunk-M75K5TJS.js.map → chunk-MZELCWJK.js.map} +1 -1
  8. package/dist/{chunk-NC54BC47.js → chunk-OCL2FUTQ.js} +40 -14
  9. package/dist/chunk-OCL2FUTQ.js.map +1 -0
  10. package/dist/{chunk-YQABPD3C.js → chunk-X35QRIA5.js} +51 -56
  11. package/dist/chunk-X35QRIA5.js.map +1 -0
  12. package/dist/{chunk-AWCUCZY4.js → chunk-ZY2HYJ5Y.js} +2 -2
  13. package/dist/{client-654098be.d.ts → client-1894a9c9.d.ts} +2 -2
  14. package/dist/{connection-bc2454dc.d.ts → connection-03ffb583.d.ts} +1 -1
  15. package/dist/{handshake-1a86f06d.d.ts → handshake-154a0bb2.d.ts} +30 -1
  16. package/dist/logging/index.d.cts +1 -1
  17. package/dist/logging/index.d.ts +1 -1
  18. package/dist/{message-57296605.d.ts → message-ff78a233.d.ts} +1 -1
  19. package/dist/router/index.cjs +1 -1
  20. package/dist/router/index.cjs.map +1 -1
  21. package/dist/router/index.d.cts +9 -8
  22. package/dist/router/index.d.ts +9 -8
  23. package/dist/router/index.js +2 -2
  24. package/dist/{server-9a6b5a8e.d.ts → server-1f5eb427.d.ts} +17 -4
  25. package/dist/{services-7daa60a0.d.ts → services-491d8c32.d.ts} +3 -3
  26. package/dist/transport/impls/ws/client.cjs +52 -25
  27. package/dist/transport/impls/ws/client.cjs.map +1 -1
  28. package/dist/transport/impls/ws/client.d.cts +5 -4
  29. package/dist/transport/impls/ws/client.d.ts +5 -4
  30. package/dist/transport/impls/ws/client.js +8 -7
  31. package/dist/transport/impls/ws/client.js.map +1 -1
  32. package/dist/transport/impls/ws/server.cjs +88 -66
  33. package/dist/transport/impls/ws/server.cjs.map +1 -1
  34. package/dist/transport/impls/ws/server.d.cts +5 -4
  35. package/dist/transport/impls/ws/server.d.ts +5 -4
  36. package/dist/transport/impls/ws/server.js +5 -5
  37. package/dist/transport/index.cjs +96 -75
  38. package/dist/transport/index.cjs.map +1 -1
  39. package/dist/transport/index.d.cts +5 -4
  40. package/dist/transport/index.d.ts +5 -4
  41. package/dist/transport/index.js +5 -5
  42. package/dist/util/testHelpers.cjs +39 -13
  43. package/dist/util/testHelpers.cjs.map +1 -1
  44. package/dist/util/testHelpers.d.cts +5 -4
  45. package/dist/util/testHelpers.d.ts +5 -4
  46. package/dist/util/testHelpers.js +3 -3
  47. package/package.json +1 -1
  48. package/dist/chunk-IV27BICV.js.map +0 -1
  49. package/dist/chunk-NC54BC47.js.map +0 -1
  50. package/dist/chunk-YQABPD3C.js.map +0 -1
  51. /package/dist/{chunk-MREEJE3X.js.map → chunk-3JCZNGF7.js.map} +0 -0
  52. /package/dist/{chunk-AWCUCZY4.js.map → chunk-ZY2HYJ5Y.js.map} +0 -0
@@ -1,14 +1,15 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-7daa60a0.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-7daa60a0.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-491d8c32.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-491d8c32.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
- import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-1a86f06d.js';
6
- export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-1a86f06d.js';
7
- import { S as ServerTransport } from '../server-9a6b5a8e.js';
8
- import '../message-57296605.js';
5
+ import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
6
+ export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-154a0bb2.js';
7
+ import { S as ServerTransport } from '../server-1f5eb427.js';
8
+ import '../message-ff78a233.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-654098be.js';
11
+ import '../client-1894a9c9.js';
12
+ import '@sinclair/typebox/errors';
12
13
  import '../types-3e5768ec.js';
13
14
 
14
15
  /**
@@ -45,6 +46,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
45
46
  extendedContext?: Omit<ServiceContext, 'state'>;
46
47
  }>): Server<Services>;
47
48
 
48
- var version = "0.26.2";
49
+ var version = "0.26.3";
49
50
 
50
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -1,14 +1,15 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-7daa60a0.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-7daa60a0.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-491d8c32.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-491d8c32.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
- import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-1a86f06d.js';
6
- export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-1a86f06d.js';
7
- import { S as ServerTransport } from '../server-9a6b5a8e.js';
8
- import '../message-57296605.js';
5
+ import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
6
+ export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-154a0bb2.js';
7
+ import { S as ServerTransport } from '../server-1f5eb427.js';
8
+ import '../message-ff78a233.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-654098be.js';
11
+ import '../client-1894a9c9.js';
12
+ import '@sinclair/typebox/errors';
12
13
  import '../types-3e5768ec.js';
13
14
 
14
15
  /**
@@ -45,6 +46,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
45
46
  extendedContext?: Omit<ServiceContext, 'state'>;
46
47
  }>): Server<Services>;
47
48
 
48
- var version = "0.26.2";
49
+ var version = "0.26.3";
49
50
 
50
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -10,10 +10,10 @@ import {
10
10
  createServer,
11
11
  createServerHandshakeOptions,
12
12
  serializeSchema
13
- } from "../chunk-MREEJE3X.js";
13
+ } from "../chunk-3JCZNGF7.js";
14
14
  import {
15
15
  version
16
- } from "../chunk-M75K5TJS.js";
16
+ } from "../chunk-MZELCWJK.js";
17
17
  export {
18
18
  Err,
19
19
  Ok,
@@ -1,5 +1,6 @@
1
- import { C as Connection, y as CommonSession, d as SessionState, z as CommonSessionProps, T as Transport, A as ServerTransportOptions, s as ServerHandshakeOptions, t as ParsedMetadata, B as ServerSession, c as ProvidedServerTransportOptions } from './handshake-1a86f06d.js';
2
- import { M as MessageMetadata, a as TransportMessage, b as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId, P as PartialTransportMessage } from './message-57296605.js';
1
+ import { C as Connection, y as CommonSession, d as SessionState, z as CommonSessionProps, T as Transport, A as ServerTransportOptions, s as ServerHandshakeOptions, t as ParsedMetadata, B as ServerSession, c as ProvidedServerTransportOptions } from './handshake-154a0bb2.js';
2
+ import { b as OpaqueTransportMessage, e as Tags, a as TransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId, P as PartialTransportMessage } from './message-ff78a233.js';
3
+ import * as _sinclair_typebox_errors from '@sinclair/typebox/errors';
3
4
  import { Static } from '@sinclair/typebox';
4
5
 
5
6
  interface SessionWaitingForHandshakeListeners {
@@ -19,8 +20,21 @@ declare class SessionWaitingForHandshake<ConnType extends Connection> extends Co
19
20
  listeners: SessionWaitingForHandshakeListeners;
20
21
  handshakeTimeout?: ReturnType<typeof setTimeout>;
21
22
  constructor(props: SessionWaitingForHandshakeProps<ConnType>);
23
+ get loggingMetadata(): {
24
+ protocolVersion?: string | undefined;
25
+ clientId: string;
26
+ connectedTo?: string | undefined;
27
+ sessionId?: string | undefined;
28
+ connId: string;
29
+ transportMessage?: Partial<OpaqueTransportMessage> | undefined;
30
+ validationErrors?: _sinclair_typebox_errors.ValueError[] | undefined;
31
+ tags?: Tags[] | undefined;
32
+ telemetry?: {
33
+ traceId: string;
34
+ spanId: string;
35
+ } | undefined;
36
+ };
22
37
  onHandshakeData: (msg: Uint8Array) => void;
23
- get loggingMetadata(): MessageMetadata;
24
38
  sendHandshake(msg: TransportMessage): boolean;
25
39
  _handleStateExit(): void;
26
40
  _handleClose(): void;
@@ -49,7 +63,6 @@ declare abstract class ServerTransport<ConnType extends Connection> extends Tran
49
63
  protected handleConnection(conn: ConnType): void;
50
64
  private rejectHandshakeRequest;
51
65
  protected onHandshakeRequest(session: SessionWaitingForHandshake<ConnType>, msg: OpaqueTransportMessage): Promise<void>;
52
- private validateHandshakeMetadata;
53
66
  }
54
67
 
55
68
  export { ServerTransport as S, SessionWaitingForHandshake as a };
@@ -1,8 +1,8 @@
1
1
  import { Static, TObject, TUnion, TString, TSchema, TNever, TLiteral } from '@sinclair/typebox';
2
2
  import { Pushable } from 'it-pushable';
3
- import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-1a86f06d.js';
4
- import { c as TransportClientId } from './message-57296605.js';
5
- import { C as ClientTransport } from './client-654098be.js';
3
+ import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-154a0bb2.js';
4
+ import { c as TransportClientId } from './message-ff78a233.js';
5
+ import { C as ClientTransport } from './client-1894a9c9.js';
6
6
 
7
7
  type AsyncIter<T> = AsyncGenerator<T, T>;
8
8
  /**
@@ -420,6 +420,7 @@ var StateMachineState = class {
420
420
  }
421
421
  if (prop === "_handleClose") {
422
422
  return () => {
423
+ target._isConsumed = true;
423
424
  target._handleStateExit();
424
425
  target._handleClose();
425
426
  };
@@ -500,15 +501,18 @@ var IdentifiedSession = class extends CommonSession {
500
501
  }
501
502
  get loggingMetadata() {
502
503
  const spanContext = this.telemetry.span.spanContext();
503
- return {
504
+ const metadata = {
504
505
  clientId: this.from,
505
506
  connectedTo: this.to,
506
- sessionId: this.id,
507
- telemetry: {
507
+ sessionId: this.id
508
+ };
509
+ if (this.telemetry.span.isRecording()) {
510
+ metadata.telemetry = {
508
511
  traceId: spanContext.traceId,
509
512
  spanId: spanContext.spanId
510
- }
511
- };
513
+ };
514
+ }
515
+ return metadata;
512
516
  }
513
517
  constructMsg(partialMsg) {
514
518
  const msg = {
@@ -590,7 +594,16 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
590
594
  // close a pending connection if it resolves, ignore errors if the promise
591
595
  // ends up rejected anyways
592
596
  bestEffortClose() {
593
- void this.connPromise.then((conn) => conn.close()).catch(() => {
597
+ void this.connPromise.then((conn) => {
598
+ conn.close();
599
+ this.log?.info(
600
+ "connection eventually resolved but session has transitioned, closed connection",
601
+ {
602
+ ...this.loggingMetadata,
603
+ ...conn.loggingMetadata
604
+ }
605
+ );
606
+ }).catch(() => {
594
607
  });
595
608
  }
596
609
  _handleStateExit() {
@@ -621,7 +634,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
621
634
  var import_api = require("@opentelemetry/api");
622
635
 
623
636
  // package.json
624
- var version = "0.26.2";
637
+ var version = "0.26.3";
625
638
 
626
639
  // tracing/index.ts
627
640
  function getPropagationContext(ctx) {
@@ -669,6 +682,13 @@ var SessionWaitingForHandshake = class extends CommonSession {
669
682
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
670
683
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
671
684
  }
685
+ get loggingMetadata() {
686
+ return {
687
+ clientId: this.from,
688
+ connId: this.conn.id,
689
+ ...this.conn.loggingMetadata
690
+ };
691
+ }
672
692
  onHandshakeData = (msg) => {
673
693
  const parsedMsg = this.parseMsg(msg);
674
694
  if (parsedMsg === null) {
@@ -680,12 +700,6 @@ var SessionWaitingForHandshake = class extends CommonSession {
680
700
  }
681
701
  this.listeners.onHandshake(parsedMsg);
682
702
  };
683
- get loggingMetadata() {
684
- return {
685
- clientId: this.from,
686
- connId: this.conn.id
687
- };
688
- }
689
703
  sendHandshake(msg) {
690
704
  return this.conn.send(this.options.codec.toBuffer(msg));
691
705
  }
@@ -718,6 +732,12 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
718
732
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
719
733
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
720
734
  }
735
+ get loggingMetadata() {
736
+ return {
737
+ ...super.loggingMetadata,
738
+ ...this.conn.loggingMetadata
739
+ };
740
+ }
721
741
  onHandshakeData = (msg) => {
722
742
  const parsedMsg = this.parseMsg(msg);
723
743
  if (parsedMsg === null) {
@@ -805,6 +825,12 @@ var SessionConnected = class extends IdentifiedSession {
805
825
  this.heartbeatMisses++;
806
826
  }, this.options.heartbeatIntervalMs);
807
827
  }
828
+ get loggingMetadata() {
829
+ return {
830
+ ...super.loggingMetadata,
831
+ ...this.conn.loggingMetadata
832
+ };
833
+ }
808
834
  startActiveHeartbeat() {
809
835
  this.isActivelyHeartbeating = true;
810
836
  }
@@ -1306,8 +1332,9 @@ var Transport = class {
1306
1332
  status: "disconnect",
1307
1333
  session
1308
1334
  });
1335
+ const to = session.to;
1309
1336
  session.close();
1310
- this.sessions.delete(session.to);
1337
+ this.sessions.delete(to);
1311
1338
  }
1312
1339
  // common listeners
1313
1340
  onSessionGracePeriodElapsed(session) {
@@ -1511,14 +1538,14 @@ var ClientTransport = class extends Transport {
1511
1538
  msg.payload.status.code
1512
1539
  ) : false;
1513
1540
  const reason = `handshake failed: ${msg.payload.status.reason}`;
1541
+ const to = session.to;
1514
1542
  this.rejectHandshakeResponse(session, reason, {
1515
1543
  ...session.loggingMetadata,
1516
1544
  transportMessage: msg
1517
1545
  });
1518
1546
  if (retriable) {
1519
- this.tryReconnecting(session.to);
1547
+ this.tryReconnecting(to);
1520
1548
  } else {
1521
- this.deleteSession(session);
1522
1549
  this.protocolError({
1523
1550
  type: ProtocolError.HandshakeFailed,
1524
1551
  code: msg.payload.status.code,
@@ -1571,6 +1598,12 @@ var ClientTransport = class extends Transport {
1571
1598
  * @param to The client ID of the node to connect to.
1572
1599
  */
1573
1600
  connect(to) {
1601
+ if (this.getStatus() !== "open") {
1602
+ this.log?.info(
1603
+ `transport state is no longer open, cancelling attempt to connect to ${to}`
1604
+ );
1605
+ return;
1606
+ }
1574
1607
  let session = this.sessions.get(to);
1575
1608
  session ??= this.createUnconnectedSession(to);
1576
1609
  if (session.state !== "NoConnection" /* NoConnection */) {
@@ -1580,13 +1613,6 @@ var ClientTransport = class extends Transport {
1580
1613
  );
1581
1614
  return;
1582
1615
  }
1583
- if (this.getStatus() !== "open") {
1584
- this.log?.info(
1585
- `transport state is no longer open, cancelling attempt to connect to ${to}`,
1586
- session.loggingMetadata
1587
- );
1588
- return;
1589
- }
1590
1616
  if (!this.retryBudget.hasBudget()) {
1591
1617
  const budgetConsumed = this.retryBudget.getBudgetConsumed();
1592
1618
  const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
@@ -1850,9 +1876,10 @@ var WebSocketClientTransport = class extends ClientTransport {
1850
1876
  };
1851
1877
  });
1852
1878
  const conn = new WebSocketConnection(ws);
1853
- this.log?.info(`raw websocket to ${to} ok, starting handshake`, {
1879
+ this.log?.info(`raw websocket to ${to} ok`, {
1854
1880
  clientId: this.clientId,
1855
- connectedTo: to
1881
+ connectedTo: to,
1882
+ ...conn.loggingMetadata
1856
1883
  });
1857
1884
  return conn;
1858
1885
  }