@replit/river 0.13.0 → 0.13.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.
- package/README.md +2 -0
- package/dist/{builder-169fbf7f.d.ts → builder-eef3b061.d.ts} +1 -1
- package/dist/{chunk-CDH7QSB4.js → chunk-23MWJLVJ.js} +1 -1
- package/dist/{chunk-NPXAAD7M.js → chunk-3Y2K543F.js} +1 -1
- package/dist/{chunk-CBRQM65K.js → chunk-67M47YPQ.js} +49 -40
- package/dist/{chunk-MGGIUH5O.js → chunk-GFRAOY75.js} +4 -4
- package/dist/{chunk-R2IMXRVU.js → chunk-NLWRMDT6.js} +4 -1
- package/dist/{connection-dd789651.d.ts → connection-03e650c8.d.ts} +1 -1
- package/dist/{connection-ab681c08.d.ts → connection-d052d027.d.ts} +1 -1
- package/dist/{index-21c1b21d.d.ts → index-9aa0aabb.d.ts} +0 -26
- package/dist/router/index.cjs +53 -44
- package/dist/router/index.d.cts +3 -3
- package/dist/router/index.d.ts +3 -3
- package/dist/router/index.js +2 -2
- package/dist/transport/impls/uds/client.cjs +5 -2
- package/dist/transport/impls/uds/client.d.cts +2 -2
- package/dist/transport/impls/uds/client.d.ts +2 -2
- package/dist/transport/impls/uds/client.js +3 -3
- package/dist/transport/impls/uds/server.cjs +4 -4
- package/dist/transport/impls/uds/server.d.cts +2 -2
- package/dist/transport/impls/uds/server.d.ts +2 -2
- package/dist/transport/impls/uds/server.js +3 -3
- package/dist/transport/impls/ws/client.cjs +8 -12
- package/dist/transport/impls/ws/client.d.cts +2 -2
- package/dist/transport/impls/ws/client.d.ts +2 -2
- package/dist/transport/impls/ws/client.js +6 -13
- package/dist/transport/impls/ws/server.cjs +4 -4
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +7 -4
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +2 -2
- package/dist/util/testHelpers.cjs +1 -1
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ It's like tRPC/gRPC but with
|
|
|
10
10
|
- transparent reconnect support for long-lived sessions
|
|
11
11
|
- over any transport (WebSockets and Unix Domain Socket out of the box)
|
|
12
12
|
|
|
13
|
+
See [PROTOCOL.md](./PROTOCOL.md) for more information on the protocol.
|
|
14
|
+
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
To use River, you must be on least Typescript 5 with `"moduleResolution": "bundler"`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
|
|
2
2
|
import { Pushable } from 'it-pushable';
|
|
3
|
-
import { b as TransportClientId, d as Session, C as Connection } from './index-
|
|
3
|
+
import { b as TransportClientId, d as Session, C as Connection } from './index-9aa0aabb.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The context for services/procedures. This is used only on
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
coerceErrorString,
|
|
4
4
|
isStreamClose,
|
|
5
5
|
isStreamOpen
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GFRAOY75.js";
|
|
7
7
|
import {
|
|
8
8
|
log
|
|
9
9
|
} from "./chunk-H4BYJELI.js";
|
|
@@ -438,6 +438,11 @@ var createClient = (transport) => _createRecursiveProxy(async (opts) => {
|
|
|
438
438
|
);
|
|
439
439
|
}
|
|
440
440
|
const [input] = opts.args;
|
|
441
|
+
log?.info(
|
|
442
|
+
`${transport.clientId} -- invoked ${procType}: ${serviceName}.${procName} with args: ${JSON.stringify(
|
|
443
|
+
input
|
|
444
|
+
)}`
|
|
445
|
+
);
|
|
441
446
|
if (procType === "rpc") {
|
|
442
447
|
return handleRpc(
|
|
443
448
|
transport,
|
|
@@ -505,16 +510,12 @@ function handleRpc(transport, serverId, input, serviceName, procedureName) {
|
|
|
505
510
|
transport.removeEventListener("sessionStatus", onSessionStatus);
|
|
506
511
|
}
|
|
507
512
|
function onMessage(msg) {
|
|
508
|
-
if (msg.streamId !== streamId)
|
|
513
|
+
if (msg.streamId !== streamId)
|
|
509
514
|
return;
|
|
510
|
-
|
|
511
|
-
if (msg.to !== transport.clientId) {
|
|
515
|
+
if (msg.to !== transport.clientId)
|
|
512
516
|
return;
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
cleanup();
|
|
516
|
-
resolve(msg.payload);
|
|
517
|
-
}
|
|
517
|
+
cleanup();
|
|
518
|
+
resolve(msg.payload);
|
|
518
519
|
}
|
|
519
520
|
transport.addEventListener("message", onMessage);
|
|
520
521
|
transport.addEventListener("sessionStatus", onSessionStatus);
|
|
@@ -558,12 +559,10 @@ function handleStream(transport, serverId, init, serviceName, procedureName) {
|
|
|
558
559
|
};
|
|
559
560
|
void pipeInputToTransport();
|
|
560
561
|
function onMessage(msg) {
|
|
561
|
-
if (msg.streamId !== streamId)
|
|
562
|
+
if (msg.streamId !== streamId)
|
|
562
563
|
return;
|
|
563
|
-
|
|
564
|
-
if (msg.to !== transport.clientId) {
|
|
564
|
+
if (msg.to !== transport.clientId)
|
|
565
565
|
return;
|
|
566
|
-
}
|
|
567
566
|
if (isStreamClose(msg.controlFlags)) {
|
|
568
567
|
cleanup();
|
|
569
568
|
} else {
|
|
@@ -602,12 +601,10 @@ function handleSubscribe(transport, serverId, input, serviceName, procedureName)
|
|
|
602
601
|
let healthyClose = true;
|
|
603
602
|
const outputStream = pushable({ objectMode: true });
|
|
604
603
|
function onMessage(msg) {
|
|
605
|
-
if (msg.streamId !== streamId)
|
|
604
|
+
if (msg.streamId !== streamId)
|
|
606
605
|
return;
|
|
607
|
-
|
|
608
|
-
if (msg.to !== transport.clientId) {
|
|
606
|
+
if (msg.to !== transport.clientId)
|
|
609
607
|
return;
|
|
610
|
-
}
|
|
611
608
|
if (isStreamClose(msg.controlFlags)) {
|
|
612
609
|
cleanup();
|
|
613
610
|
} else {
|
|
@@ -691,13 +688,12 @@ function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
|
691
688
|
transport.removeEventListener("sessionStatus", onSessionStatus);
|
|
692
689
|
}
|
|
693
690
|
function onMessage(msg) {
|
|
694
|
-
if (msg.
|
|
691
|
+
if (msg.streamId !== streamId)
|
|
695
692
|
return;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
}
|
|
693
|
+
if (msg.to !== transport.clientId)
|
|
694
|
+
return;
|
|
695
|
+
cleanup();
|
|
696
|
+
resolve(msg.payload);
|
|
701
697
|
}
|
|
702
698
|
transport.addEventListener("message", onMessage);
|
|
703
699
|
transport.addEventListener("sessionStatus", onSessionStatus);
|
|
@@ -752,17 +748,15 @@ var RiverServer = class {
|
|
|
752
748
|
};
|
|
753
749
|
// cleanup streams on session close
|
|
754
750
|
onSessionStatus = async (evt) => {
|
|
755
|
-
if (evt.status !== "disconnect")
|
|
751
|
+
if (evt.status !== "disconnect")
|
|
756
752
|
return;
|
|
757
|
-
}
|
|
758
753
|
const disconnectedClientId = evt.session.to;
|
|
759
754
|
log?.info(
|
|
760
755
|
`${this.transport.clientId} -- got session disconnect from ${disconnectedClientId}, cleaning up streams`
|
|
761
756
|
);
|
|
762
757
|
const streamsFromThisClient = this.clientStreams.get(disconnectedClientId);
|
|
763
|
-
if (!streamsFromThisClient)
|
|
758
|
+
if (!streamsFromThisClient)
|
|
764
759
|
return;
|
|
765
|
-
}
|
|
766
760
|
this.disconnectedSessions.add(disconnectedClientId);
|
|
767
761
|
await Promise.all(
|
|
768
762
|
Array.from(streamsFromThisClient).map(this.cleanupStream)
|
|
@@ -812,21 +806,36 @@ var RiverServer = class {
|
|
|
812
806
|
const procedure = service.procedures[message.procedureName];
|
|
813
807
|
const incoming = pushable({ objectMode: true });
|
|
814
808
|
const outgoing = pushable({ objectMode: true });
|
|
809
|
+
const needsClose = procedure.type === "subscription" || procedure.type === "stream";
|
|
815
810
|
const outputHandler = (
|
|
816
811
|
// sending outgoing messages back to client
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
this.
|
|
828
|
-
|
|
829
|
-
|
|
812
|
+
needsClose ? (
|
|
813
|
+
// subscription and stream case, we need to send a close bit after the response stream
|
|
814
|
+
(async () => {
|
|
815
|
+
for await (const response of outgoing) {
|
|
816
|
+
this.transport.send(session.to, {
|
|
817
|
+
streamId: message.streamId,
|
|
818
|
+
controlFlags: 0,
|
|
819
|
+
payload: response
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
if (!this.disconnectedSessions.has(message.from)) {
|
|
823
|
+
this.transport.sendCloseStream(session.to, message.streamId);
|
|
824
|
+
}
|
|
825
|
+
})()
|
|
826
|
+
) : (
|
|
827
|
+
// rpc and upload case, we just send the response back with close bit
|
|
828
|
+
(async () => {
|
|
829
|
+
const response = await outgoing.next().then((res) => res.value);
|
|
830
|
+
if (response) {
|
|
831
|
+
this.transport.send(session.to, {
|
|
832
|
+
streamId: message.streamId,
|
|
833
|
+
controlFlags: 4 /* StreamClosedBit */,
|
|
834
|
+
payload: response
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
})()
|
|
838
|
+
)
|
|
830
839
|
);
|
|
831
840
|
const errorHandler = (err) => {
|
|
832
841
|
const errorMsg = coerceErrorString(err);
|
|
@@ -34,7 +34,7 @@ var ControlMessageHandshakeResponseSchema = Type.Object({
|
|
|
34
34
|
}),
|
|
35
35
|
Type.Object({
|
|
36
36
|
ok: Type.Literal(false),
|
|
37
|
-
reason: Type.
|
|
37
|
+
reason: Type.String()
|
|
38
38
|
})
|
|
39
39
|
])
|
|
40
40
|
});
|
|
@@ -63,7 +63,7 @@ function handshakeRequestMessage(from, to, instanceId) {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
66
|
+
function handshakeResponseMessage(from, instanceId, to, ok, reason) {
|
|
67
67
|
return {
|
|
68
68
|
id: nanoid(),
|
|
69
69
|
from,
|
|
@@ -82,7 +82,7 @@ function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
|
82
82
|
type: "HANDSHAKE_RESP",
|
|
83
83
|
status: {
|
|
84
84
|
ok: false,
|
|
85
|
-
reason: "
|
|
85
|
+
reason: reason ?? "Unknown reason"
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
};
|
|
@@ -106,7 +106,7 @@ function isStreamClose(controlFlag) {
|
|
|
106
106
|
// util/stringify.ts
|
|
107
107
|
function coerceErrorString(err) {
|
|
108
108
|
if (err instanceof Error) {
|
|
109
|
-
return err.message;
|
|
109
|
+
return err.message || "unknown reason";
|
|
110
110
|
}
|
|
111
111
|
return `[coerced to error] ${String(err)}`;
|
|
112
112
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
handshakeRequestMessage,
|
|
8
8
|
handshakeResponseMessage,
|
|
9
9
|
isAck
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GFRAOY75.js";
|
|
11
11
|
import {
|
|
12
12
|
log
|
|
13
13
|
} from "./chunk-H4BYJELI.js";
|
|
@@ -625,6 +625,9 @@ var ClientTransport = class extends Transport {
|
|
|
625
625
|
} catch (error) {
|
|
626
626
|
const errStr = coerceErrorString(error);
|
|
627
627
|
this.inflightConnectionPromises.delete(to);
|
|
628
|
+
const shouldRetry = this.state === "open" && this.tryReconnecting;
|
|
629
|
+
if (!shouldRetry)
|
|
630
|
+
return;
|
|
628
631
|
if (attempt >= this.options.retryAttemptsMax) {
|
|
629
632
|
const errMsg = `connection to ${to} failed after ${attempt} attempts (${errStr}), giving up`;
|
|
630
633
|
log?.error(`${this.clientId} -- ${errMsg}`);
|
|
@@ -140,32 +140,6 @@ interface SessionOptions {
|
|
|
140
140
|
* - This will only be considered disconnected if
|
|
141
141
|
* - the server tells the client that we’ve reconnected but it doesn’t recognize us anymore (server definitely died) or
|
|
142
142
|
* - we hit a grace period after a connection disconnect
|
|
143
|
-
*
|
|
144
|
-
* Here's a legend for what each of the numbers means. A '-' indicates the
|
|
145
|
-
* session/connection is connected and ' ' means it is disconnected.
|
|
146
|
-
*
|
|
147
|
-
* 1. connectionStatus :: connect
|
|
148
|
-
* 2. sessionStatus :: connect
|
|
149
|
-
* 3. connectionStatus :: disconnect
|
|
150
|
-
* 4. sessionStatus :: disconnect
|
|
151
|
-
*
|
|
152
|
-
* From the server's perspective:
|
|
153
|
-
* ```plaintext
|
|
154
|
-
* session 2-----------------------4
|
|
155
|
-
* connection ----1---------3 1-------3
|
|
156
|
-
* ^-^ grace period
|
|
157
|
-
* ^---^ connection is created
|
|
158
|
-
* before connectionStatus event is fired
|
|
159
|
-
* ```
|
|
160
|
-
*
|
|
161
|
-
* From the client's perspective:
|
|
162
|
-
* ```plaintext
|
|
163
|
-
* session 2---------------------------4
|
|
164
|
-
* connection 1---------3 1-------3
|
|
165
|
-
* ^-^ grace period
|
|
166
|
-
* ^---^ session is created as soon
|
|
167
|
-
* as we send an outgoing message
|
|
168
|
-
* ```
|
|
169
143
|
*/
|
|
170
144
|
declare class Session<ConnType extends Connection> {
|
|
171
145
|
private codec;
|
package/dist/router/index.cjs
CHANGED
|
@@ -438,7 +438,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox2.Type.Object({
|
|
|
438
438
|
}),
|
|
439
439
|
import_typebox2.Type.Object({
|
|
440
440
|
ok: import_typebox2.Type.Literal(false),
|
|
441
|
-
reason: import_typebox2.Type.
|
|
441
|
+
reason: import_typebox2.Type.String()
|
|
442
442
|
})
|
|
443
443
|
])
|
|
444
444
|
});
|
|
@@ -491,6 +491,9 @@ function Err(error) {
|
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
+
// logging/index.ts
|
|
495
|
+
var log;
|
|
496
|
+
|
|
494
497
|
// router/client.ts
|
|
495
498
|
var noop = () => {
|
|
496
499
|
};
|
|
@@ -521,6 +524,11 @@ var createClient = (transport) => _createRecursiveProxy(async (opts) => {
|
|
|
521
524
|
);
|
|
522
525
|
}
|
|
523
526
|
const [input] = opts.args;
|
|
527
|
+
log?.info(
|
|
528
|
+
`${transport.clientId} -- invoked ${procType}: ${serviceName}.${procName} with args: ${JSON.stringify(
|
|
529
|
+
input
|
|
530
|
+
)}`
|
|
531
|
+
);
|
|
524
532
|
if (procType === "rpc") {
|
|
525
533
|
return handleRpc(
|
|
526
534
|
transport,
|
|
@@ -588,16 +596,12 @@ function handleRpc(transport, serverId, input, serviceName, procedureName) {
|
|
|
588
596
|
transport.removeEventListener("sessionStatus", onSessionStatus);
|
|
589
597
|
}
|
|
590
598
|
function onMessage(msg) {
|
|
591
|
-
if (msg.streamId !== streamId)
|
|
599
|
+
if (msg.streamId !== streamId)
|
|
592
600
|
return;
|
|
593
|
-
|
|
594
|
-
if (msg.to !== transport.clientId) {
|
|
601
|
+
if (msg.to !== transport.clientId)
|
|
595
602
|
return;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
cleanup();
|
|
599
|
-
resolve(msg.payload);
|
|
600
|
-
}
|
|
603
|
+
cleanup();
|
|
604
|
+
resolve(msg.payload);
|
|
601
605
|
}
|
|
602
606
|
transport.addEventListener("message", onMessage);
|
|
603
607
|
transport.addEventListener("sessionStatus", onSessionStatus);
|
|
@@ -641,12 +645,10 @@ function handleStream(transport, serverId, init, serviceName, procedureName) {
|
|
|
641
645
|
};
|
|
642
646
|
void pipeInputToTransport();
|
|
643
647
|
function onMessage(msg) {
|
|
644
|
-
if (msg.streamId !== streamId)
|
|
648
|
+
if (msg.streamId !== streamId)
|
|
645
649
|
return;
|
|
646
|
-
|
|
647
|
-
if (msg.to !== transport.clientId) {
|
|
650
|
+
if (msg.to !== transport.clientId)
|
|
648
651
|
return;
|
|
649
|
-
}
|
|
650
652
|
if (isStreamClose(msg.controlFlags)) {
|
|
651
653
|
cleanup();
|
|
652
654
|
} else {
|
|
@@ -685,12 +687,10 @@ function handleSubscribe(transport, serverId, input, serviceName, procedureName)
|
|
|
685
687
|
let healthyClose = true;
|
|
686
688
|
const outputStream = pushable({ objectMode: true });
|
|
687
689
|
function onMessage(msg) {
|
|
688
|
-
if (msg.streamId !== streamId)
|
|
690
|
+
if (msg.streamId !== streamId)
|
|
689
691
|
return;
|
|
690
|
-
|
|
691
|
-
if (msg.to !== transport.clientId) {
|
|
692
|
+
if (msg.to !== transport.clientId)
|
|
692
693
|
return;
|
|
693
|
-
}
|
|
694
694
|
if (isStreamClose(msg.controlFlags)) {
|
|
695
695
|
cleanup();
|
|
696
696
|
} else {
|
|
@@ -774,13 +774,12 @@ function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
|
774
774
|
transport.removeEventListener("sessionStatus", onSessionStatus);
|
|
775
775
|
}
|
|
776
776
|
function onMessage(msg) {
|
|
777
|
-
if (msg.
|
|
777
|
+
if (msg.streamId !== streamId)
|
|
778
778
|
return;
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}
|
|
779
|
+
if (msg.to !== transport.clientId)
|
|
780
|
+
return;
|
|
781
|
+
cleanup();
|
|
782
|
+
resolve(msg.payload);
|
|
784
783
|
}
|
|
785
784
|
transport.addEventListener("message", onMessage);
|
|
786
785
|
transport.addEventListener("sessionStatus", onSessionStatus);
|
|
@@ -788,16 +787,13 @@ function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
|
788
787
|
return [inputStream, responsePromise];
|
|
789
788
|
}
|
|
790
789
|
|
|
791
|
-
// logging/index.ts
|
|
792
|
-
var log;
|
|
793
|
-
|
|
794
790
|
// router/server.ts
|
|
795
791
|
var import_value = require("@sinclair/typebox/value");
|
|
796
792
|
|
|
797
793
|
// util/stringify.ts
|
|
798
794
|
function coerceErrorString(err) {
|
|
799
795
|
if (err instanceof Error) {
|
|
800
|
-
return err.message;
|
|
796
|
+
return err.message || "unknown reason";
|
|
801
797
|
}
|
|
802
798
|
return `[coerced to error] ${String(err)}`;
|
|
803
799
|
}
|
|
@@ -848,17 +844,15 @@ var RiverServer = class {
|
|
|
848
844
|
};
|
|
849
845
|
// cleanup streams on session close
|
|
850
846
|
onSessionStatus = async (evt) => {
|
|
851
|
-
if (evt.status !== "disconnect")
|
|
847
|
+
if (evt.status !== "disconnect")
|
|
852
848
|
return;
|
|
853
|
-
}
|
|
854
849
|
const disconnectedClientId = evt.session.to;
|
|
855
850
|
log?.info(
|
|
856
851
|
`${this.transport.clientId} -- got session disconnect from ${disconnectedClientId}, cleaning up streams`
|
|
857
852
|
);
|
|
858
853
|
const streamsFromThisClient = this.clientStreams.get(disconnectedClientId);
|
|
859
|
-
if (!streamsFromThisClient)
|
|
854
|
+
if (!streamsFromThisClient)
|
|
860
855
|
return;
|
|
861
|
-
}
|
|
862
856
|
this.disconnectedSessions.add(disconnectedClientId);
|
|
863
857
|
await Promise.all(
|
|
864
858
|
Array.from(streamsFromThisClient).map(this.cleanupStream)
|
|
@@ -908,21 +902,36 @@ var RiverServer = class {
|
|
|
908
902
|
const procedure = service.procedures[message.procedureName];
|
|
909
903
|
const incoming = pushable({ objectMode: true });
|
|
910
904
|
const outgoing = pushable({ objectMode: true });
|
|
905
|
+
const needsClose = procedure.type === "subscription" || procedure.type === "stream";
|
|
911
906
|
const outputHandler = (
|
|
912
907
|
// sending outgoing messages back to client
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
this.
|
|
924
|
-
|
|
925
|
-
|
|
908
|
+
needsClose ? (
|
|
909
|
+
// subscription and stream case, we need to send a close bit after the response stream
|
|
910
|
+
(async () => {
|
|
911
|
+
for await (const response of outgoing) {
|
|
912
|
+
this.transport.send(session.to, {
|
|
913
|
+
streamId: message.streamId,
|
|
914
|
+
controlFlags: 0,
|
|
915
|
+
payload: response
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (!this.disconnectedSessions.has(message.from)) {
|
|
919
|
+
this.transport.sendCloseStream(session.to, message.streamId);
|
|
920
|
+
}
|
|
921
|
+
})()
|
|
922
|
+
) : (
|
|
923
|
+
// rpc and upload case, we just send the response back with close bit
|
|
924
|
+
(async () => {
|
|
925
|
+
const response = await outgoing.next().then((res) => res.value);
|
|
926
|
+
if (response) {
|
|
927
|
+
this.transport.send(session.to, {
|
|
928
|
+
streamId: message.streamId,
|
|
929
|
+
controlFlags: 4 /* StreamClosedBit */,
|
|
930
|
+
payload: response
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
})()
|
|
934
|
+
)
|
|
926
935
|
);
|
|
927
936
|
const errorHandler = (err) => {
|
|
928
937
|
const errorMsg = coerceErrorString(err);
|
package/dist/router/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-
|
|
2
|
-
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-
|
|
3
|
-
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-
|
|
1
|
+
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-eef3b061.js';
|
|
2
|
+
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-eef3b061.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-9aa0aabb.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-
|
|
2
|
-
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-
|
|
3
|
-
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-
|
|
1
|
+
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-eef3b061.js';
|
|
2
|
+
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-eef3b061.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-9aa0aabb.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
package/dist/router/index.js
CHANGED
|
@@ -67,7 +67,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
|
67
67
|
}),
|
|
68
68
|
import_typebox.Type.Object({
|
|
69
69
|
ok: import_typebox.Type.Literal(false),
|
|
70
|
-
reason: import_typebox.Type.
|
|
70
|
+
reason: import_typebox.Type.String()
|
|
71
71
|
})
|
|
72
72
|
])
|
|
73
73
|
});
|
|
@@ -492,7 +492,7 @@ var import_nanoid3 = require("nanoid");
|
|
|
492
492
|
// util/stringify.ts
|
|
493
493
|
function coerceErrorString(err) {
|
|
494
494
|
if (err instanceof Error) {
|
|
495
|
-
return err.message;
|
|
495
|
+
return err.message || "unknown reason";
|
|
496
496
|
}
|
|
497
497
|
return `[coerced to error] ${String(err)}`;
|
|
498
498
|
}
|
|
@@ -866,6 +866,9 @@ var ClientTransport = class extends Transport {
|
|
|
866
866
|
} catch (error) {
|
|
867
867
|
const errStr = coerceErrorString(error);
|
|
868
868
|
this.inflightConnectionPromises.delete(to);
|
|
869
|
+
const shouldRetry = this.state === "open" && this.tryReconnecting;
|
|
870
|
+
if (!shouldRetry)
|
|
871
|
+
return;
|
|
869
872
|
if (attempt >= this.options.retryAttemptsMax) {
|
|
870
873
|
const errMsg = `connection to ${to} failed after ${attempt} attempts (${errStr}), giving up`;
|
|
871
874
|
log?.error(`${this.clientId} -- ${errMsg}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-03e650c8.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-03e650c8.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-23MWJLVJ.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NLWRMDT6.js";
|
|
7
|
+
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
10
|
} from "../../../chunk-H4BYJELI.js";
|
|
@@ -66,7 +66,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
|
66
66
|
}),
|
|
67
67
|
import_typebox.Type.Object({
|
|
68
68
|
ok: import_typebox.Type.Literal(false),
|
|
69
|
-
reason: import_typebox.Type.
|
|
69
|
+
reason: import_typebox.Type.String()
|
|
70
70
|
})
|
|
71
71
|
])
|
|
72
72
|
});
|
|
@@ -79,7 +79,7 @@ var ControlMessagePayloadSchema = import_typebox.Type.Union([
|
|
|
79
79
|
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
80
80
|
import_typebox.Type.Unknown()
|
|
81
81
|
);
|
|
82
|
-
function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
82
|
+
function handshakeResponseMessage(from, instanceId, to, ok, reason) {
|
|
83
83
|
return {
|
|
84
84
|
id: (0, import_nanoid.nanoid)(),
|
|
85
85
|
from,
|
|
@@ -98,7 +98,7 @@ function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
|
98
98
|
type: "HANDSHAKE_RESP",
|
|
99
99
|
status: {
|
|
100
100
|
ok: false,
|
|
101
|
-
reason: "
|
|
101
|
+
reason: reason ?? "Unknown reason"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -406,7 +406,7 @@ var import_nanoid3 = require("nanoid");
|
|
|
406
406
|
// util/stringify.ts
|
|
407
407
|
function coerceErrorString(err) {
|
|
408
408
|
if (err instanceof Error) {
|
|
409
|
-
return err.message;
|
|
409
|
+
return err.message || "unknown reason";
|
|
410
410
|
}
|
|
411
411
|
return `[coerced to error] ${String(err)}`;
|
|
412
412
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-03e650c8.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-03e650c8.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-23MWJLVJ.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NLWRMDT6.js";
|
|
7
|
+
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
10
|
} from "../../../chunk-H4BYJELI.js";
|
|
@@ -63,7 +63,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
|
63
63
|
}),
|
|
64
64
|
import_typebox.Type.Object({
|
|
65
65
|
ok: import_typebox.Type.Literal(false),
|
|
66
|
-
reason: import_typebox.Type.
|
|
66
|
+
reason: import_typebox.Type.String()
|
|
67
67
|
})
|
|
68
68
|
])
|
|
69
69
|
});
|
|
@@ -398,7 +398,7 @@ var import_nanoid3 = require("nanoid");
|
|
|
398
398
|
// util/stringify.ts
|
|
399
399
|
function coerceErrorString(err) {
|
|
400
400
|
if (err instanceof Error) {
|
|
401
|
-
return err.message;
|
|
401
|
+
return err.message || "unknown reason";
|
|
402
402
|
}
|
|
403
403
|
return `[coerced to error] ${String(err)}`;
|
|
404
404
|
}
|
|
@@ -772,6 +772,9 @@ var ClientTransport = class extends Transport {
|
|
|
772
772
|
} catch (error) {
|
|
773
773
|
const errStr = coerceErrorString(error);
|
|
774
774
|
this.inflightConnectionPromises.delete(to);
|
|
775
|
+
const shouldRetry = this.state === "open" && this.tryReconnecting;
|
|
776
|
+
if (!shouldRetry)
|
|
777
|
+
return;
|
|
775
778
|
if (attempt >= this.options.retryAttemptsMax) {
|
|
776
779
|
const errMsg = `connection to ${to} failed after ${attempt} attempts (${errStr}), giving up`;
|
|
777
780
|
log?.error(`${this.clientId} -- ${errMsg}`);
|
|
@@ -873,25 +876,18 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
873
876
|
resolve({ err: "ws is closing or closed" });
|
|
874
877
|
return;
|
|
875
878
|
}
|
|
876
|
-
|
|
877
|
-
ws.removeEventListener("open", onOpen);
|
|
879
|
+
ws.onopen = () => {
|
|
878
880
|
resolve({ ws });
|
|
879
881
|
};
|
|
880
|
-
|
|
881
|
-
ws.removeEventListener("close", onClose);
|
|
882
|
+
ws.onclose = (evt) => {
|
|
882
883
|
resolve({ err: evt.reason });
|
|
883
884
|
};
|
|
884
|
-
|
|
885
|
+
ws.onerror = (evt) => {
|
|
885
886
|
const err = evt.error;
|
|
886
|
-
ws.removeEventListener("error", onError);
|
|
887
|
-
ws.removeEventListener("close", onClose);
|
|
888
887
|
resolve({
|
|
889
888
|
err: err?.code ?? "unexpected disconnect"
|
|
890
889
|
});
|
|
891
890
|
};
|
|
892
|
-
ws.addEventListener("open", onOpen);
|
|
893
|
-
ws.addEventListener("close", onClose);
|
|
894
|
-
ws.addEventListener("error", onError);
|
|
895
891
|
}).catch((e) => {
|
|
896
892
|
const reason = e instanceof Error ? e.message : "unknown reason";
|
|
897
893
|
resolve({ err: `couldn't get a new websocket: ${reason}` });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-d052d027.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-d052d027.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-3Y2K543F.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NLWRMDT6.js";
|
|
7
|
+
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
10
|
} from "../../../chunk-H4BYJELI.js";
|
|
@@ -49,25 +49,18 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
49
49
|
resolve({ err: "ws is closing or closed" });
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
ws.removeEventListener("open", onOpen);
|
|
52
|
+
ws.onopen = () => {
|
|
54
53
|
resolve({ ws });
|
|
55
54
|
};
|
|
56
|
-
|
|
57
|
-
ws.removeEventListener("close", onClose);
|
|
55
|
+
ws.onclose = (evt) => {
|
|
58
56
|
resolve({ err: evt.reason });
|
|
59
57
|
};
|
|
60
|
-
|
|
58
|
+
ws.onerror = (evt) => {
|
|
61
59
|
const err = evt.error;
|
|
62
|
-
ws.removeEventListener("error", onError);
|
|
63
|
-
ws.removeEventListener("close", onClose);
|
|
64
60
|
resolve({
|
|
65
61
|
err: err?.code ?? "unexpected disconnect"
|
|
66
62
|
});
|
|
67
63
|
};
|
|
68
|
-
ws.addEventListener("open", onOpen);
|
|
69
|
-
ws.addEventListener("close", onClose);
|
|
70
|
-
ws.addEventListener("error", onError);
|
|
71
64
|
}).catch((e) => {
|
|
72
65
|
const reason = e instanceof Error ? e.message : "unknown reason";
|
|
73
66
|
resolve({ err: `couldn't get a new websocket: ${reason}` });
|
|
@@ -66,7 +66,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
|
66
66
|
}),
|
|
67
67
|
import_typebox.Type.Object({
|
|
68
68
|
ok: import_typebox.Type.Literal(false),
|
|
69
|
-
reason: import_typebox.Type.
|
|
69
|
+
reason: import_typebox.Type.String()
|
|
70
70
|
})
|
|
71
71
|
])
|
|
72
72
|
});
|
|
@@ -79,7 +79,7 @@ var ControlMessagePayloadSchema = import_typebox.Type.Union([
|
|
|
79
79
|
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
80
80
|
import_typebox.Type.Unknown()
|
|
81
81
|
);
|
|
82
|
-
function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
82
|
+
function handshakeResponseMessage(from, instanceId, to, ok, reason) {
|
|
83
83
|
return {
|
|
84
84
|
id: (0, import_nanoid.nanoid)(),
|
|
85
85
|
from,
|
|
@@ -98,7 +98,7 @@ function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
|
98
98
|
type: "HANDSHAKE_RESP",
|
|
99
99
|
status: {
|
|
100
100
|
ok: false,
|
|
101
|
-
reason: "
|
|
101
|
+
reason: reason ?? "Unknown reason"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -406,7 +406,7 @@ var import_nanoid3 = require("nanoid");
|
|
|
406
406
|
// util/stringify.ts
|
|
407
407
|
function coerceErrorString(err) {
|
|
408
408
|
if (err instanceof Error) {
|
|
409
|
-
return err.message;
|
|
409
|
+
return err.message || "unknown reason";
|
|
410
410
|
}
|
|
411
411
|
return `[coerced to error] ${String(err)}`;
|
|
412
412
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
1
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-d052d027.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
1
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-9aa0aabb.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-d052d027.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-3Y2K543F.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NLWRMDT6.js";
|
|
7
|
+
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
10
|
} from "../../../chunk-H4BYJELI.js";
|
package/dist/transport/index.cjs
CHANGED
|
@@ -69,7 +69,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
|
69
69
|
}),
|
|
70
70
|
import_typebox.Type.Object({
|
|
71
71
|
ok: import_typebox.Type.Literal(false),
|
|
72
|
-
reason: import_typebox.Type.
|
|
72
|
+
reason: import_typebox.Type.String()
|
|
73
73
|
})
|
|
74
74
|
])
|
|
75
75
|
});
|
|
@@ -98,7 +98,7 @@ function handshakeRequestMessage(from, to, instanceId) {
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
101
|
+
function handshakeResponseMessage(from, instanceId, to, ok, reason) {
|
|
102
102
|
return {
|
|
103
103
|
id: (0, import_nanoid.nanoid)(),
|
|
104
104
|
from,
|
|
@@ -117,7 +117,7 @@ function handshakeResponseMessage(from, instanceId, to, ok) {
|
|
|
117
117
|
type: "HANDSHAKE_RESP",
|
|
118
118
|
status: {
|
|
119
119
|
ok: false,
|
|
120
|
-
reason: "
|
|
120
|
+
reason: reason ?? "Unknown reason"
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
};
|
|
@@ -428,7 +428,7 @@ var import_nanoid3 = require("nanoid");
|
|
|
428
428
|
// util/stringify.ts
|
|
429
429
|
function coerceErrorString(err) {
|
|
430
430
|
if (err instanceof Error) {
|
|
431
|
-
return err.message;
|
|
431
|
+
return err.message || "unknown reason";
|
|
432
432
|
}
|
|
433
433
|
return `[coerced to error] ${String(err)}`;
|
|
434
434
|
}
|
|
@@ -802,6 +802,9 @@ var ClientTransport = class extends Transport {
|
|
|
802
802
|
} catch (error) {
|
|
803
803
|
const errStr = coerceErrorString(error);
|
|
804
804
|
this.inflightConnectionPromises.delete(to);
|
|
805
|
+
const shouldRetry = this.state === "open" && this.tryReconnecting;
|
|
806
|
+
if (!shouldRetry)
|
|
807
|
+
return;
|
|
805
808
|
if (attempt >= this.options.retryAttemptsMax) {
|
|
806
809
|
const errMsg = `connection to ${to} failed after ${attempt} attempts (${errStr}), giving up`;
|
|
807
810
|
log?.error(`${this.clientId} -- ${errMsg}`);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-
|
|
1
|
+
export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-9aa0aabb.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-
|
|
1
|
+
export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-9aa0aabb.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
package/dist/transport/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
ServerTransport,
|
|
6
6
|
Session,
|
|
7
7
|
Transport
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-NLWRMDT6.js";
|
|
9
9
|
import {
|
|
10
10
|
OpaqueTransportMessageSchema,
|
|
11
11
|
TransportMessageSchema
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-GFRAOY75.js";
|
|
13
13
|
import "../chunk-H4BYJELI.js";
|
|
14
14
|
import "../chunk-GZ7HCLLM.js";
|
|
15
15
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-
|
|
5
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-
|
|
4
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-9aa0aabb.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-eef3b061.js';
|
|
6
6
|
import { Static } from '@sinclair/typebox';
|
|
7
7
|
import net from 'node:net';
|
|
8
8
|
import '../types-3e5768ec.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-
|
|
5
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-
|
|
4
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-9aa0aabb.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-eef3b061.js';
|
|
6
6
|
import { Static } from '@sinclair/typebox';
|
|
7
7
|
import net from 'node:net';
|
|
8
8
|
import '../types-3e5768ec.js';
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-67M47YPQ.js";
|
|
5
5
|
import "../chunk-5IZ2UHWV.js";
|
|
6
6
|
import {
|
|
7
7
|
Session,
|
|
8
8
|
defaultSessionOptions
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-NLWRMDT6.js";
|
|
10
10
|
import {
|
|
11
11
|
coerceErrorString
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-GFRAOY75.js";
|
|
13
13
|
import "../chunk-H4BYJELI.js";
|
|
14
14
|
import "../chunk-GZ7HCLLM.js";
|
|
15
15
|
|
package/package.json
CHANGED