@replit/river 0.18.0 → 0.18.2

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 (41) hide show
  1. package/dist/{chunk-TIFNW5GQ.js → chunk-D3CC5GL7.js} +1 -1
  2. package/dist/{chunk-UEKU6XRG.js → chunk-K7CUSLWL.js} +1 -1
  3. package/dist/{chunk-ZPPKYJI7.js → chunk-PUX3U2SZ.js} +1 -1
  4. package/dist/{chunk-CLY7AQ25.js → chunk-UABIFWM7.js} +25 -1
  5. package/dist/{chunk-YITXOAPA.js → chunk-WER2DWCP.js} +7 -7
  6. package/dist/{connection-df5f32ee.d.ts → connection-893bd769.d.ts} +1 -1
  7. package/dist/{connection-32bf6608.d.ts → connection-89918b74.d.ts} +1 -1
  8. package/dist/{index-6118cd48.d.ts → index-46ed19d8.d.ts} +6 -12
  9. package/dist/{index-314e676a.d.ts → index-d412ca83.d.ts} +1 -1
  10. package/dist/logging/index.cjs +7 -7
  11. package/dist/logging/index.d.cts +1 -1
  12. package/dist/logging/index.d.ts +1 -1
  13. package/dist/logging/index.js +1 -1
  14. package/dist/{procedures-74a10937.d.ts → procedures-85e52b9c.d.ts} +2 -2
  15. package/dist/router/index.d.cts +4 -4
  16. package/dist/router/index.d.ts +4 -4
  17. package/dist/router/index.js +2 -2
  18. package/dist/transport/impls/uds/client.cjs +10 -0
  19. package/dist/transport/impls/uds/client.d.cts +3 -3
  20. package/dist/transport/impls/uds/client.d.ts +3 -3
  21. package/dist/transport/impls/uds/client.js +3 -3
  22. package/dist/transport/impls/uds/server.cjs +14 -0
  23. package/dist/transport/impls/uds/server.d.cts +3 -3
  24. package/dist/transport/impls/uds/server.d.ts +3 -3
  25. package/dist/transport/impls/uds/server.js +3 -3
  26. package/dist/transport/impls/ws/client.cjs +10 -0
  27. package/dist/transport/impls/ws/client.d.cts +3 -3
  28. package/dist/transport/impls/ws/client.d.ts +3 -3
  29. package/dist/transport/impls/ws/client.js +3 -3
  30. package/dist/transport/impls/ws/server.cjs +14 -0
  31. package/dist/transport/impls/ws/server.d.cts +3 -3
  32. package/dist/transport/impls/ws/server.d.ts +3 -3
  33. package/dist/transport/impls/ws/server.js +3 -3
  34. package/dist/transport/index.cjs +24 -0
  35. package/dist/transport/index.d.cts +2 -2
  36. package/dist/transport/index.d.ts +2 -2
  37. package/dist/transport/index.js +2 -2
  38. package/dist/util/testHelpers.d.cts +3 -3
  39. package/dist/util/testHelpers.d.ts +3 -3
  40. package/dist/util/testHelpers.js +3 -3
  41. package/package.json +1 -1
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-VH3NGOXQ.js";
7
7
  import {
8
8
  log
9
- } from "./chunk-YITXOAPA.js";
9
+ } from "./chunk-WER2DWCP.js";
10
10
 
11
11
  // router/services.ts
12
12
  import { Type } from "@sinclair/typebox";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-CLY7AQ25.js";
3
+ } from "./chunk-UABIFWM7.js";
4
4
 
5
5
  // transport/impls/ws/connection.ts
6
6
  var WebSocketConnection = class extends Connection {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-CLY7AQ25.js";
3
+ } from "./chunk-UABIFWM7.js";
4
4
 
5
5
  // transport/transforms/messageFraming.ts
6
6
  import { Transform } from "node:stream";
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-VH3NGOXQ.js";
11
11
  import {
12
12
  log
13
- } from "./chunk-YITXOAPA.js";
13
+ } from "./chunk-WER2DWCP.js";
14
14
  import {
15
15
  NaiveJsonCodec
16
16
  } from "./chunk-GZ7HCLLM.js";
@@ -688,6 +688,15 @@ var ClientTransport = class extends Transport {
688
688
  if (this.state !== "open")
689
689
  return;
690
690
  let session = void 0;
691
+ const handshakeTimeout = setTimeout(() => {
692
+ if (!session) {
693
+ log?.warn(
694
+ `connection to ${to} timed out waiting for handshake, closing`,
695
+ { clientId: this.clientId, connectedTo: to, connId: conn.debugId }
696
+ );
697
+ conn.close();
698
+ }
699
+ }, this.options.sessionDisconnectGraceMs);
691
700
  const handshakeHandler = (data) => {
692
701
  const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
693
702
  if (!maybeSession) {
@@ -695,6 +704,7 @@ var ClientTransport = class extends Transport {
695
704
  return;
696
705
  } else {
697
706
  session = maybeSession;
707
+ clearTimeout(handshakeTimeout);
698
708
  }
699
709
  conn.removeDataListener(handshakeHandler);
700
710
  conn.addDataListener((data2) => {
@@ -888,6 +898,19 @@ var ServerTransport = class extends Transport {
888
898
  });
889
899
  let session = void 0;
890
900
  const client = () => session?.to ?? "unknown";
901
+ const handshakeTimeout = setTimeout(() => {
902
+ if (!session) {
903
+ log?.warn(
904
+ `connection to ${client()} timed out waiting for handshake, closing`,
905
+ {
906
+ clientId: this.clientId,
907
+ connectedTo: client(),
908
+ connId: conn.debugId
909
+ }
910
+ );
911
+ conn.close();
912
+ }
913
+ }, this.options.sessionDisconnectGraceMs);
891
914
  const handshakeHandler = (data) => {
892
915
  const maybeSession = this.receiveHandshakeRequestMessage(data, conn);
893
916
  if (!maybeSession) {
@@ -895,6 +918,7 @@ var ServerTransport = class extends Transport {
895
918
  return;
896
919
  } else {
897
920
  session = maybeSession;
921
+ clearTimeout(handshakeTimeout);
898
922
  }
899
923
  conn.removeDataListener(handshakeHandler);
900
924
  conn.addDataListener((data2) => {
@@ -33,7 +33,7 @@ var BaseLogger = class {
33
33
  }
34
34
  }
35
35
  };
36
- var stringLogger = (msg, _ctx, level) => {
36
+ var stringLogger = (msg, _ctx, level = "info") => {
37
37
  console.log(`[river:${level}] ${msg}`);
38
38
  };
39
39
  var colorMap = {
@@ -42,7 +42,7 @@ var colorMap = {
42
42
  warn: "\x1B[33m",
43
43
  error: "\x1B[31m"
44
44
  };
45
- var coloredStringLogger = (msg, _ctx, level) => {
45
+ var coloredStringLogger = (msg, _ctx, level = "info") => {
46
46
  const color = colorMap[level];
47
47
  console.log(`[river:${color}${level}\x1B[0m] ${msg}`);
48
48
  };
@@ -55,12 +55,12 @@ function bindLogger(fn, level) {
55
55
  log = void 0;
56
56
  return;
57
57
  }
58
- if (fn instanceof BaseLogger) {
59
- log = fn;
60
- return fn;
58
+ if (typeof fn === "function") {
59
+ log = new BaseLogger(fn, level);
60
+ return log;
61
61
  }
62
- log = new BaseLogger(fn, level);
63
- return log;
62
+ log = fn;
63
+ return fn;
64
64
  }
65
65
 
66
66
  export {
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { C as Connection } from './index-314e676a.js';
2
+ import { C as Connection } from './index-d412ca83.js';
3
3
 
4
4
  declare class WebSocketConnection extends Connection {
5
5
  ws: WebSocket;
@@ -1,4 +1,4 @@
1
- import { C as Connection } from './index-314e676a.js';
1
+ import { C as Connection } from './index-d412ca83.js';
2
2
  import { Socket } from 'node:net';
3
3
  import stream, { Transform, TransformCallback, TransformOptions } from 'node:stream';
4
4
 
@@ -90,7 +90,10 @@ declare const LoggingLevels: {
90
90
  readonly error: 2;
91
91
  };
92
92
  type LoggingLevel = keyof typeof LoggingLevels;
93
- type LogFn = (msg: string, ctx: MessageMetadata, level: LoggingLevel) => void;
93
+ type LogFn = (msg: string, ctx?: MessageMetadata, level?: LoggingLevel) => void;
94
+ type Logger = {
95
+ [key in LoggingLevel]: LogFn;
96
+ };
94
97
  type MessageMetadata = Record<string, unknown> & Partial<{
95
98
  protocolVersion: string;
96
99
  clientId: string;
@@ -100,18 +103,9 @@ type MessageMetadata = Record<string, unknown> & Partial<{
100
103
  fullTransportMessage: OpaqueTransportMessage;
101
104
  partialTransportMessage: Partial<PartialTransportMessage>;
102
105
  }>;
103
- declare class BaseLogger {
104
- minLevel: LoggingLevel;
105
- private output;
106
- constructor(output: LogFn, minLevel?: LoggingLevel);
107
- debug(msg: string, metadata?: MessageMetadata): void;
108
- info(msg: string, metadata?: MessageMetadata): void;
109
- warn(msg: string, metadata?: MessageMetadata): void;
110
- error(msg: string, metadata?: MessageMetadata): void;
111
- }
112
106
  declare const stringLogger: LogFn;
113
107
  declare const coloredStringLogger: LogFn;
114
108
  declare const jsonLogger: LogFn;
115
- declare function bindLogger(fn: LogFn | BaseLogger | undefined, level?: LoggingLevel): BaseLogger | undefined;
109
+ declare function bindLogger(fn: LogFn | Logger | undefined, level?: LoggingLevel): Logger | undefined;
116
110
 
117
- export { LogFn as L, MessageMetadata as M, OpaqueTransportMessage as O, PartialTransportMessage as P, TransportClientId as T, TransportMessage as a, TransportMessageSchema as b, OpaqueTransportMessageSchema as c, isStreamClose as d, coloredStringLogger as e, bindLogger as f, isStreamOpen as i, jsonLogger as j, stringLogger as s };
111
+ export { Logger as L, MessageMetadata as M, OpaqueTransportMessage as O, PartialTransportMessage as P, TransportClientId as T, TransportMessage as a, TransportMessageSchema as b, OpaqueTransportMessageSchema as c, isStreamClose as d, coloredStringLogger as e, bindLogger as f, LogFn as g, isStreamOpen as i, jsonLogger as j, stringLogger as s };
@@ -1,5 +1,5 @@
1
1
  import { C as Codec } from './types-3e5768ec.js';
2
- import { T as TransportClientId, M as MessageMetadata, P as PartialTransportMessage, a as TransportMessage, O as OpaqueTransportMessage } from './index-6118cd48.js';
2
+ import { T as TransportClientId, M as MessageMetadata, P as PartialTransportMessage, a as TransportMessage, O as OpaqueTransportMessage } from './index-46ed19d8.js';
3
3
 
4
4
  /**
5
5
  * A connection is the actual raw underlying transport connection.
@@ -62,7 +62,7 @@ var BaseLogger = class {
62
62
  }
63
63
  }
64
64
  };
65
- var stringLogger = (msg, _ctx, level) => {
65
+ var stringLogger = (msg, _ctx, level = "info") => {
66
66
  console.log(`[river:${level}] ${msg}`);
67
67
  };
68
68
  var colorMap = {
@@ -71,7 +71,7 @@ var colorMap = {
71
71
  warn: "\x1B[33m",
72
72
  error: "\x1B[31m"
73
73
  };
74
- var coloredStringLogger = (msg, _ctx, level) => {
74
+ var coloredStringLogger = (msg, _ctx, level = "info") => {
75
75
  const color = colorMap[level];
76
76
  console.log(`[river:${color}${level}\x1B[0m] ${msg}`);
77
77
  };
@@ -84,12 +84,12 @@ function bindLogger(fn, level) {
84
84
  log = void 0;
85
85
  return;
86
86
  }
87
- if (fn instanceof BaseLogger) {
88
- log = fn;
89
- return fn;
87
+ if (typeof fn === "function") {
88
+ log = new BaseLogger(fn, level);
89
+ return log;
90
90
  }
91
- log = new BaseLogger(fn, level);
92
- return log;
91
+ log = fn;
92
+ return fn;
93
93
  }
94
94
  // Annotate the CommonJS export names for ESM import in node:
95
95
  0 && (module.exports = {
@@ -1,2 +1,2 @@
1
- export { L as LogFn, M as MessageMetadata, f as bindLogger, e as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-6118cd48.js';
1
+ export { g as LogFn, L as Logger, M as MessageMetadata, f as bindLogger, e as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-46ed19d8.js';
2
2
  import '@sinclair/typebox';
@@ -1,2 +1,2 @@
1
- export { L as LogFn, M as MessageMetadata, f as bindLogger, e as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-6118cd48.js';
1
+ export { g as LogFn, L as Logger, M as MessageMetadata, f as bindLogger, e as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-46ed19d8.js';
2
2
  import '@sinclair/typebox';
@@ -3,7 +3,7 @@ import {
3
3
  coloredStringLogger,
4
4
  jsonLogger,
5
5
  stringLogger
6
- } from "../chunk-YITXOAPA.js";
6
+ } from "../chunk-WER2DWCP.js";
7
7
  export {
8
8
  bindLogger,
9
9
  coloredStringLogger,
@@ -1,7 +1,7 @@
1
1
  import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
2
2
  import { Pushable } from 'it-pushable';
3
- import { T as TransportClientId } from './index-6118cd48.js';
4
- import { a as Session, C as Connection } from './index-314e676a.js';
3
+ import { T as TransportClientId } from './index-46ed19d8.js';
4
+ import { a as Session, C as Connection } from './index-d412ca83.js';
5
5
 
6
6
  type TLiteralString = TLiteral<string>;
7
7
  type RiverErrorSchema = TObject<{
@@ -1,9 +1,9 @@
1
1
  import { TUnion, Static } from '@sinclair/typebox';
2
- import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-74a10937.js';
3
- export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-74a10937.js';
4
- import { b as ClientTransport, C as Connection, c as ServerTransport } from '../index-314e676a.js';
2
+ import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-85e52b9c.js';
3
+ export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-85e52b9c.js';
4
+ import { b as ClientTransport, C as Connection, c as ServerTransport } from '../index-d412ca83.js';
5
5
  import { Pushable } from 'it-pushable';
6
- import { T as TransportClientId } from '../index-6118cd48.js';
6
+ import { T as TransportClientId } from '../index-46ed19d8.js';
7
7
  import '../types-3e5768ec.js';
8
8
 
9
9
  /**
@@ -1,9 +1,9 @@
1
1
  import { TUnion, Static } from '@sinclair/typebox';
2
- import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-74a10937.js';
3
- export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-74a10937.js';
4
- import { b as ClientTransport, C as Connection, c as ServerTransport } from '../index-314e676a.js';
2
+ import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-85e52b9c.js';
3
+ export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-85e52b9c.js';
4
+ import { b as ClientTransport, C as Connection, c as ServerTransport } from '../index-d412ca83.js';
5
5
  import { Pushable } from 'it-pushable';
6
- import { T as TransportClientId } from '../index-6118cd48.js';
6
+ import { T as TransportClientId } from '../index-46ed19d8.js';
7
7
  import '../types-3e5768ec.js';
8
8
 
9
9
  /**
@@ -7,9 +7,9 @@ import {
7
7
  UNCAUGHT_ERROR,
8
8
  createClient,
9
9
  createServer
10
- } from "../chunk-TIFNW5GQ.js";
10
+ } from "../chunk-D3CC5GL7.js";
11
11
  import "../chunk-VH3NGOXQ.js";
12
- import "../chunk-YITXOAPA.js";
12
+ import "../chunk-WER2DWCP.js";
13
13
  export {
14
14
  Err,
15
15
  Ok,
@@ -925,6 +925,15 @@ var ClientTransport = class extends Transport {
925
925
  if (this.state !== "open")
926
926
  return;
927
927
  let session = void 0;
928
+ const handshakeTimeout = setTimeout(() => {
929
+ if (!session) {
930
+ log?.warn(
931
+ `connection to ${to} timed out waiting for handshake, closing`,
932
+ { clientId: this.clientId, connectedTo: to, connId: conn.debugId }
933
+ );
934
+ conn.close();
935
+ }
936
+ }, this.options.sessionDisconnectGraceMs);
928
937
  const handshakeHandler = (data) => {
929
938
  const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
930
939
  if (!maybeSession) {
@@ -932,6 +941,7 @@ var ClientTransport = class extends Transport {
932
941
  return;
933
942
  } else {
934
943
  session = maybeSession;
944
+ clearTimeout(handshakeTimeout);
935
945
  }
936
946
  conn.removeDataListener(handshakeHandler);
937
947
  conn.addDataListener((data2) => {
@@ -1,6 +1,6 @@
1
- import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
2
- import { T as TransportClientId } from '../../../index-6118cd48.js';
3
- import { U as UdsConnection } from '../../../connection-32bf6608.js';
1
+ import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
2
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
3
+ import { U as UdsConnection } from '../../../connection-89918b74.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'node:net';
@@ -1,6 +1,6 @@
1
- import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
2
- import { T as TransportClientId } from '../../../index-6118cd48.js';
3
- import { U as UdsConnection } from '../../../connection-32bf6608.js';
1
+ import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
2
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
3
+ import { U as UdsConnection } from '../../../connection-89918b74.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'node:net';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-ZPPKYJI7.js";
3
+ } from "../../../chunk-PUX3U2SZ.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-CLY7AQ25.js";
6
+ } from "../../../chunk-UABIFWM7.js";
7
7
  import "../../../chunk-VH3NGOXQ.js";
8
8
  import {
9
9
  log
10
- } from "../../../chunk-YITXOAPA.js";
10
+ } from "../../../chunk-WER2DWCP.js";
11
11
  import "../../../chunk-GZ7HCLLM.js";
12
12
 
13
13
  // transport/impls/uds/client.ts
@@ -744,6 +744,19 @@ var ServerTransport = class extends Transport {
744
744
  });
745
745
  let session = void 0;
746
746
  const client = () => session?.to ?? "unknown";
747
+ const handshakeTimeout = setTimeout(() => {
748
+ if (!session) {
749
+ log?.warn(
750
+ `connection to ${client()} timed out waiting for handshake, closing`,
751
+ {
752
+ clientId: this.clientId,
753
+ connectedTo: client(),
754
+ connId: conn.debugId
755
+ }
756
+ );
757
+ conn.close();
758
+ }
759
+ }, this.options.sessionDisconnectGraceMs);
747
760
  const handshakeHandler = (data) => {
748
761
  const maybeSession = this.receiveHandshakeRequestMessage(data, conn);
749
762
  if (!maybeSession) {
@@ -751,6 +764,7 @@ var ServerTransport = class extends Transport {
751
764
  return;
752
765
  } else {
753
766
  session = maybeSession;
767
+ clearTimeout(handshakeTimeout);
754
768
  }
755
769
  conn.removeDataListener(handshakeHandler);
756
770
  conn.addDataListener((data2) => {
@@ -1,7 +1,7 @@
1
1
  import { Server, Socket } from 'node:net';
2
- import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-314e676a.js';
3
- import { T as TransportClientId } from '../../../index-6118cd48.js';
4
- import { U as UdsConnection } from '../../../connection-32bf6608.js';
2
+ import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-d412ca83.js';
3
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
4
+ import { U as UdsConnection } from '../../../connection-89918b74.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
  import 'node:stream';
@@ -1,7 +1,7 @@
1
1
  import { Server, Socket } from 'node:net';
2
- import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-314e676a.js';
3
- import { T as TransportClientId } from '../../../index-6118cd48.js';
4
- import { U as UdsConnection } from '../../../connection-32bf6608.js';
2
+ import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-d412ca83.js';
3
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
4
+ import { U as UdsConnection } from '../../../connection-89918b74.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
  import 'node:stream';
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-ZPPKYJI7.js";
3
+ } from "../../../chunk-PUX3U2SZ.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-CLY7AQ25.js";
6
+ } from "../../../chunk-UABIFWM7.js";
7
7
  import "../../../chunk-VH3NGOXQ.js";
8
- import "../../../chunk-YITXOAPA.js";
8
+ import "../../../chunk-WER2DWCP.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
10
10
 
11
11
  // transport/impls/uds/server.ts
@@ -829,6 +829,15 @@ var ClientTransport = class extends Transport {
829
829
  if (this.state !== "open")
830
830
  return;
831
831
  let session = void 0;
832
+ const handshakeTimeout = setTimeout(() => {
833
+ if (!session) {
834
+ log?.warn(
835
+ `connection to ${to} timed out waiting for handshake, closing`,
836
+ { clientId: this.clientId, connectedTo: to, connId: conn.debugId }
837
+ );
838
+ conn.close();
839
+ }
840
+ }, this.options.sessionDisconnectGraceMs);
832
841
  const handshakeHandler = (data) => {
833
842
  const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
834
843
  if (!maybeSession) {
@@ -836,6 +845,7 @@ var ClientTransport = class extends Transport {
836
845
  return;
837
846
  } else {
838
847
  session = maybeSession;
848
+ clearTimeout(handshakeTimeout);
839
849
  }
840
850
  conn.removeDataListener(handshakeHandler);
841
851
  conn.addDataListener((data2) => {
@@ -1,7 +1,7 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
3
- import { T as TransportClientId } from '../../../index-6118cd48.js';
4
- import { W as WebSocketConnection } from '../../../connection-df5f32ee.js';
2
+ import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
3
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
4
+ import { W as WebSocketConnection } from '../../../connection-893bd769.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
3
- import { T as TransportClientId } from '../../../index-6118cd48.js';
4
- import { W as WebSocketConnection } from '../../../connection-df5f32ee.js';
2
+ import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
3
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
4
+ import { W as WebSocketConnection } from '../../../connection-893bd769.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-UEKU6XRG.js";
3
+ } from "../../../chunk-K7CUSLWL.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-CLY7AQ25.js";
6
+ } from "../../../chunk-UABIFWM7.js";
7
7
  import "../../../chunk-VH3NGOXQ.js";
8
8
  import {
9
9
  log
10
- } from "../../../chunk-YITXOAPA.js";
10
+ } from "../../../chunk-WER2DWCP.js";
11
11
  import "../../../chunk-GZ7HCLLM.js";
12
12
 
13
13
  // transport/impls/ws/client.ts
@@ -744,6 +744,19 @@ var ServerTransport = class extends Transport {
744
744
  });
745
745
  let session = void 0;
746
746
  const client = () => session?.to ?? "unknown";
747
+ const handshakeTimeout = setTimeout(() => {
748
+ if (!session) {
749
+ log?.warn(
750
+ `connection to ${client()} timed out waiting for handshake, closing`,
751
+ {
752
+ clientId: this.clientId,
753
+ connectedTo: client(),
754
+ connId: conn.debugId
755
+ }
756
+ );
757
+ conn.close();
758
+ }
759
+ }, this.options.sessionDisconnectGraceMs);
747
760
  const handshakeHandler = (data) => {
748
761
  const maybeSession = this.receiveHandshakeRequestMessage(data, conn);
749
762
  if (!maybeSession) {
@@ -751,6 +764,7 @@ var ServerTransport = class extends Transport {
751
764
  return;
752
765
  } else {
753
766
  session = maybeSession;
767
+ clearTimeout(handshakeTimeout);
754
768
  }
755
769
  conn.removeDataListener(handshakeHandler);
756
770
  conn.addDataListener((data2) => {
@@ -1,8 +1,8 @@
1
- import { T as TransportClientId } from '../../../index-6118cd48.js';
2
- import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-314e676a.js';
1
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
2
+ import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-d412ca83.js';
3
3
  import { WebSocketServer } from 'ws';
4
4
  import { WebSocket } from 'isomorphic-ws';
5
- import { W as WebSocketConnection } from '../../../connection-df5f32ee.js';
5
+ import { W as WebSocketConnection } from '../../../connection-893bd769.js';
6
6
  import '@sinclair/typebox';
7
7
  import '../../../types-3e5768ec.js';
8
8
 
@@ -1,8 +1,8 @@
1
- import { T as TransportClientId } from '../../../index-6118cd48.js';
2
- import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-314e676a.js';
1
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
2
+ import { c as ServerTransport, d as ProvidedTransportOptions } from '../../../index-d412ca83.js';
3
3
  import { WebSocketServer } from 'ws';
4
4
  import { WebSocket } from 'isomorphic-ws';
5
- import { W as WebSocketConnection } from '../../../connection-df5f32ee.js';
5
+ import { W as WebSocketConnection } from '../../../connection-893bd769.js';
6
6
  import '@sinclair/typebox';
7
7
  import '../../../types-3e5768ec.js';
8
8
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-UEKU6XRG.js";
3
+ } from "../../../chunk-K7CUSLWL.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-CLY7AQ25.js";
6
+ } from "../../../chunk-UABIFWM7.js";
7
7
  import "../../../chunk-VH3NGOXQ.js";
8
- import "../../../chunk-YITXOAPA.js";
8
+ import "../../../chunk-WER2DWCP.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
10
10
 
11
11
  // transport/impls/ws/server.ts
@@ -851,6 +851,15 @@ var ClientTransport = class extends Transport {
851
851
  if (this.state !== "open")
852
852
  return;
853
853
  let session = void 0;
854
+ const handshakeTimeout = setTimeout(() => {
855
+ if (!session) {
856
+ log?.warn(
857
+ `connection to ${to} timed out waiting for handshake, closing`,
858
+ { clientId: this.clientId, connectedTo: to, connId: conn.debugId }
859
+ );
860
+ conn.close();
861
+ }
862
+ }, this.options.sessionDisconnectGraceMs);
854
863
  const handshakeHandler = (data) => {
855
864
  const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
856
865
  if (!maybeSession) {
@@ -858,6 +867,7 @@ var ClientTransport = class extends Transport {
858
867
  return;
859
868
  } else {
860
869
  session = maybeSession;
870
+ clearTimeout(handshakeTimeout);
861
871
  }
862
872
  conn.removeDataListener(handshakeHandler);
863
873
  conn.addDataListener((data2) => {
@@ -1051,6 +1061,19 @@ var ServerTransport = class extends Transport {
1051
1061
  });
1052
1062
  let session = void 0;
1053
1063
  const client = () => session?.to ?? "unknown";
1064
+ const handshakeTimeout = setTimeout(() => {
1065
+ if (!session) {
1066
+ log?.warn(
1067
+ `connection to ${client()} timed out waiting for handshake, closing`,
1068
+ {
1069
+ clientId: this.clientId,
1070
+ connectedTo: client(),
1071
+ connId: conn.debugId
1072
+ }
1073
+ );
1074
+ conn.close();
1075
+ }
1076
+ }, this.options.sessionDisconnectGraceMs);
1054
1077
  const handshakeHandler = (data) => {
1055
1078
  const maybeSession = this.receiveHandshakeRequestMessage(data, conn);
1056
1079
  if (!maybeSession) {
@@ -1058,6 +1081,7 @@ var ServerTransport = class extends Transport {
1058
1081
  return;
1059
1082
  } else {
1060
1083
  session = maybeSession;
1084
+ clearTimeout(handshakeTimeout);
1061
1085
  }
1062
1086
  conn.removeDataListener(handshakeHandler);
1063
1087
  conn.addDataListener((data2) => {
@@ -1,4 +1,4 @@
1
- export { b as ClientTransport, P as ClientTransportOptions, C as Connection, g as EventHandler, E as EventMap, f as EventTypes, h as ProtocolError, i as ProtocolErrorType, c as ServerTransport, a as Session, T as Transport, d as TransportOptions, e as TransportStatus } from '../index-314e676a.js';
2
- export { O as OpaqueTransportMessage, c as OpaqueTransportMessageSchema, T as TransportClientId, a as TransportMessage, b as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../index-6118cd48.js';
1
+ export { b as ClientTransport, P as ClientTransportOptions, C as Connection, g as EventHandler, E as EventMap, f as EventTypes, h as ProtocolError, i as ProtocolErrorType, c as ServerTransport, a as Session, T as Transport, d as TransportOptions, e as TransportStatus } from '../index-d412ca83.js';
2
+ export { O as OpaqueTransportMessage, c as OpaqueTransportMessageSchema, T as TransportClientId, a as TransportMessage, b as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../index-46ed19d8.js';
3
3
  import '../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
@@ -1,4 +1,4 @@
1
- export { b as ClientTransport, P as ClientTransportOptions, C as Connection, g as EventHandler, E as EventMap, f as EventTypes, h as ProtocolError, i as ProtocolErrorType, c as ServerTransport, a as Session, T as Transport, d as TransportOptions, e as TransportStatus } from '../index-314e676a.js';
2
- export { O as OpaqueTransportMessage, c as OpaqueTransportMessageSchema, T as TransportClientId, a as TransportMessage, b as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../index-6118cd48.js';
1
+ export { b as ClientTransport, P as ClientTransportOptions, C as Connection, g as EventHandler, E as EventMap, f as EventTypes, h as ProtocolError, i as ProtocolErrorType, c as ServerTransport, a as Session, T as Transport, d as TransportOptions, e as TransportStatus } from '../index-d412ca83.js';
2
+ export { O as OpaqueTransportMessage, c as OpaqueTransportMessageSchema, T as TransportClientId, a as TransportMessage, b as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../index-46ed19d8.js';
3
3
  import '../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
@@ -6,12 +6,12 @@ import {
6
6
  ServerTransport,
7
7
  Session,
8
8
  Transport
9
- } from "../chunk-CLY7AQ25.js";
9
+ } from "../chunk-UABIFWM7.js";
10
10
  import {
11
11
  OpaqueTransportMessageSchema,
12
12
  TransportMessageSchema
13
13
  } from "../chunk-VH3NGOXQ.js";
14
- import "../chunk-YITXOAPA.js";
14
+ import "../chunk-WER2DWCP.js";
15
15
  import "../chunk-GZ7HCLLM.js";
16
16
  export {
17
17
  ClientTransport,
@@ -1,8 +1,8 @@
1
1
  import { Static } from '@sinclair/typebox';
2
- import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-74a10937.js';
3
- import { T as Transport, C as Connection, S as SessionOptions, a as Session } from '../index-314e676a.js';
2
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-85e52b9c.js';
3
+ import { T as Transport, C as Connection, S as SessionOptions, a as Session } from '../index-d412ca83.js';
4
4
  import * as it_pushable from 'it-pushable';
5
- import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-6118cd48.js';
5
+ import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-46ed19d8.js';
6
6
  import WebSocket from 'isomorphic-ws';
7
7
  import http from 'node:http';
8
8
  import net from 'node:net';
@@ -1,8 +1,8 @@
1
1
  import { Static } from '@sinclair/typebox';
2
- import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-74a10937.js';
3
- import { T as Transport, C as Connection, S as SessionOptions, a as Session } from '../index-314e676a.js';
2
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-85e52b9c.js';
3
+ import { T as Transport, C as Connection, S as SessionOptions, a as Session } from '../index-d412ca83.js';
4
4
  import * as it_pushable from 'it-pushable';
5
- import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-6118cd48.js';
5
+ import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-46ed19d8.js';
6
6
  import WebSocket from 'isomorphic-ws';
7
7
  import http from 'node:http';
8
8
  import net from 'node:net';
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  UNCAUGHT_ERROR,
3
3
  pushable
4
- } from "../chunk-TIFNW5GQ.js";
4
+ } from "../chunk-D3CC5GL7.js";
5
5
  import "../chunk-RPIDSIQG.js";
6
6
  import {
7
7
  Session,
8
8
  defaultTransportOptions
9
- } from "../chunk-CLY7AQ25.js";
9
+ } from "../chunk-UABIFWM7.js";
10
10
  import {
11
11
  coerceErrorString
12
12
  } from "../chunk-VH3NGOXQ.js";
13
- import "../chunk-YITXOAPA.js";
13
+ import "../chunk-WER2DWCP.js";
14
14
  import "../chunk-GZ7HCLLM.js";
15
15
 
16
16
  // util/testHelpers.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@replit/river",
3
3
  "description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
4
- "version": "0.18.0",
4
+ "version": "0.18.2",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {