@replit/river 0.25.1 → 0.25.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/dist/{chunk-SZ5NBBX7.js → chunk-EHD2JJBW.js} +2 -2
- package/dist/{chunk-SZ5NBBX7.js.map → chunk-EHD2JJBW.js.map} +1 -1
- package/dist/{chunk-SGSRNAWJ.js → chunk-GDHQCPWW.js} +2 -2
- package/dist/{chunk-5CNNIOAO.js → chunk-ONIPHO7J.js} +102 -95
- package/dist/chunk-ONIPHO7J.js.map +1 -0
- package/dist/{chunk-D5O3ERJU.js → chunk-PF74DCPQ.js} +3 -3
- package/dist/chunk-PF74DCPQ.js.map +1 -0
- package/dist/{chunk-YM5Y4NAT.js → chunk-Q3PZBJXR.js} +199 -117
- package/dist/chunk-Q3PZBJXR.js.map +1 -0
- package/dist/{chunk-PCBPPTXH.js → chunk-QXMZJ7LF.js} +17 -26
- package/dist/chunk-QXMZJ7LF.js.map +1 -0
- package/dist/{chunk-MBMEJIPU.js → chunk-ZWMWRM23.js} +2 -2
- package/dist/{client-1321630c.d.ts → client-edc8e2de.d.ts} +3 -1
- package/dist/{connection-bd907ca6.d.ts → connection-ef50ac3a.d.ts} +1 -1
- package/dist/{handshake-3772d7ca.d.ts → handshake-12d57161.d.ts} +131 -83
- package/dist/router/index.cjs +1 -1
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +7 -7
- package/dist/router/index.d.ts +7 -7
- package/dist/router/index.js +2 -2
- package/dist/{server-f0fd2b98.d.ts → server-f8228636.d.ts} +8 -3
- package/dist/{services-8d14ae16.d.ts → services-4b9e5232.d.ts} +2 -2
- package/dist/transport/impls/ws/client.cjs +291 -205
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +3 -3
- package/dist/transport/impls/ws/client.d.ts +3 -3
- package/dist/transport/impls/ws/client.js +5 -5
- package/dist/transport/impls/ws/server.cjs +206 -136
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +3 -3
- package/dist/transport/impls/ws/server.d.ts +3 -3
- package/dist/transport/impls/ws/server.js +5 -5
- package/dist/transport/index.cjs +304 -226
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +3 -3
- package/dist/transport/index.d.ts +3 -3
- package/dist/transport/index.js +5 -5
- package/dist/util/testHelpers.cjs +197 -115
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +5 -4
- package/dist/util/testHelpers.d.ts +5 -4
- package/dist/util/testHelpers.js +6 -3
- package/dist/util/testHelpers.js.map +1 -1
- package/package.json +14 -13
- package/dist/chunk-5CNNIOAO.js.map +0 -1
- package/dist/chunk-D5O3ERJU.js.map +0 -1
- package/dist/chunk-PCBPPTXH.js.map +0 -1
- package/dist/chunk-YM5Y4NAT.js.map +0 -1
- /package/dist/{chunk-SGSRNAWJ.js.map → chunk-GDHQCPWW.js.map} +0 -0
- /package/dist/{chunk-MBMEJIPU.js.map → chunk-ZWMWRM23.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createSessionTelemetryInfo,
|
|
4
4
|
generateId,
|
|
5
5
|
isAck
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EHD2JJBW.js";
|
|
7
7
|
import {
|
|
8
8
|
NaiveJsonCodec
|
|
9
9
|
} from "./chunk-4PVU7J25.js";
|
|
@@ -18,7 +18,7 @@ var defaultTransportOptions = {
|
|
|
18
18
|
codec: NaiveJsonCodec
|
|
19
19
|
};
|
|
20
20
|
var defaultConnectionRetryOptions = {
|
|
21
|
-
baseIntervalMs:
|
|
21
|
+
baseIntervalMs: 150,
|
|
22
22
|
maxJitterMs: 200,
|
|
23
23
|
maxBackoffMs: 32e3,
|
|
24
24
|
attemptBudgetCapacity: 5,
|
|
@@ -36,6 +36,7 @@ var defaultServerTransportOptions = {
|
|
|
36
36
|
import { Value } from "@sinclair/typebox/value";
|
|
37
37
|
var SessionState = /* @__PURE__ */ ((SessionState2) => {
|
|
38
38
|
SessionState2["NoConnection"] = "NoConnection";
|
|
39
|
+
SessionState2["BackingOff"] = "BackingOff";
|
|
39
40
|
SessionState2["Connecting"] = "Connecting";
|
|
40
41
|
SessionState2["Handshaking"] = "Handshaking";
|
|
41
42
|
SessionState2["Connected"] = "Connected";
|
|
@@ -93,7 +94,7 @@ var CommonSession = class extends StateMachineState {
|
|
|
93
94
|
from;
|
|
94
95
|
options;
|
|
95
96
|
log;
|
|
96
|
-
constructor(from, options, log) {
|
|
97
|
+
constructor({ from, options, log }) {
|
|
97
98
|
super();
|
|
98
99
|
this.from = from;
|
|
99
100
|
this.options = options;
|
|
@@ -134,8 +135,9 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
134
135
|
*/
|
|
135
136
|
ack;
|
|
136
137
|
sendBuffer;
|
|
137
|
-
constructor(
|
|
138
|
-
|
|
138
|
+
constructor(props) {
|
|
139
|
+
const { id, to, seq, ack, sendBuffer, telemetry, log } = props;
|
|
140
|
+
super(props);
|
|
139
141
|
this.id = id;
|
|
140
142
|
this.to = to;
|
|
141
143
|
this.seq = seq;
|
|
@@ -190,23 +192,23 @@ var SessionConnecting = class extends IdentifiedSession {
|
|
|
190
192
|
connPromise;
|
|
191
193
|
listeners;
|
|
192
194
|
connectionTimeout;
|
|
193
|
-
constructor(
|
|
194
|
-
super(
|
|
195
|
-
this.connPromise = connPromise;
|
|
196
|
-
this.listeners = listeners;
|
|
195
|
+
constructor(props) {
|
|
196
|
+
super(props);
|
|
197
|
+
this.connPromise = props.connPromise;
|
|
198
|
+
this.listeners = props.listeners;
|
|
197
199
|
this.connectionTimeout = setTimeout(() => {
|
|
198
|
-
listeners.onConnectionTimeout();
|
|
200
|
+
this.listeners.onConnectionTimeout();
|
|
199
201
|
}, this.options.connectionTimeoutMs);
|
|
200
|
-
connPromise.then(
|
|
202
|
+
this.connPromise.then(
|
|
201
203
|
(conn) => {
|
|
202
204
|
if (this._isConsumed)
|
|
203
205
|
return;
|
|
204
|
-
listeners.onConnectionEstablished(conn);
|
|
206
|
+
this.listeners.onConnectionEstablished(conn);
|
|
205
207
|
},
|
|
206
208
|
(err) => {
|
|
207
209
|
if (this._isConsumed)
|
|
208
210
|
return;
|
|
209
|
-
listeners.onConnectionFailed(err);
|
|
211
|
+
this.listeners.onConnectionFailed(err);
|
|
210
212
|
}
|
|
211
213
|
);
|
|
212
214
|
}
|
|
@@ -232,9 +234,9 @@ var SessionNoConnection = class extends IdentifiedSession {
|
|
|
232
234
|
state = "NoConnection" /* NoConnection */;
|
|
233
235
|
listeners;
|
|
234
236
|
gracePeriodTimeout;
|
|
235
|
-
constructor(
|
|
236
|
-
super(
|
|
237
|
-
this.listeners = listeners;
|
|
237
|
+
constructor(props) {
|
|
238
|
+
super(props);
|
|
239
|
+
this.listeners = props.listeners;
|
|
238
240
|
this.gracePeriodTimeout = setTimeout(() => {
|
|
239
241
|
this.listeners.onSessionGracePeriodElapsed();
|
|
240
242
|
}, this.options.sessionDisconnectGraceMs);
|
|
@@ -257,16 +259,16 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
257
259
|
conn;
|
|
258
260
|
listeners;
|
|
259
261
|
handshakeTimeout;
|
|
260
|
-
constructor(
|
|
261
|
-
super(
|
|
262
|
-
this.conn = conn;
|
|
263
|
-
this.listeners = listeners;
|
|
262
|
+
constructor(props) {
|
|
263
|
+
super(props);
|
|
264
|
+
this.conn = props.conn;
|
|
265
|
+
this.listeners = props.listeners;
|
|
264
266
|
this.handshakeTimeout = setTimeout(() => {
|
|
265
|
-
listeners.onHandshakeTimeout();
|
|
267
|
+
this.listeners.onHandshakeTimeout();
|
|
266
268
|
}, this.options.handshakeTimeoutMs);
|
|
267
269
|
this.conn.addDataListener(this.onHandshakeData);
|
|
268
|
-
this.conn.addErrorListener(listeners.onConnectionErrored);
|
|
269
|
-
this.conn.addCloseListener(listeners.onConnectionClosed);
|
|
270
|
+
this.conn.addErrorListener(this.listeners.onConnectionErrored);
|
|
271
|
+
this.conn.addCloseListener(this.listeners.onConnectionClosed);
|
|
270
272
|
}
|
|
271
273
|
onHandshakeData = (msg) => {
|
|
272
274
|
const parsedMsg = this.parseMsg(msg);
|
|
@@ -303,16 +305,16 @@ var SessionHandshaking = class extends IdentifiedSession {
|
|
|
303
305
|
conn;
|
|
304
306
|
listeners;
|
|
305
307
|
handshakeTimeout;
|
|
306
|
-
constructor(
|
|
307
|
-
super(
|
|
308
|
-
this.conn = conn;
|
|
309
|
-
this.listeners = listeners;
|
|
308
|
+
constructor(props) {
|
|
309
|
+
super(props);
|
|
310
|
+
this.conn = props.conn;
|
|
311
|
+
this.listeners = props.listeners;
|
|
310
312
|
this.handshakeTimeout = setTimeout(() => {
|
|
311
|
-
listeners.onHandshakeTimeout();
|
|
313
|
+
this.listeners.onHandshakeTimeout();
|
|
312
314
|
}, this.options.handshakeTimeoutMs);
|
|
313
315
|
this.conn.addDataListener(this.onHandshakeData);
|
|
314
|
-
this.conn.addErrorListener(listeners.onConnectionErrored);
|
|
315
|
-
this.conn.addCloseListener(listeners.onConnectionClosed);
|
|
316
|
+
this.conn.addErrorListener(this.listeners.onConnectionErrored);
|
|
317
|
+
this.conn.addCloseListener(this.listeners.onConnectionClosed);
|
|
316
318
|
}
|
|
317
319
|
onHandshakeData = (msg) => {
|
|
318
320
|
const parsedMsg = this.parseMsg(msg);
|
|
@@ -344,16 +346,13 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
344
346
|
state = "Connected" /* Connected */;
|
|
345
347
|
conn;
|
|
346
348
|
listeners;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
get isActivelyHeartbeating() {
|
|
351
|
-
return this.activeHeartbeatHandle !== void 0;
|
|
352
|
-
}
|
|
349
|
+
heartbeatHandle;
|
|
350
|
+
heartbeatMisses = 0;
|
|
351
|
+
isActivelyHeartbeating;
|
|
353
352
|
updateBookkeeping(ack, seq) {
|
|
354
353
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
355
354
|
this.ack = seq + 1;
|
|
356
|
-
this.
|
|
355
|
+
this.heartbeatMisses = 0;
|
|
357
356
|
}
|
|
358
357
|
send(msg) {
|
|
359
358
|
const constructedMsg = this.constructMsg(msg);
|
|
@@ -361,13 +360,13 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
361
360
|
this.conn.send(this.options.codec.toBuffer(constructedMsg));
|
|
362
361
|
return constructedMsg.id;
|
|
363
362
|
}
|
|
364
|
-
constructor(
|
|
365
|
-
super(
|
|
366
|
-
this.conn = conn;
|
|
367
|
-
this.listeners = listeners;
|
|
363
|
+
constructor(props) {
|
|
364
|
+
super(props);
|
|
365
|
+
this.conn = props.conn;
|
|
366
|
+
this.listeners = props.listeners;
|
|
368
367
|
this.conn.addDataListener(this.onMessageData);
|
|
369
|
-
this.conn.addCloseListener(listeners.onConnectionClosed);
|
|
370
|
-
this.conn.addErrorListener(listeners.onConnectionErrored);
|
|
368
|
+
this.conn.addCloseListener(this.listeners.onConnectionClosed);
|
|
369
|
+
this.conn.addErrorListener(this.listeners.onConnectionErrored);
|
|
371
370
|
if (this.sendBuffer.length > 0) {
|
|
372
371
|
this.log?.debug(
|
|
373
372
|
`sending ${this.sendBuffer.length} buffered messages`,
|
|
@@ -375,12 +374,11 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
375
374
|
);
|
|
376
375
|
}
|
|
377
376
|
for (const msg of this.sendBuffer) {
|
|
378
|
-
conn.send(this.options.codec.toBuffer(msg));
|
|
377
|
+
this.conn.send(this.options.codec.toBuffer(msg));
|
|
379
378
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const misses = this.activeHeartbeatMisses;
|
|
379
|
+
this.isActivelyHeartbeating = false;
|
|
380
|
+
this.heartbeatHandle = setInterval(() => {
|
|
381
|
+
const misses = this.heartbeatMisses;
|
|
384
382
|
const missDuration = misses * this.options.heartbeatIntervalMs;
|
|
385
383
|
if (misses >= this.options.heartbeatsUntilDead) {
|
|
386
384
|
this.log?.info(
|
|
@@ -389,29 +387,18 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
389
387
|
);
|
|
390
388
|
this.telemetry.span.addEvent("closing connection due to inactivity");
|
|
391
389
|
this.conn.close();
|
|
392
|
-
clearInterval(this.
|
|
393
|
-
this.
|
|
390
|
+
clearInterval(this.heartbeatHandle);
|
|
391
|
+
this.heartbeatHandle = void 0;
|
|
394
392
|
return;
|
|
395
393
|
}
|
|
396
|
-
this.
|
|
397
|
-
|
|
394
|
+
if (this.isActivelyHeartbeating) {
|
|
395
|
+
this.sendHeartbeat();
|
|
396
|
+
}
|
|
397
|
+
this.heartbeatMisses++;
|
|
398
398
|
}, this.options.heartbeatIntervalMs);
|
|
399
399
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (this.passiveHeartbeatHandle) {
|
|
403
|
-
clearTimeout(this.passiveHeartbeatHandle);
|
|
404
|
-
this.passiveHeartbeatHandle = void 0;
|
|
405
|
-
}
|
|
406
|
-
this.passiveHeartbeatHandle = setTimeout(() => {
|
|
407
|
-
this.log?.info(
|
|
408
|
-
`closing connection to ${this.to} due to not receiving a heartbeat in the last ${duration}ms`,
|
|
409
|
-
this.loggingMetadata
|
|
410
|
-
);
|
|
411
|
-
this.telemetry.span.addEvent("closing connection due to inactivity");
|
|
412
|
-
this.conn.close();
|
|
413
|
-
this.passiveHeartbeatHandle = void 0;
|
|
414
|
-
}, duration);
|
|
400
|
+
startActiveHeartbeat() {
|
|
401
|
+
this.isActivelyHeartbeating = true;
|
|
415
402
|
}
|
|
416
403
|
sendHeartbeat() {
|
|
417
404
|
this.log?.debug("sending heartbeat", this.loggingMetadata);
|
|
@@ -466,7 +453,6 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
466
453
|
});
|
|
467
454
|
if (!this.isActivelyHeartbeating) {
|
|
468
455
|
this.sendHeartbeat();
|
|
469
|
-
this.waitForNextHeartbeat();
|
|
470
456
|
}
|
|
471
457
|
};
|
|
472
458
|
_handleStateExit() {
|
|
@@ -474,10 +460,8 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
474
460
|
this.conn.removeDataListener(this.onMessageData);
|
|
475
461
|
this.conn.removeCloseListener(this.listeners.onConnectionClosed);
|
|
476
462
|
this.conn.removeErrorListener(this.listeners.onConnectionErrored);
|
|
477
|
-
clearInterval(this.
|
|
478
|
-
|
|
479
|
-
this.activeHeartbeatHandle = void 0;
|
|
480
|
-
this.passiveHeartbeatHandle = void 0;
|
|
463
|
+
clearInterval(this.heartbeatHandle);
|
|
464
|
+
this.heartbeatHandle = void 0;
|
|
481
465
|
}
|
|
482
466
|
_handleClose() {
|
|
483
467
|
super._handleClose();
|
|
@@ -485,52 +469,76 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
485
469
|
}
|
|
486
470
|
};
|
|
487
471
|
|
|
472
|
+
// transport/sessionStateMachine/SessionBackingOff.ts
|
|
473
|
+
var SessionBackingOff = class extends IdentifiedSession {
|
|
474
|
+
state = "BackingOff" /* BackingOff */;
|
|
475
|
+
listeners;
|
|
476
|
+
backoffTimeout;
|
|
477
|
+
constructor(props) {
|
|
478
|
+
super(props);
|
|
479
|
+
this.listeners = props.listeners;
|
|
480
|
+
this.backoffTimeout = setTimeout(() => {
|
|
481
|
+
this.listeners.onBackoffFinished();
|
|
482
|
+
}, props.backoffMs);
|
|
483
|
+
}
|
|
484
|
+
_handleClose() {
|
|
485
|
+
super._handleClose();
|
|
486
|
+
}
|
|
487
|
+
_handleStateExit() {
|
|
488
|
+
super._handleStateExit();
|
|
489
|
+
if (this.backoffTimeout) {
|
|
490
|
+
clearTimeout(this.backoffTimeout);
|
|
491
|
+
this.backoffTimeout = void 0;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
|
|
488
496
|
// transport/sessionStateMachine/transitions.ts
|
|
489
497
|
function inheritSharedSession(session) {
|
|
490
|
-
return
|
|
491
|
-
session.id,
|
|
492
|
-
session.from,
|
|
493
|
-
session.to,
|
|
494
|
-
session.seq,
|
|
495
|
-
session.ack,
|
|
496
|
-
session.sendBuffer,
|
|
497
|
-
session.telemetry,
|
|
498
|
-
session.options,
|
|
499
|
-
session.log
|
|
500
|
-
|
|
498
|
+
return {
|
|
499
|
+
id: session.id,
|
|
500
|
+
from: session.from,
|
|
501
|
+
to: session.to,
|
|
502
|
+
seq: session.seq,
|
|
503
|
+
ack: session.ack,
|
|
504
|
+
sendBuffer: session.sendBuffer,
|
|
505
|
+
telemetry: session.telemetry,
|
|
506
|
+
options: session.options,
|
|
507
|
+
log: session.log
|
|
508
|
+
};
|
|
501
509
|
}
|
|
502
510
|
var SessionStateGraph = {
|
|
503
511
|
entrypoints: {
|
|
504
|
-
NoConnection(to, from, listeners, options, log) {
|
|
512
|
+
NoConnection: (to, from, listeners, options, log) => {
|
|
505
513
|
const id = `session-${generateId()}`;
|
|
506
514
|
const telemetry = createSessionTelemetryInfo(id, to, from);
|
|
507
515
|
const sendBuffer = [];
|
|
508
|
-
const session = new SessionNoConnection(
|
|
516
|
+
const session = new SessionNoConnection({
|
|
509
517
|
listeners,
|
|
510
518
|
id,
|
|
511
519
|
from,
|
|
512
520
|
to,
|
|
513
|
-
0,
|
|
514
|
-
0,
|
|
521
|
+
seq: 0,
|
|
522
|
+
ack: 0,
|
|
515
523
|
sendBuffer,
|
|
516
524
|
telemetry,
|
|
517
525
|
options,
|
|
518
526
|
log
|
|
519
|
-
);
|
|
527
|
+
});
|
|
520
528
|
session.log?.info(`session ${session.id} created in NoConnection state`, {
|
|
521
529
|
...session.loggingMetadata,
|
|
522
530
|
tags: ["state-transition"]
|
|
523
531
|
});
|
|
524
532
|
return session;
|
|
525
533
|
},
|
|
526
|
-
WaitingForHandshake(from, conn, listeners, options, log) {
|
|
527
|
-
const session = new SessionWaitingForHandshake(
|
|
534
|
+
WaitingForHandshake: (from, conn, listeners, options, log) => {
|
|
535
|
+
const session = new SessionWaitingForHandshake({
|
|
528
536
|
conn,
|
|
529
537
|
listeners,
|
|
530
538
|
from,
|
|
531
539
|
options,
|
|
532
540
|
log
|
|
533
|
-
);
|
|
541
|
+
});
|
|
534
542
|
session.log?.info(`session created in WaitingForHandshake state`, {
|
|
535
543
|
...session.loggingMetadata,
|
|
536
544
|
tags: ["state-transition"]
|
|
@@ -542,16 +550,33 @@ var SessionStateGraph = {
|
|
|
542
550
|
// After a session is transitioned, any usage of the old session will throw.
|
|
543
551
|
transition: {
|
|
544
552
|
// happy path transitions
|
|
545
|
-
|
|
553
|
+
NoConnectionToBackingOff: (oldSession, backoffMs, listeners) => {
|
|
546
554
|
const carriedState = inheritSharedSession(oldSession);
|
|
547
555
|
oldSession._handleStateExit();
|
|
548
|
-
const session = new
|
|
549
|
-
|
|
556
|
+
const session = new SessionBackingOff({
|
|
557
|
+
backoffMs,
|
|
550
558
|
listeners,
|
|
551
559
|
...carriedState
|
|
560
|
+
});
|
|
561
|
+
session.log?.info(
|
|
562
|
+
`session ${session.id} transition from NoConnection to BackingOff`,
|
|
563
|
+
{
|
|
564
|
+
...session.loggingMetadata,
|
|
565
|
+
tags: ["state-transition"]
|
|
566
|
+
}
|
|
552
567
|
);
|
|
568
|
+
return session;
|
|
569
|
+
},
|
|
570
|
+
BackingOffToConnecting: (oldSession, connPromise, listeners) => {
|
|
571
|
+
const carriedState = inheritSharedSession(oldSession);
|
|
572
|
+
oldSession._handleStateExit();
|
|
573
|
+
const session = new SessionConnecting({
|
|
574
|
+
connPromise,
|
|
575
|
+
listeners,
|
|
576
|
+
...carriedState
|
|
577
|
+
});
|
|
553
578
|
session.log?.info(
|
|
554
|
-
`session ${session.id} transition from
|
|
579
|
+
`session ${session.id} transition from BackingOff to Connecting`,
|
|
555
580
|
{
|
|
556
581
|
...session.loggingMetadata,
|
|
557
582
|
tags: ["state-transition"]
|
|
@@ -559,10 +584,14 @@ var SessionStateGraph = {
|
|
|
559
584
|
);
|
|
560
585
|
return session;
|
|
561
586
|
},
|
|
562
|
-
ConnectingToHandshaking(oldSession, conn, listeners) {
|
|
587
|
+
ConnectingToHandshaking: (oldSession, conn, listeners) => {
|
|
563
588
|
const carriedState = inheritSharedSession(oldSession);
|
|
564
589
|
oldSession._handleStateExit();
|
|
565
|
-
const session = new SessionHandshaking(
|
|
590
|
+
const session = new SessionHandshaking({
|
|
591
|
+
conn,
|
|
592
|
+
listeners,
|
|
593
|
+
...carriedState
|
|
594
|
+
});
|
|
566
595
|
session.log?.info(
|
|
567
596
|
`session ${session.id} transition from Connecting to Handshaking`,
|
|
568
597
|
{
|
|
@@ -572,11 +601,15 @@ var SessionStateGraph = {
|
|
|
572
601
|
);
|
|
573
602
|
return session;
|
|
574
603
|
},
|
|
575
|
-
HandshakingToConnected(oldSession, listeners) {
|
|
604
|
+
HandshakingToConnected: (oldSession, listeners) => {
|
|
576
605
|
const carriedState = inheritSharedSession(oldSession);
|
|
577
606
|
const conn = oldSession.conn;
|
|
578
607
|
oldSession._handleStateExit();
|
|
579
|
-
const session = new SessionConnected(
|
|
608
|
+
const session = new SessionConnected({
|
|
609
|
+
conn,
|
|
610
|
+
listeners,
|
|
611
|
+
...carriedState
|
|
612
|
+
});
|
|
580
613
|
session.log?.info(
|
|
581
614
|
`session ${session.id} transition from Handshaking to Connected`,
|
|
582
615
|
{
|
|
@@ -586,7 +619,7 @@ var SessionStateGraph = {
|
|
|
586
619
|
);
|
|
587
620
|
return session;
|
|
588
621
|
},
|
|
589
|
-
WaitingForHandshakeToConnected(pendingSession, oldSession, sessionId, to, propagationCtx, listeners) {
|
|
622
|
+
WaitingForHandshakeToConnected: (pendingSession, oldSession, sessionId, to, propagationCtx, listeners) => {
|
|
590
623
|
const conn = pendingSession.conn;
|
|
591
624
|
const { from, options } = pendingSession;
|
|
592
625
|
const carriedState = oldSession ? (
|
|
@@ -594,21 +627,30 @@ var SessionStateGraph = {
|
|
|
594
627
|
inheritSharedSession(oldSession)
|
|
595
628
|
) : (
|
|
596
629
|
// old session does not exist, create new state
|
|
597
|
-
|
|
598
|
-
sessionId,
|
|
630
|
+
{
|
|
631
|
+
id: sessionId,
|
|
599
632
|
from,
|
|
600
633
|
to,
|
|
601
|
-
0,
|
|
602
|
-
0,
|
|
603
|
-
[],
|
|
604
|
-
createSessionTelemetryInfo(
|
|
634
|
+
seq: 0,
|
|
635
|
+
ack: 0,
|
|
636
|
+
sendBuffer: [],
|
|
637
|
+
telemetry: createSessionTelemetryInfo(
|
|
638
|
+
sessionId,
|
|
639
|
+
to,
|
|
640
|
+
from,
|
|
641
|
+
propagationCtx
|
|
642
|
+
),
|
|
605
643
|
options,
|
|
606
|
-
pendingSession.log
|
|
607
|
-
|
|
644
|
+
log: pendingSession.log
|
|
645
|
+
}
|
|
608
646
|
);
|
|
609
647
|
pendingSession._handleStateExit();
|
|
610
648
|
oldSession?._handleStateExit();
|
|
611
|
-
const session = new SessionConnected(
|
|
649
|
+
const session = new SessionConnected({
|
|
650
|
+
conn,
|
|
651
|
+
listeners,
|
|
652
|
+
...carriedState
|
|
653
|
+
});
|
|
612
654
|
session.log?.info(
|
|
613
655
|
`session ${session.id} transition from WaitingForHandshake to Connected`,
|
|
614
656
|
{
|
|
@@ -619,11 +661,24 @@ var SessionStateGraph = {
|
|
|
619
661
|
return session;
|
|
620
662
|
},
|
|
621
663
|
// disconnect paths
|
|
622
|
-
|
|
664
|
+
BackingOffToNoConnection: (oldSession, listeners) => {
|
|
665
|
+
const carriedState = inheritSharedSession(oldSession);
|
|
666
|
+
oldSession._handleStateExit();
|
|
667
|
+
const session = new SessionNoConnection({ listeners, ...carriedState });
|
|
668
|
+
session.log?.info(
|
|
669
|
+
`session ${session.id} transition from BackingOff to NoConnection`,
|
|
670
|
+
{
|
|
671
|
+
...session.loggingMetadata,
|
|
672
|
+
tags: ["state-transition"]
|
|
673
|
+
}
|
|
674
|
+
);
|
|
675
|
+
return session;
|
|
676
|
+
},
|
|
677
|
+
ConnectingToNoConnection: (oldSession, listeners) => {
|
|
623
678
|
const carriedState = inheritSharedSession(oldSession);
|
|
624
679
|
oldSession.bestEffortClose();
|
|
625
680
|
oldSession._handleStateExit();
|
|
626
|
-
const session = new SessionNoConnection(listeners, ...carriedState);
|
|
681
|
+
const session = new SessionNoConnection({ listeners, ...carriedState });
|
|
627
682
|
session.log?.info(
|
|
628
683
|
`session ${session.id} transition from Connecting to NoConnection`,
|
|
629
684
|
{
|
|
@@ -633,11 +688,11 @@ var SessionStateGraph = {
|
|
|
633
688
|
);
|
|
634
689
|
return session;
|
|
635
690
|
},
|
|
636
|
-
HandshakingToNoConnection(oldSession, listeners) {
|
|
691
|
+
HandshakingToNoConnection: (oldSession, listeners) => {
|
|
637
692
|
const carriedState = inheritSharedSession(oldSession);
|
|
638
693
|
oldSession.conn.close();
|
|
639
694
|
oldSession._handleStateExit();
|
|
640
|
-
const session = new SessionNoConnection(listeners, ...carriedState);
|
|
695
|
+
const session = new SessionNoConnection({ listeners, ...carriedState });
|
|
641
696
|
session.log?.info(
|
|
642
697
|
`session ${session.id} transition from Handshaking to NoConnection`,
|
|
643
698
|
{
|
|
@@ -647,11 +702,11 @@ var SessionStateGraph = {
|
|
|
647
702
|
);
|
|
648
703
|
return session;
|
|
649
704
|
},
|
|
650
|
-
ConnectedToNoConnection(oldSession, listeners) {
|
|
705
|
+
ConnectedToNoConnection: (oldSession, listeners) => {
|
|
651
706
|
const carriedState = inheritSharedSession(oldSession);
|
|
652
707
|
oldSession.conn.close();
|
|
653
708
|
oldSession._handleStateExit();
|
|
654
|
-
const session = new SessionNoConnection(listeners, ...carriedState);
|
|
709
|
+
const session = new SessionNoConnection({ listeners, ...carriedState });
|
|
655
710
|
session.log?.info(
|
|
656
711
|
`session ${session.id} transition from Connected to NoConnection`,
|
|
657
712
|
{
|
|
@@ -663,12 +718,39 @@ var SessionStateGraph = {
|
|
|
663
718
|
}
|
|
664
719
|
}
|
|
665
720
|
};
|
|
721
|
+
var transitions = SessionStateGraph.transition;
|
|
722
|
+
var ClientSessionStateGraph = {
|
|
723
|
+
entrypoint: SessionStateGraph.entrypoints.NoConnection,
|
|
724
|
+
transition: {
|
|
725
|
+
// happy paths
|
|
726
|
+
NoConnectionToBackingOff: transitions.NoConnectionToBackingOff,
|
|
727
|
+
BackingOffToConnecting: transitions.BackingOffToConnecting,
|
|
728
|
+
ConnectingToHandshaking: transitions.ConnectingToHandshaking,
|
|
729
|
+
HandshakingToConnected: transitions.HandshakingToConnected,
|
|
730
|
+
// disconnect paths
|
|
731
|
+
BackingOffToNoConnection: transitions.BackingOffToNoConnection,
|
|
732
|
+
ConnectingToNoConnection: transitions.ConnectingToNoConnection,
|
|
733
|
+
HandshakingToNoConnection: transitions.HandshakingToNoConnection,
|
|
734
|
+
ConnectedToNoConnection: transitions.ConnectedToNoConnection
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
var ServerSessionStateGraph = {
|
|
738
|
+
entrypoint: SessionStateGraph.entrypoints.WaitingForHandshake,
|
|
739
|
+
transition: {
|
|
740
|
+
// happy paths
|
|
741
|
+
WaitingForHandshakeToConnected: transitions.WaitingForHandshakeToConnected,
|
|
742
|
+
// disconnect paths
|
|
743
|
+
ConnectedToNoConnection: transitions.ConnectedToNoConnection
|
|
744
|
+
}
|
|
745
|
+
};
|
|
666
746
|
|
|
667
747
|
export {
|
|
668
748
|
defaultTransportOptions,
|
|
669
749
|
defaultClientTransportOptions,
|
|
670
750
|
defaultServerTransportOptions,
|
|
671
751
|
SessionState,
|
|
672
|
-
SessionStateGraph
|
|
752
|
+
SessionStateGraph,
|
|
753
|
+
ClientSessionStateGraph,
|
|
754
|
+
ServerSessionStateGraph
|
|
673
755
|
};
|
|
674
|
-
//# sourceMappingURL=chunk-
|
|
756
|
+
//# sourceMappingURL=chunk-Q3PZBJXR.js.map
|