@replit/river 0.204.0 → 0.205.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/{chunk-6YUDEFCS.js → chunk-AXZPYUY6.js} +10 -5
- package/dist/{chunk-6YUDEFCS.js.map → chunk-AXZPYUY6.js.map} +1 -1
- package/dist/{chunk-QSW7AWEP.js → chunk-EU2H4J7U.js} +2 -2
- package/dist/{chunk-LJCR3ADI.js → chunk-GG3GL7CW.js} +4 -4
- package/dist/{chunk-LJCR3ADI.js.map → chunk-GG3GL7CW.js.map} +1 -1
- package/dist/{chunk-3V7VMJNA.js → chunk-RAO6UI45.js} +5 -4
- package/dist/chunk-RAO6UI45.js.map +1 -0
- package/dist/{chunk-YODW2ZMU.js → chunk-VN7QS6OS.js} +3 -3
- package/dist/{client-0c0a4a5e.d.ts → client-3adfb12a.d.ts} +1 -1
- package/dist/{connection-7b62dfec.d.ts → connection-9ca3e7ed.d.ts} +1 -1
- package/dist/{context-3cf1ed4e.d.ts → context-1a332293.d.ts} +4 -1
- package/dist/router/index.cjs +3 -3
- 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 +1 -1
- package/dist/{server-a287de55.d.ts → server-8ac5c6bf.d.ts} +1 -1
- package/dist/{services-51980ecd.d.ts → services-4213d92e.d.ts} +2 -2
- package/dist/testUtil/index.cjs +11 -5
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +4 -4
- package/dist/testUtil/index.d.ts +4 -4
- package/dist/testUtil/index.js +4 -4
- package/dist/transport/impls/ws/client.cjs +11 -5
- 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 +4 -4
- package/dist/transport/impls/ws/server.cjs +9 -4
- 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 +4 -4
- package/dist/transport/index.cjs +11 -5
- 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 +4 -4
- package/package.json +1 -1
- package/dist/chunk-3V7VMJNA.js.map +0 -1
- /package/dist/{chunk-QSW7AWEP.js.map → chunk-EU2H4J7U.js.map} +0 -0
- /package/dist/{chunk-YODW2ZMU.js.map → chunk-VN7QS6OS.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ProtocolError,
|
|
4
4
|
Transport,
|
|
5
5
|
defaultClientTransportOptions
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AXZPYUY6.js";
|
|
7
7
|
import {
|
|
8
8
|
ControlMessageHandshakeResponseSchema,
|
|
9
9
|
HandshakeErrorRetriableResponseCodes,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
currentProtocolVersion,
|
|
12
12
|
getPropagationContext,
|
|
13
13
|
handshakeRequestMessage
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GG3GL7CW.js";
|
|
15
15
|
|
|
16
16
|
// transport/client.ts
|
|
17
17
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
@@ -344,7 +344,8 @@ var ClientTransport = class extends Transport {
|
|
|
344
344
|
* and don't want to wait for the grace period to elapse.
|
|
345
345
|
*/
|
|
346
346
|
hardDisconnect() {
|
|
347
|
-
|
|
347
|
+
const sessions = Array.from(this.sessions.values());
|
|
348
|
+
for (const session of sessions) {
|
|
348
349
|
this.deleteSession(session);
|
|
349
350
|
}
|
|
350
351
|
}
|
|
@@ -434,4 +435,4 @@ var ClientTransport = class extends Transport {
|
|
|
434
435
|
export {
|
|
435
436
|
ClientTransport
|
|
436
437
|
};
|
|
437
|
-
//# sourceMappingURL=chunk-
|
|
438
|
+
//# sourceMappingURL=chunk-RAO6UI45.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../transport/client.ts","../transport/rateLimit.ts"],"sourcesContent":["import { SpanStatusCode } from '@opentelemetry/api';\nimport { ClientHandshakeOptions } from '../router/handshake';\nimport {\n ControlMessageHandshakeResponseSchema,\n HandshakeErrorRetriableResponseCodes,\n OpaqueTransportMessage,\n TransportClientId,\n currentProtocolVersion,\n handshakeRequestMessage,\n} from './message';\nimport {\n ClientTransportOptions,\n ProvidedClientTransportOptions,\n defaultClientTransportOptions,\n} from './options';\nimport { LeakyBucketRateLimit } from './rateLimit';\nimport { Transport } from './transport';\nimport { coerceErrorString } from './stringifyError';\nimport { ProtocolError } from './events';\nimport { Value } from '@sinclair/typebox/value';\nimport { getPropagationContext } from '../tracing';\nimport { Connection } from './connection';\nimport { MessageMetadata } from '../logging';\nimport { SessionConnecting } from './sessionStateMachine/SessionConnecting';\nimport { SessionHandshaking } from './sessionStateMachine/SessionHandshaking';\nimport { SessionConnected } from './sessionStateMachine/SessionConnected';\nimport {\n ClientSession,\n ClientSessionStateGraph,\n} from './sessionStateMachine/transitions';\nimport { SessionState } from './sessionStateMachine/common';\nimport { SessionNoConnection } from './sessionStateMachine/SessionNoConnection';\nimport { SessionBackingOff } from './sessionStateMachine/SessionBackingOff';\n\nexport abstract class ClientTransport<\n ConnType extends Connection,\n> extends Transport<ConnType> {\n /**\n * The options for this transport.\n */\n protected options: ClientTransportOptions;\n\n retryBudget: LeakyBucketRateLimit;\n\n /**\n * A flag indicating whether the transport should automatically reconnect\n * when a connection is dropped.\n * Realistically, this should always be true for clients unless you are writing\n * tests or a special case where you don't want to reconnect.\n */\n reconnectOnConnectionDrop = true;\n\n /**\n * Optional handshake options for this client.\n */\n handshakeExtensions?: ClientHandshakeOptions;\n\n sessions: Map<TransportClientId, ClientSession<ConnType>>;\n\n constructor(\n clientId: TransportClientId,\n providedOptions?: ProvidedClientTransportOptions,\n ) {\n super(clientId, providedOptions);\n this.sessions = new Map();\n this.options = {\n ...defaultClientTransportOptions,\n ...providedOptions,\n };\n this.retryBudget = new LeakyBucketRateLimit(this.options);\n }\n\n extendHandshake(options: ClientHandshakeOptions) {\n this.handshakeExtensions = options;\n }\n\n /**\n * Abstract method that creates a new {@link Connection} object.\n *\n * @param to The client ID of the node to connect to.\n * @returns The new connection object.\n */\n protected abstract createNewOutgoingConnection(\n to: TransportClientId,\n ): Promise<ConnType>;\n\n private tryReconnecting(to: TransportClientId) {\n const oldSession = this.sessions.get(to);\n if (!this.options.enableTransparentSessionReconnects && oldSession) {\n this.deleteSession(oldSession);\n }\n\n if (this.reconnectOnConnectionDrop && this.getStatus() === 'open') {\n this.connect(to);\n }\n }\n\n /*\n * Creates a raw unconnected session object.\n * This is mostly a River internal, you shouldn't need to use this directly.\n */\n createUnconnectedSession(to: string): SessionNoConnection {\n const session = ClientSessionStateGraph.entrypoint(\n to,\n this.clientId,\n {\n onSessionGracePeriodElapsed: () => {\n this.onSessionGracePeriodElapsed(session);\n },\n },\n this.options,\n currentProtocolVersion,\n this.tracer,\n this.log,\n );\n\n this.createSession(session);\n\n return session;\n }\n\n // listeners\n protected onConnectingFailed(session: SessionConnecting<ConnType>) {\n const noConnectionSession = super.onConnectingFailed(session);\n this.tryReconnecting(noConnectionSession.to);\n\n return noConnectionSession;\n }\n\n protected onConnClosed(\n session: SessionHandshaking<ConnType> | SessionConnected<ConnType>,\n ) {\n const noConnectionSession = super.onConnClosed(session);\n this.tryReconnecting(noConnectionSession.to);\n\n return noConnectionSession;\n }\n\n protected onConnectionEstablished(\n session: SessionConnecting<ConnType>,\n conn: ConnType,\n ): SessionHandshaking<ConnType> {\n // transition to handshaking\n const handshakingSession =\n ClientSessionStateGraph.transition.ConnectingToHandshaking(\n session,\n conn,\n {\n onConnectionErrored: (err) => {\n // just log, when we error we also emit close\n const errStr = coerceErrorString(err);\n this.log?.error(\n `connection to ${handshakingSession.to} errored during handshake: ${errStr}`,\n handshakingSession.loggingMetadata,\n );\n },\n onConnectionClosed: () => {\n this.log?.warn(\n `connection to ${handshakingSession.to} closed during handshake`,\n handshakingSession.loggingMetadata,\n );\n this.onConnClosed(handshakingSession);\n },\n onHandshake: (msg) => {\n this.onHandshakeResponse(handshakingSession, msg);\n },\n onInvalidHandshake: (reason, code) => {\n this.log?.error(\n `invalid handshake: ${reason}`,\n handshakingSession.loggingMetadata,\n );\n this.deleteSession(session, { unhealthy: true });\n this.protocolError({\n type: ProtocolError.HandshakeFailed,\n code,\n message: reason,\n });\n },\n onHandshakeTimeout: () => {\n this.log?.error(\n `connection to ${handshakingSession.to} timed out during handshake`,\n handshakingSession.loggingMetadata,\n );\n this.onConnClosed(handshakingSession);\n },\n onSessionGracePeriodElapsed: () => {\n this.onSessionGracePeriodElapsed(handshakingSession);\n },\n },\n );\n\n this.updateSession(handshakingSession);\n void this.sendHandshake(handshakingSession);\n\n return handshakingSession;\n }\n\n private rejectHandshakeResponse(\n session: SessionHandshaking<ConnType>,\n reason: string,\n metadata: MessageMetadata,\n ) {\n session.conn.telemetry?.span.setStatus({\n code: SpanStatusCode.ERROR,\n message: reason,\n });\n\n this.log?.warn(reason, metadata);\n this.deleteSession(session, { unhealthy: true });\n }\n\n protected onHandshakeResponse(\n session: SessionHandshaking<ConnType>,\n msg: OpaqueTransportMessage,\n ) {\n // invariant: msg is a handshake response\n if (!Value.Check(ControlMessageHandshakeResponseSchema, msg.payload)) {\n const reason = `received invalid handshake response`;\n this.rejectHandshakeResponse(session, reason, {\n ...session.loggingMetadata,\n transportMessage: msg,\n validationErrors: [\n ...Value.Errors(ControlMessageHandshakeResponseSchema, msg.payload),\n ],\n });\n\n return;\n }\n\n // invariant: handshake response should be ok\n if (!msg.payload.status.ok) {\n const retriable = Value.Check(\n HandshakeErrorRetriableResponseCodes,\n msg.payload.status.code,\n );\n\n const reason = `handshake failed: ${msg.payload.status.reason}`;\n const to = session.to;\n this.rejectHandshakeResponse(session, reason, {\n ...session.loggingMetadata,\n transportMessage: msg,\n });\n\n if (retriable) {\n this.tryReconnecting(to);\n } else {\n this.protocolError({\n type: ProtocolError.HandshakeFailed,\n code: msg.payload.status.code,\n message: reason,\n });\n }\n\n return;\n }\n\n // invariant: session id should match between client + server\n if (msg.payload.status.sessionId !== session.id) {\n const reason = `session id mismatch: expected ${session.id}, got ${msg.payload.status.sessionId}`;\n this.rejectHandshakeResponse(session, reason, {\n ...session.loggingMetadata,\n transportMessage: msg,\n });\n\n return;\n }\n\n // transition to connected!\n this.log?.info(`handshake from ${msg.from} ok`, {\n ...session.loggingMetadata,\n transportMessage: msg,\n });\n\n const connectedSession =\n ClientSessionStateGraph.transition.HandshakingToConnected(session, {\n onConnectionErrored: (err) => {\n // just log, when we error we also emit close\n const errStr = coerceErrorString(err);\n this.log?.warn(\n `connection to ${connectedSession.to} errored: ${errStr}`,\n connectedSession.loggingMetadata,\n );\n },\n onConnectionClosed: () => {\n this.log?.info(\n `connection to ${connectedSession.to} closed`,\n connectedSession.loggingMetadata,\n );\n this.onConnClosed(connectedSession);\n },\n onMessage: (msg) => {\n this.handleMsg(msg);\n },\n onInvalidMessage: (reason) => {\n this.deleteSession(connectedSession, { unhealthy: true });\n this.protocolError({\n type: ProtocolError.InvalidMessage,\n message: reason,\n });\n },\n });\n\n this.updateSession(connectedSession);\n this.retryBudget.startRestoringBudget();\n }\n\n /**\n * Manually attempts to connect to a client.\n * @param to The client ID of the node to connect to.\n */\n connect(to: TransportClientId) {\n if (this.getStatus() !== 'open') {\n this.log?.info(\n `transport state is no longer open, cancelling attempt to connect to ${to}`,\n );\n\n return;\n }\n\n const session = this.sessions.get(to) ?? this.createUnconnectedSession(to);\n if (session.state !== SessionState.NoConnection) {\n // already trying to connect\n this.log?.debug(\n `session to ${to} has state ${session.state}, skipping connect attempt`,\n session.loggingMetadata,\n );\n\n return;\n }\n\n // check budget\n if (!this.retryBudget.hasBudget()) {\n const budgetConsumed = this.retryBudget.getBudgetConsumed();\n const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;\n this.log?.error(errMsg, session.loggingMetadata);\n this.protocolError({\n type: ProtocolError.RetriesExceeded,\n message: errMsg,\n });\n\n return;\n }\n\n const backoffMs = this.retryBudget.getBackoffMs();\n\n this.log?.info(\n `attempting connection to ${to} (${backoffMs}ms backoff)`,\n session.loggingMetadata,\n );\n\n this.retryBudget.consumeBudget();\n const backingOffSession =\n ClientSessionStateGraph.transition.NoConnectionToBackingOff(\n session,\n backoffMs,\n {\n onBackoffFinished: () => {\n this.onBackoffFinished(backingOffSession);\n },\n onSessionGracePeriodElapsed: () => {\n this.onSessionGracePeriodElapsed(backingOffSession);\n },\n },\n );\n\n this.updateSession(backingOffSession);\n }\n\n /**\n * Manually kills all sessions to the server (including all pending state).\n * This is useful for when you want to close all connections to a server\n * and don't want to wait for the grace period to elapse.\n */\n hardDisconnect() {\n // create a copy of the sessions to avoid modifying the map while iterating\n const sessions = Array.from(this.sessions.values());\n for (const session of sessions) {\n this.deleteSession(session);\n }\n }\n\n protected onBackoffFinished(session: SessionBackingOff) {\n const connPromise = session.tracer.startActiveSpan(\n 'connect',\n async (span) => {\n try {\n return await this.createNewOutgoingConnection(session.to);\n } catch (err) {\n // rethrow the error so that the promise is rejected\n // as it was before we wrapped it in a span\n const errStr = coerceErrorString(err);\n span.recordException(errStr);\n span.setStatus({ code: SpanStatusCode.ERROR });\n throw err;\n } finally {\n span.end();\n }\n },\n );\n\n // transition to connecting\n const connectingSession =\n ClientSessionStateGraph.transition.BackingOffToConnecting(\n session,\n connPromise,\n {\n onConnectionEstablished: (conn) => {\n this.log?.debug(\n `connection to ${connectingSession.to} established`,\n {\n ...conn.loggingMetadata,\n ...connectingSession.loggingMetadata,\n },\n );\n\n // cast here because conn can't be narrowed to ConnType\n // in the callback due to variance rules\n this.onConnectionEstablished(connectingSession, conn as ConnType);\n },\n onConnectionFailed: (error: unknown) => {\n const errStr = coerceErrorString(error);\n this.log?.error(\n `error connecting to ${connectingSession.to}: ${errStr}`,\n connectingSession.loggingMetadata,\n );\n this.onConnectingFailed(connectingSession);\n },\n onConnectionTimeout: () => {\n this.log?.error(\n `connection to ${connectingSession.to} timed out`,\n connectingSession.loggingMetadata,\n );\n this.onConnectingFailed(connectingSession);\n },\n onSessionGracePeriodElapsed: () => {\n this.onSessionGracePeriodElapsed(connectingSession);\n },\n },\n );\n\n this.updateSession(connectingSession);\n }\n\n private async sendHandshake(session: SessionHandshaking<ConnType>) {\n let metadata: unknown = undefined;\n\n if (this.handshakeExtensions) {\n metadata = await this.handshakeExtensions.construct();\n }\n\n // double-check to make sure we haven't transitioned the session yet\n if (session._isConsumed) {\n // bail out, don't need to do anything\n return;\n }\n\n const requestMsg = handshakeRequestMessage({\n from: this.clientId,\n to: session.to,\n sessionId: session.id,\n expectedSessionState: {\n nextExpectedSeq: session.ack,\n nextSentSeq: session.nextSeq(),\n },\n metadata,\n tracing: getPropagationContext(session.telemetry.ctx),\n });\n\n this.log?.debug(`sending handshake request to ${session.to}`, {\n ...session.loggingMetadata,\n transportMessage: requestMsg,\n });\n\n session.sendHandshake(requestMsg);\n }\n\n close() {\n this.retryBudget.close();\n super.close();\n }\n}\n","/**\n * Options to control the backoff and retry behavior of the client transport's connection behaviour.\n *\n * River implements exponential backoff with jitter to prevent flooding the server\n * when there's an issue with connection establishment.\n *\n * The backoff is calculated via the following:\n * backOff = min(jitter + {@link baseIntervalMs} * 2 ^ budget_consumed, {@link maxBackoffMs})\n *\n * We use a leaky bucket rate limit with a budget of {@link attemptBudgetCapacity} reconnection attempts.\n * Budget only starts to restore after a successful handshake at a rate of one budget per {@link budgetRestoreIntervalMs}.\n */\nexport interface ConnectionRetryOptions {\n /**\n * The base interval to wait before retrying a connection.\n */\n baseIntervalMs: number;\n\n /**\n * The maximum random jitter to add to the total backoff time.\n */\n maxJitterMs: number;\n\n /**\n * The maximum amount of time to wait before retrying a connection.\n * This does not include the jitter.\n */\n maxBackoffMs: number;\n\n /**\n * The max number of times to attempt a connection before a successful handshake.\n * This persists across connections but starts restoring budget after a successful handshake.\n * The restoration interval depends on {@link budgetRestoreIntervalMs}\n */\n attemptBudgetCapacity: number;\n\n /**\n * After a successful connection attempt, how long to wait before we restore a single budget.\n */\n budgetRestoreIntervalMs: number;\n}\n\nexport class LeakyBucketRateLimit {\n private budgetConsumed: number;\n private intervalHandle?: ReturnType<typeof setInterval>;\n private readonly options: ConnectionRetryOptions;\n\n constructor(options: ConnectionRetryOptions) {\n this.options = options;\n this.budgetConsumed = 0;\n }\n\n getBackoffMs() {\n if (this.getBudgetConsumed() === 0) {\n return 0;\n }\n\n const exponent = Math.max(0, this.getBudgetConsumed() - 1);\n const jitter = Math.floor(Math.random() * this.options.maxJitterMs);\n const backoffMs = Math.min(\n this.options.baseIntervalMs * 2 ** exponent,\n this.options.maxBackoffMs,\n );\n\n return backoffMs + jitter;\n }\n\n get totalBudgetRestoreTime() {\n return (\n this.options.budgetRestoreIntervalMs * this.options.attemptBudgetCapacity\n );\n }\n\n consumeBudget() {\n // If we're consuming again, let's ensure that we're not leaking\n this.stopLeak();\n this.budgetConsumed = this.getBudgetConsumed() + 1;\n }\n\n getBudgetConsumed() {\n return this.budgetConsumed;\n }\n\n hasBudget() {\n return this.getBudgetConsumed() < this.options.attemptBudgetCapacity;\n }\n\n startRestoringBudget() {\n if (this.intervalHandle) {\n return;\n }\n\n const restoreBudgetForUser = () => {\n const currentBudget = this.budgetConsumed;\n if (!currentBudget) {\n this.stopLeak();\n\n return;\n }\n\n const newBudget = currentBudget - 1;\n if (newBudget === 0) {\n return;\n }\n\n this.budgetConsumed = newBudget;\n };\n\n this.intervalHandle = setInterval(\n restoreBudgetForUser,\n this.options.budgetRestoreIntervalMs,\n );\n }\n\n private stopLeak() {\n if (!this.intervalHandle) {\n return;\n }\n\n clearInterval(this.intervalHandle);\n this.intervalHandle = undefined;\n }\n\n close() {\n this.stopL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C;AAED,SAAK,KAAK,MAAM,gCAAgC,QAAQ,EAAE,IAAI;AAAA,MAC5D,GAAG,QAAQ;AAAA,MACX,kBAAkB;AAAA,IACpB,CAAC;AAED,YAAQ,cAAc,UAAU;AAAA,EAClC;AAAA,EAEA,QAAQ;AACN,SAAK,YAAY,MAAM;AACvB,UAAM,MAAM;AAAA,EACd;AACF;","names":["msg"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ServerSessionStateGraph,
|
|
4
4
|
Transport,
|
|
5
5
|
defaultServerTransportOptions
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AXZPYUY6.js";
|
|
7
7
|
import {
|
|
8
8
|
ControlMessageHandshakeRequestSchema,
|
|
9
9
|
HandshakeErrorCustomHandlerFatalResponseCodes,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
currentProtocolVersion,
|
|
13
13
|
handshakeResponseMessage,
|
|
14
14
|
isAcceptedProtocolVersion
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GG3GL7CW.js";
|
|
16
16
|
|
|
17
17
|
// transport/server.ts
|
|
18
18
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
@@ -374,4 +374,4 @@ var ServerTransport = class extends Transport {
|
|
|
374
374
|
export {
|
|
375
375
|
ServerTransport
|
|
376
376
|
};
|
|
377
|
-
//# sourceMappingURL=chunk-
|
|
377
|
+
//# sourceMappingURL=chunk-VN7QS6OS.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Connection, T as Transport, m as ClientTransportOptions, L as LeakyBucketRateLimit, n as ClientHandshakeOptions, o as ClientSession, b as ProvidedClientTransportOptions, e as SessionNoConnection, f as SessionConnecting, g as SessionHandshaking, h as SessionConnected, p as SessionBackingOff } from './context-
|
|
1
|
+
import { C as Connection, T as Transport, m as ClientTransportOptions, L as LeakyBucketRateLimit, n as ClientHandshakeOptions, o as ClientSession, b as ProvidedClientTransportOptions, e as SessionNoConnection, f as SessionConnecting, g as SessionHandshaking, h as SessionConnected, p as SessionBackingOff } from './context-1a332293.js';
|
|
2
2
|
import { c as TransportClientId, b as OpaqueTransportMessage } from './message-3def9ded.js';
|
|
3
3
|
|
|
4
4
|
declare abstract class ClientTransport<ConnType extends Connection> extends Transport<ConnType> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as ProtocolVersion, b as OpaqueTransportMessage, e as Tags } from './message-3def9ded.js';
|
|
2
2
|
import * as _sinclair_typebox_errors from '@sinclair/typebox/errors';
|
|
3
|
-
import { C as Connection } from './context-
|
|
3
|
+
import { C as Connection } from './context-1a332293.js';
|
|
4
4
|
import { W as WsLike } from './wslike-e0b32dd5.js';
|
|
5
5
|
|
|
6
6
|
interface ConnectionInfoExtras extends Record<string, unknown> {
|
|
@@ -321,8 +321,11 @@ type ProtocolErrorType = (typeof ProtocolError)[keyof typeof ProtocolError];
|
|
|
321
321
|
interface EventMap {
|
|
322
322
|
message: OpaqueTransportMessage;
|
|
323
323
|
sessionStatus: {
|
|
324
|
-
status: '
|
|
324
|
+
status: 'created' | 'closing';
|
|
325
325
|
session: Session<Connection>;
|
|
326
|
+
} | {
|
|
327
|
+
status: 'closed';
|
|
328
|
+
session: Pick<Session<Connection>, 'id' | 'to'>;
|
|
326
329
|
};
|
|
327
330
|
sessionTransition: {
|
|
328
331
|
state: SessionState.Connected;
|
package/dist/router/index.cjs
CHANGED
|
@@ -1096,7 +1096,7 @@ function handleProc(procType, transport, serverId, init, serviceName, procedureN
|
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
1098
1098
|
function onSessionStatus(evt) {
|
|
1099
|
-
if (evt.status !== "
|
|
1099
|
+
if (evt.status !== "closing" || evt.session.to !== serverId || session.id !== evt.session.id) {
|
|
1100
1100
|
return;
|
|
1101
1101
|
}
|
|
1102
1102
|
cleanClose = false;
|
|
@@ -1255,7 +1255,7 @@ var RiverServer = class {
|
|
|
1255
1255
|
);
|
|
1256
1256
|
};
|
|
1257
1257
|
const handleSessionStatus = (evt) => {
|
|
1258
|
-
if (evt.status !== "
|
|
1258
|
+
if (evt.status !== "closing")
|
|
1259
1259
|
return;
|
|
1260
1260
|
const disconnectedClientId = evt.session.to;
|
|
1261
1261
|
this.log?.info(
|
|
@@ -1858,7 +1858,7 @@ function createServerHandshakeOptions(schema, validate) {
|
|
|
1858
1858
|
}
|
|
1859
1859
|
|
|
1860
1860
|
// package.json
|
|
1861
|
-
var version = "0.
|
|
1861
|
+
var version = "0.205.0";
|
|
1862
1862
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1863
1863
|
0 && (module.exports = {
|
|
1864
1864
|
CANCEL_CODE,
|