@fluidframework/container-loader 2.0.0-internal.2.3.0 → 2.0.0-internal.2.4.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/dist/connectionManager.d.ts +1 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +1 -1
- package/dist/connectionManager.js.map +1 -1
- package/dist/container.d.ts +16 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +31 -5
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +1 -5
- package/dist/containerContext.js.map +1 -1
- package/dist/deltaManager.d.ts +4 -0
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +22 -0
- package/dist/deltaManager.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/connectionManager.d.ts +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +1 -1
- package/lib/connectionManager.js.map +1 -1
- package/lib/container.d.ts +16 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +31 -5
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +1 -5
- package/lib/containerContext.js.map +1 -1
- package/lib/deltaManager.d.ts +4 -0
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +22 -0
- package/lib/deltaManager.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +13 -12
- package/src/connectionManager.ts +1 -1
- package/src/container.ts +43 -10
- package/src/containerContext.ts +5 -8
- package/src/deltaManager.ts +25 -0
- package/src/packageVersion.ts +1 -1
|
@@ -38,7 +38,7 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
38
38
|
private pendingReconnect;
|
|
39
39
|
private clientSequenceNumber;
|
|
40
40
|
private clientSequenceNumberObserved;
|
|
41
|
-
/** Counts the number of
|
|
41
|
+
/** Counts the number of non-runtime ops sent by the client which may not be acked. */
|
|
42
42
|
private localOpsToIgnore;
|
|
43
43
|
/** track clientId used last time when we sent any ops */
|
|
44
44
|
private lastSubmittedClientId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEH,gBAAgB,EAChB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,WAAW,EACX,YAAY,EAEZ,uBAAuB,EAC1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEH,gBAAgB,EAGnB,MAAM,oCAAoC,CAAC;AAW5C,OAAO,EACH,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAGhB,yBAAyB,EAO5B,MAAM,sCAAsC,CAAC;AAK9C,OAAO,EACH,aAAa,EACb,kBAAkB,EAClB,6BAA6B,EAChC,MAAM,aAAa,CAAC;AAuFrB;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAyJpD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IA5J1B,qEAAqE;IACrE,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAiB;IAEzD;;;;OAIG;IACH,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,UAAU,CAAuC;IAEzD,kEAAkE;IAClE,OAAO,CAAC,oBAAoB,CAAsB;IAElD,4CAA4C;IAC5C,OAAO,CAAC,cAAc,CAAS;IAE/B;;OAEG;IACH,OAAO,CAAC,cAAc,CAAgB;IAEtC,2EAA2E;IAC3E,OAAO,CAAC,gBAAgB,CAAS;I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O,CAAC,uBAAuB;IAQxB,OAAO,CAAC,cAAc,CAAC,EAAE,cAAc;YAOhC,WAAW;IAyIzB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IActB;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAqCjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAwHpC;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;;;;;OAMG;YACW,SAAS;IA2ChB,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,GAAG,gBAAgB,GAAG,SAAS;IAmC3G,YAAY,CAAC,OAAO,EAAE,GAAG;IAQzB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE;IA4BzC,0BAA0B,CAAC,OAAO,EAAE,yBAAyB;IAuCpE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAGxB;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAmB1B;IAGF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAOxC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAK3B;CACL"}
|
|
@@ -94,7 +94,7 @@ class ConnectionManager {
|
|
|
94
94
|
this.pendingReconnect = false;
|
|
95
95
|
this.clientSequenceNumber = 0;
|
|
96
96
|
this.clientSequenceNumberObserved = 0;
|
|
97
|
-
/** Counts the number of
|
|
97
|
+
/** Counts the number of non-runtime ops sent by the client which may not be acked. */
|
|
98
98
|
this.localOpsToIgnore = 0;
|
|
99
99
|
this.connectFirstConnection = true;
|
|
100
100
|
this._connectionVerboseProps = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionManager.js","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAM9D,+DAAsF;AAOtF,qEAA2E;AAO3E,+DASsC;AACtC,+EAe8C;AAC9C,qE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AG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAW,CAAC;YAC/D,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE;gBAC5B,sCAAsC;gBACtC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,CAAC;gBAE5E,gGAAgG;gBAChG,sGAAsG;gBACtG,mGAAmG;gBACnG,mGAAmG;gBACnG,uFAAuF;gBACvF,mCAAmC;gBACnC,IAAI,CAAC,SAAS,CACV,MAAM,EAAE,iBAAiB;gBACzB,gBAAgB,CACnB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACd,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC/E,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;CA6CJ;AA70BD,8CA60BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport {\n IDisposable,\n ITelemetryLogger,\n ITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { assert, performance, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n IDeltaQueue,\n ReadOnlyInfo,\n IConnectionDetails,\n ICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport { GenericError, UsageError } from \"@fluidframework/container-utils\";\nimport {\n IAnyDriverError,\n IDocumentService,\n IDocumentDeltaConnection,\n IDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport {\n canRetryOnError,\n createWriteError,\n createGenericNetworkError,\n getRetryDelayFromError,\n waitForConnectedState,\n DeltaStreamConnectionForbiddenError,\n logNetworkFailure,\n isRuntimeMessage,\n} from \"@fluidframework/driver-utils\";\nimport {\n ConnectionMode,\n IClient,\n IClientConfiguration,\n IClientDetails,\n IDocumentMessage,\n INack,\n INackContent,\n ISequencedDocumentMessage,\n ISignalClient,\n ISignalMessage,\n ITokenClaims,\n MessageType,\n ScopeType,\n ISequencedDocumentSystemMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n TelemetryLogger,\n normalizeError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n ReconnectMode,\n IConnectionManager,\n IConnectionManagerFactoryArgs,\n} from \"./contracts\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport { SignalType } from \"./protocol\";\n\nconst MaxReconnectDelayInMs = 8000;\nconst InitialReconnectDelayInMs = 1000;\nconst DefaultChunkSize = 16 * 1024;\n\nconst fatalConnectErrorProp = { fatalConnectError: true };\n\nfunction getNackReconnectInfo(nackContent: INackContent) {\n const message = `Nack (${nackContent.type}): ${nackContent.message}`;\n const canRetry = nackContent.code !== 403;\n const retryAfterMs = nackContent.retryAfter !== undefined ? nackContent.retryAfter * 1000 : undefined;\n return createGenericNetworkError(\n message,\n { canRetry, retryAfterMs },\n { statusCode: nackContent.code, driverVersion: undefined });\n}\n\n/**\n * Implementation of IDocumentDeltaConnection that does not support submitting\n * or receiving ops. Used in storage-only mode.\n */\nconst clientNoDeltaStream: IClient = {\n mode: \"read\",\n details: { capabilities: { interactive: true } },\n permission: [],\n user: { id: \"storage-only client\" }, // we need some \"fake\" ID here.\n scopes: [],\n};\nconst clientIdNoDeltaStream: string = \"storage-only client\";\n\nclass NoDeltaStream\n extends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n implements IDocumentDeltaConnection, IDisposable {\n clientId = clientIdNoDeltaStream;\n claims: ITokenClaims = {\n scopes: [ScopeType.DocRead],\n } as any;\n mode: ConnectionMode = \"read\";\n existing: boolean = true;\n maxMessageSize: number = 0;\n version: string = \"\";\n initialMessages: ISequencedDocumentMessage[] = [];\n initialSignals: ISignalMessage[] = [];\n initialClients: ISignalClient[] = [{ client: clientNoDeltaStream, clientId: clientIdNoDeltaStream }];\n serviceConfiguration: IClientConfiguration = {\n maxMessageSize: 0,\n blockSize: 0,\n };\n checkpointSequenceNumber?: number | undefined = undefined;\n submit(messages: IDocumentMessage[]): void {\n this.emit(\"nack\", this.clientId, messages.map((operation) => {\n return {\n operation,\n content: { message: \"Cannot submit with storage-only connection\", code: 403 },\n };\n }));\n }\n submitSignal(message: any): void {\n this.emit(\"nack\", this.clientId, {\n operation: message,\n content: { message: \"Cannot submit signal with storage-only connection\", code: 403 },\n });\n }\n\n private _disposed = false;\n public get disposed() { return this._disposed; }\n public dispose() { this._disposed = true; }\n}\n\n/**\n * Interface to track the current in-progress connection attempt.\n */\ninterface IPendingConnection {\n /**\n * Used to cancel an in-progress connection attempt.\n */\n abort(): void;\n\n /**\n * Desired ConnectionMode of this in-progress connection attempt.\n */\n connectionMode: ConnectionMode;\n}\n\n/**\n * Implementation of IConnectionManager, used by Container class\n * Implements constant connectivity to relay service, by reconnecting in case of lost connection or error.\n * Exposes various controls to influence this process, including manual reconnects, forced read-only mode, etc.\n */\nexport class ConnectionManager implements IConnectionManager {\n /** Connection mode used when reconnecting on error or disconnect. */\n private readonly defaultReconnectionMode: ConnectionMode;\n\n /**\n * Tracks the current in-progress connection attempt. Undefined if there is none.\n * Note: Once the connection attempt fires and the code becomes asynchronous, its possible that a new connection\n * attempt was fired and this.pendingConnection was overwritten to reflect the new attempt.\n */\n private pendingConnection: IPendingConnection | undefined;\n private connection: IDocumentDeltaConnection | undefined;\n\n /** file ACL - whether user has only read-only access to a file */\n private _readonlyPermissions: boolean | undefined;\n\n /** tracks host requiring read-only mode. */\n private _forceReadonly = false;\n\n /**\n * Controls whether the DeltaManager will automatically reconnect to the delta stream after receiving a disconnect.\n */\n private _reconnectMode: ReconnectMode;\n\n /** True if there is pending (async) reconnection from \"read\" to \"write\" */\n private pendingReconnect = false;\n\n private clientSequenceNumber = 0;\n private clientSequenceNumberObserved = 0;\n /** Counts the number of noops sent by the client which may not be acked. */\n private localOpsToIgnore = 0;\n\n /** track clientId used last time when we sent any ops */\n private lastSubmittedClientId: string | undefined;\n\n private connectFirstConnection = true;\n\n private _connectionVerboseProps: Record<string, string | number> = {};\n\n private _connectionProps: ITelemetryProperties = {};\n\n private _disposed = false;\n\n private readonly _outbound: DeltaQueue<IDocumentMessage[]>;\n\n public get connectionVerboseProps() { return this._connectionVerboseProps; }\n\n public readonly clientDetails: IClientDetails;\n\n /**\n * The current connection mode, initially read.\n */\n public get connectionMode(): ConnectionMode {\n return this.connection?.mode ?? \"read\";\n }\n\n public get connected() { return this.connection !== undefined; }\n\n public get clientId() { return this.connection?.clientId; }\n /**\n * Automatic reconnecting enabled or disabled.\n * If set to Never, then reconnecting will never be allowed.\n */\n public get reconnectMode(): ReconnectMode {\n return this._reconnectMode;\n }\n\n public get maxMessageSize(): number {\n return this.connection?.serviceConfiguration?.maxMessageSize\n ?? DefaultChunkSize;\n }\n\n public get version(): string {\n if (this.connection === undefined) {\n throw new Error(\"Cannot check version without a connection\");\n }\n return this.connection.version;\n }\n\n public get serviceConfiguration(): IClientConfiguration | undefined {\n return this.connection?.serviceConfiguration;\n }\n\n public get scopes(): string[] | undefined {\n return this.connection?.claims.scopes;\n }\n\n public get outbound(): IDeltaQueue<IDocumentMessage[]> {\n return this._outbound;\n }\n\n /**\n * Returns set of props that can be logged in telemetry that provide some insights / statistics\n * about current or last connection (if there is no connection at the moment)\n */\n public get connectionProps(): ITelemetryProperties {\n return this.connection !== undefined\n ? this._connectionProps\n : {\n ...this._connectionProps,\n // Report how many ops this client sent in last disconnected session\n sentOps: this.clientSequenceNumber,\n };\n }\n\n public shouldJoinWrite(): boolean {\n // We don't have to wait for ack for topmost NoOps. So subtract those.\n return this.clientSequenceNumberObserved < (this.clientSequenceNumber - this.localOpsToIgnore);\n }\n\n /**\n * Tells if container is in read-only mode.\n * Data stores should listen for \"readonly\" notifications and disallow user\n * making changes to data stores.\n * Readonly state can be because of no storage write permission,\n * or due to host forcing readonly mode for container.\n * It is undefined if we have not yet established websocket connection\n * and do not know if user has write access to a file.\n */\n private get readonly(): boolean | undefined {\n if (this._forceReadonly) {\n return true;\n }\n return this._readonlyPermissions;\n }\n\n public get readOnlyInfo(): ReadOnlyInfo {\n const storageOnly = this.connection !== undefined && this.connection instanceof NoDeltaStream;\n if (storageOnly || this._forceReadonly || this._readonlyPermissions === true) {\n return {\n readonly: true,\n forced: this._forceReadonly,\n permissions: this._readonlyPermissions,\n storageOnly,\n };\n }\n\n return { readonly: this._readonlyPermissions };\n }\n\n private static detailsFromConnection(connection: IDocumentDeltaConnection): IConnectionDetails {\n return {\n claims: connection.claims,\n clientId: connection.clientId,\n existing: connection.existing,\n checkpointSequenceNumber: connection.checkpointSequenceNumber,\n get initialClients() { return connection.initialClients; },\n mode: connection.mode,\n serviceConfiguration: connection.serviceConfiguration,\n version: connection.version,\n };\n }\n\n constructor(\n private readonly serviceProvider: () => IDocumentService | undefined,\n private client: IClient,\n reconnectAllowed: boolean,\n private readonly logger: ITelemetryLogger,\n private readonly props: IConnectionManagerFactoryArgs,\n ) {\n this.clientDetails = this.client.details;\n this.defaultReconnectionMode = this.client.mode;\n this._reconnectMode = reconnectAllowed ? ReconnectMode.Enabled : ReconnectMode.Never;\n\n // Outbound message queue. The outbound queue is represented as a queue of an array of ops. Ops contained\n // within an array *must* fit within the maxMessageSize and are guaranteed to be ordered sequentially.\n this._outbound = new DeltaQueue<IDocumentMessage[]>(\n (messages) => {\n if (this.connection === undefined) {\n throw new Error(\"Attempted to submit an outbound message without connection\");\n }\n this.connection.submit(messages);\n });\n\n this._outbound.on(\"error\", (error) => {\n this.props.closeHandler(normalizeError(error));\n });\n }\n\n public dispose(error?: ICriticalContainerError, switchToReadonly: boolean = true) {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.pendingConnection = undefined;\n\n // Ensure that things like triggerConnect() will short circuit\n this._reconnectMode = ReconnectMode.Never;\n\n this._outbound.clear();\n\n const disconnectReason = error !== undefined\n ? `Closing DeltaManager (${error.message})`\n : \"Closing DeltaManager\";\n\n // This raises \"disconnect\" event if we have active connection.\n this.disconnectFromDeltaStream(disconnectReason);\n\n if (switchToReadonly) {\n // Notify everyone we are in read-only state.\n // Useful for data stores in case we hit some critical error,\n // to switch to a mode where user edits are not accepted\n this.set_readonlyPermissions(true);\n }\n }\n\n /**\n * Enables or disables automatic reconnecting.\n * Will throw an error if reconnectMode set to Never.\n */\n public setAutoReconnect(mode: ReconnectMode): void {\n assert(mode !== ReconnectMode.Never && this._reconnectMode !== ReconnectMode.Never,\n 0x278 /* \"API is not supported for non-connecting or closed container\" */);\n\n this._reconnectMode = mode;\n\n if (mode !== ReconnectMode.Enabled) {\n // immediately disconnect - do not rely on service eventually dropping connection.\n this.disconnectFromDeltaStream(\"setAutoReconnect\");\n }\n }\n\n /**\n * Sends signal to runtime (and data stores) to be read-only.\n * Hosts may have read only views, indicating to data stores that no edits are allowed.\n * This is independent from this._readonlyPermissions (permissions) and this.connectionMode\n * (server can return \"write\" mode even when asked for \"read\")\n * Leveraging same \"readonly\" event as runtime & data stores should behave the same in such case\n * as in read-only permissions.\n * But this.active can be used by some DDSes to figure out if ops can be sent\n * (for example, read-only view still participates in code proposals / upgrades decisions)\n *\n * Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour\n * the readonly flag. If ops are generated, they will accumulate locally and not be sent. If\n * there are pending in the outbound queue, it will stop sending until force readonly is\n * cleared.\n *\n * @param readonly - set or clear force readonly.\n */\n public forceReadonly(readonly: boolean) {\n if (readonly !== this._forceReadonly) {\n this.logger.sendTelemetryEvent({\n eventName: \"ForceReadOnly\",\n value: readonly,\n });\n }\n const oldValue = this.readonly;\n this._forceReadonly = readonly;\n\n if (oldValue !== this.readonly) {\n if (this._reconnectMode === ReconnectMode.Never) {\n throw new UsageError(\"API is not supported for non-connecting or closed container\");\n }\n let reconnect = false;\n if (this.readonly === true) {\n // If we switch to readonly while connected, we should disconnect first\n // See comment in the \"readonly\" event handler to deltaManager set up by\n // the ContainerRuntime constructor\n\n if (this.shouldJoinWrite()) {\n // If we have pending changes, then we will never send them - it smells like\n // host logic error.\n this.logger.sendErrorEvent({ eventName: \"ForceReadonlyPendingChanged\" });\n }\n\n reconnect = this.disconnectFromDeltaStream(\"Force readonly\");\n }\n this.props.readonlyChangeHandler(this.readonly);\n if (reconnect) {\n // reconnect if we disconnected from before.\n this.triggerConnect(\"read\");\n }\n }\n }\n\n private set_readonlyPermissions(readonly: boolean) {\n const oldValue = this.readonly;\n this._readonlyPermissions = readonly;\n if (oldValue !== this.readonly) {\n this.props.readonlyChangeHandler(this.readonly);\n }\n }\n\n public connect(connectionMode?: ConnectionMode) {\n this.connectCore(connectionMode).catch((error) => {\n const normalizedError = normalizeError(error, { props: fatalConnectErrorProp });\n this.props.closeHandler(normalizedError);\n });\n }\n\n private async connectCore(connectionMode?: ConnectionMode): Promise<void> {\n assert(!this._disposed, 0x26a /* \"not closed\" */);\n\n if (this.connection !== undefined) {\n return; // Connection attempt already completed successfully\n }\n\n let pendingConnectionMode;\n if (this.pendingConnection !== undefined) {\n pendingConnectionMode = this.pendingConnection.connectionMode;\n this.cancelConnection(); // Throw out in-progress connection attempt in favor of new attempt\n assert(this.pendingConnection === undefined, 0x344 /* this.pendingConnection should be undefined */);\n }\n // If there is no specified ConnectionMode, try the previous mode, if there is no previous mode use default\n let requestedMode = connectionMode ?? pendingConnectionMode ?? this.defaultReconnectionMode;\n\n // if we have any non-acked ops from last connection, reconnect as \"write\".\n // without that we would connect in view-only mode, which will result in immediate\n // firing of \"connected\" event from Container and switch of current clientId (as tracked\n // by all DDSes). This will make it impossible to figure out if ops actually made it through,\n // so DDSes will immediately resubmit all pending ops, and some of them will be duplicates, corrupting document\n if (this.shouldJoinWrite()) {\n requestedMode = \"write\";\n }\n\n const docService = this.serviceProvider();\n assert(docService !== undefined, 0x2a7 /* \"Container is not attached\" */);\n\n let connection: IDocumentDeltaConnection | undefined;\n\n if (docService.policies?.storageOnly === true) {\n connection = new NoDeltaStream();\n this.setupNewSuccessfulConnection(connection, \"read\");\n assert(this.pendingConnection === undefined, 0x2b3 /* \"logic error\" */);\n return;\n }\n\n let delayMs = InitialReconnectDelayInMs;\n let connectRepeatCount = 0;\n const connectStartTime = performance.now();\n let lastError: any;\n\n const abortController = new AbortController();\n const abortSignal = abortController.signal;\n this.pendingConnection = { abort: () => { abortController.abort(); }, connectionMode: requestedMode };\n\n // This loop will keep trying to connect until successful, with a delay between each iteration.\n while (connection === undefined) {\n if (this._disposed) {\n throw new Error(\"Attempting to connect a closed DeltaManager\");\n }\n if (abortSignal.aborted === true) {\n this.logger.sendTelemetryEvent({\n eventName: \"ConnectionAttemptCancelled\",\n attempts: connectRepeatCount,\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n connectionEstablished: false,\n });\n return;\n }\n connectRepeatCount++;\n\n try {\n this.client.mode = requestedMode;\n connection = await docService.connectToDeltaStream({ ...this.client, mode: requestedMode });\n\n if (connection.disposed) {\n // Nobody observed this connection, so drop it on the floor and retry.\n this.logger.sendTelemetryEvent({ eventName: \"ReceivedClosedConnection\" });\n connection = undefined;\n }\n } catch (origError: any) {\n if (typeof origError === \"object\" && origError !== null &&\n origError?.errorType === DeltaStreamConnectionForbiddenError.errorType) {\n connection = new NoDeltaStream();\n requestedMode = \"read\";\n break;\n }\n\n // Socket.io error when we connect to wrong socket, or hit some multiplexing bug\n if (!canRetryOnError(origError)) {\n const error = normalizeError(origError, { props: fatalConnectErrorProp });\n this.props.closeHandler(error);\n throw error;\n }\n\n // Since the error is retryable this will not log to the error table\n logNetworkFailure(\n this.logger,\n {\n attempts: connectRepeatCount,\n delay: delayMs, // milliseconds\n eventName: \"DeltaConnectionFailureToConnect\",\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n },\n origError);\n\n lastError = origError;\n\n const retryDelayFromError = getRetryDelayFromError(origError);\n delayMs = retryDelayFromError ?? Math.min(delayMs * 2, MaxReconnectDelayInMs);\n\n if (retryDelayFromError !== undefined) {\n this.props.reconnectionDelayHandler(retryDelayFromError, origError);\n }\n await waitForConnectedState(delayMs);\n }\n }\n\n // If we retried more than once, log an event about how long it took (this will not log to error table)\n if (connectRepeatCount > 1) {\n logNetworkFailure(\n this.logger,\n {\n eventName: \"MultipleDeltaConnectionFailures\",\n attempts: connectRepeatCount,\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n },\n lastError,\n );\n }\n\n // Check for abort signal after while loop as well\n if (abortSignal.aborted === true) {\n connection.dispose();\n this.logger.sendTelemetryEvent({\n eventName: \"ConnectionAttemptCancelled\",\n attempts: connectRepeatCount,\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n connectionEstablished: true,\n });\n return;\n }\n\n this.setupNewSuccessfulConnection(connection, requestedMode);\n }\n\n /**\n * Start the connection. Any error should result in container being closed.\n * And report the error if it escapes for any reason.\n * @param args - The connection arguments\n */\n private triggerConnect(connectionMode: ConnectionMode) {\n // reconnect() has async await of waitForConnectedState(), and that causes potential race conditions\n // where we might already have a connection. If it were to happen, it's possible that we will connect\n // with different mode to `connectionMode`. Glancing through the caller chains, it looks like code should be\n // fine (if needed, reconnect flow will get triggered again). Places where new mode matters should encode it\n // directly in connectCore - see this.shouldJoinWrite() test as an example.\n // assert(this.connection === undefined, 0x239 /* \"called only in disconnected state\" */);\n\n if (this.reconnectMode !== ReconnectMode.Enabled) {\n return;\n }\n this.connect(connectionMode);\n }\n\n /**\n * Disconnect the current connection.\n * @param reason - Text description of disconnect reason to emit with disconnect event\n * @returns A boolean that indicates if there was an existing connection (or pending connection) to disconnect\n */\n private disconnectFromDeltaStream(reason: string): boolean {\n this.pendingReconnect = false;\n\n if (this.connection === undefined) {\n if (this.pendingConnection !== undefined) {\n this.cancelConnection();\n return true;\n }\n return false;\n }\n\n assert(this.pendingConnection === undefined, 0x27b /* \"reentrancy may result in incorrect behavior\" */);\n\n const connection = this.connection;\n // Avoid any re-entrancy - clear object reference\n this.connection = undefined;\n\n // Remove listeners first so we don't try to retrigger this flow accidentally through reconnectOnError\n connection.off(\"op\", this.opHandler);\n connection.off(\"signal\", this.props.signalHandler);\n connection.off(\"nack\", this.nackHandler);\n connection.off(\"disconnect\", this.disconnectHandlerInternal);\n connection.off(\"error\", this.errorHandler);\n connection.off(\"pong\", this.props.pongHandler);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._outbound.pause();\n this._outbound.clear();\n this.props.disconnectHandler(reason);\n\n connection.dispose();\n\n this._connectionVerboseProps = {};\n\n return true;\n }\n\n /**\n * Cancel in-progress connection attempt.\n */\n private cancelConnection() {\n assert(this.pendingConnection !== undefined,\n 0x345 /* this.pendingConnection is undefined when trying to cancel */);\n this.pendingConnection.abort();\n this.pendingConnection = undefined;\n this.logger.sendTelemetryEvent({ eventName: \"ConnectionCancelReceived\" });\n }\n\n /**\n * Once we've successfully gotten a connection, we need to set up state, attach event listeners, and process\n * initial messages.\n * @param connection - The newly established connection\n */\n private setupNewSuccessfulConnection(connection: IDocumentDeltaConnection, requestedMode: ConnectionMode) {\n // Old connection should have been cleaned up before establishing a new one\n assert(this.connection === undefined, 0x0e6 /* \"old connection exists on new connection setup\" */);\n assert(!connection.disposed, 0x28a /* \"can't be disposed - Callers need to ensure that!\" */);\n\n this.pendingConnection = undefined;\n\n this.connection = connection;\n\n // Does information in scopes & mode matches?\n // If we asked for \"write\" and got \"read\", then file is read-only\n // But if we ask read, server can still give us write.\n const readonly = !connection.claims.scopes.includes(ScopeType.DocWrite);\n\n if (connection.mode !== requestedMode) {\n this.logger.sendTelemetryEvent({ eventName: \"ConnectionModeMismatch\", requestedMode, mode: connection.mode });\n }\n // This connection mode validation logic is moving to the driver layer in 0.44. These two asserts can be\n // removed after those packages have released and become ubiquitous.\n assert(requestedMode === \"read\" || readonly === (this.connectionMode === \"read\"),\n 0x0e7 /* \"claims/connectionMode mismatch\" */);\n assert(!readonly || this.connectionMode === \"read\", 0x0e8 /* \"readonly perf with write connection\" */);\n\n this.set_readonlyPermissions(readonly);\n\n if (this._disposed) {\n // Raise proper events, Log telemetry event and close connection.\n this.disconnectFromDeltaStream(\"ConnectionManager already closed\");\n return;\n }\n\n this._outbound.resume();\n\n connection.on(\"op\", this.opHandler);\n connection.on(\"signal\", this.props.signalHandler);\n connection.on(\"nack\", this.nackHandler);\n connection.on(\"disconnect\", this.disconnectHandlerInternal);\n connection.on(\"error\", this.errorHandler);\n connection.on(\"pong\", this.props.pongHandler);\n\n // Initial messages are always sorted. However, due to early op handler installed by drivers and appending those\n // ops to initialMessages, resulting set is no longer sorted, which would result in client hitting storage to\n // fill in gap. We will recover by cancelling this request once we process remaining ops, but it's a waste that\n // we could avoid\n const initialMessages = connection.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\n // Some storages may provide checkpointSequenceNumber to identify how far client is behind.\n let checkpointSequenceNumber = connection.checkpointSequenceNumber;\n\n this._connectionVerboseProps = {\n clientId: connection.clientId,\n mode: connection.mode,\n };\n\n // reset connection props\n this._connectionProps = {};\n\n if (connection.relayServiceAgent !== undefined) {\n this._connectionVerboseProps.relayServiceAgent = connection.relayServiceAgent;\n this._connectionProps.relayServiceAgent = connection.relayServiceAgent;\n }\n this._connectionProps.socketDocumentId = connection.claims.documentId;\n this._connectionProps.connectionMode = connection.mode;\n\n let last = -1;\n if (initialMessages.length !== 0) {\n this._connectionVerboseProps.connectionInitialOpsFrom = initialMessages[0].sequenceNumber;\n last = initialMessages[initialMessages.length - 1].sequenceNumber;\n this._connectionVerboseProps.connectionInitialOpsTo = last + 1;\n // Update knowledge of how far we are behind, before raising \"connect\" event\n // This is duplication of what incomingOpHandler() does, but we have to raise event before we get there,\n // so duplicating update logic here as well.\n if (checkpointSequenceNumber === undefined || checkpointSequenceNumber < last) {\n checkpointSequenceNumber = last;\n }\n }\n\n this.props.incomingOpHandler(\n initialMessages,\n this.connectFirstConnection ? \"InitialOps\" : \"ReconnectOps\");\n\n const details = ConnectionManager.detailsFromConnection(connection);\n details.checkpointSequenceNumber = checkpointSequenceNumber;\n this.props.connectHandler(details);\n\n this.connectFirstConnection = false;\n\n // Synthesize clear & join signals out of initialClients state.\n // This allows us to have single way to process signals, and makes it simpler to initialize\n // protocol in Container.\n const clearSignal: ISignalMessage = {\n clientId: null, // system message\n content: JSON.stringify({\n type: SignalType.Clear,\n }),\n };\n this.props.signalHandler(clearSignal);\n\n for (const priorClient of connection.initialClients ?? []) {\n const joinSignal: ISignalMessage = {\n clientId: null, // system signal\n content: JSON.stringify({\n type: SignalType.ClientJoin,\n content: priorClient, // ISignalClient\n }),\n };\n this.props.signalHandler(joinSignal);\n }\n\n // Unfortunately, there is no defined order between initialSignals (including join & leave signals)\n // and connection.initialClients. In practice, connection.initialSignals quite often contains join signal\n // for \"self\" and connection.initialClients does not contain \"self\", so we have to process them after\n // \"clear\" signal above.\n if (connection.initialSignals !== undefined) {\n for (const signal of connection.initialSignals) {\n this.props.signalHandler(signal);\n }\n }\n }\n\n /**\n * Disconnect the current connection and reconnect. Closes the container if it fails.\n * @param connection - The connection that wants to reconnect - no-op if it's different from this.connection\n * @param requestedMode - Read or write\n * @param error - Error reconnect information including whether or not to reconnect\n * @returns A promise that resolves when the connection is reestablished or we stop trying\n */\n private reconnectOnError(\n requestedMode: ConnectionMode,\n error: IAnyDriverError,\n ) {\n this.reconnect(\n requestedMode,\n error.message,\n error)\n .catch(this.props.closeHandler);\n }\n\n /**\n * Disconnect the current connection and reconnect.\n * @param connection - The connection that wants to reconnect - no-op if it's different from this.connection\n * @param requestedMode - Read or write\n * @param error - Error reconnect information including whether or not to reconnect\n * @returns A promise that resolves when the connection is reestablished or we stop trying\n */\n private async reconnect(\n requestedMode: ConnectionMode,\n disconnectMessage: string,\n error?: IAnyDriverError,\n ) {\n // We quite often get protocol errors before / after observing nack/disconnect\n // we do not want to run through same sequence twice.\n // If we're already disconnected/disconnecting it's not appropriate to call this again.\n assert(this.connection !== undefined, 0x0eb /* \"Missing connection for reconnect\" */);\n\n this.disconnectFromDeltaStream(disconnectMessage);\n\n // We will always trigger reconnect, even if canRetry is false.\n // Any truly fatal error state will result in container close upon attempted reconnect,\n // which is a preferable to closing abruptly when a live connection fails.\n if (error !== undefined && !error.canRetry) {\n this.logger.sendTelemetryEvent({\n eventName: \"reconnectingDespiteFatalError\",\n reconnectMode: this.reconnectMode,\n }, error);\n }\n\n if (this.reconnectMode === ReconnectMode.Never) {\n // Do not raise container error if we are closing just because we lost connection.\n // Those errors (like IdleDisconnect) would show up in telemetry dashboards and\n // are very misleading, as first initial reaction - some logic is broken.\n this.props.closeHandler();\n }\n\n // If closed then we can't reconnect\n if (this._disposed || this.reconnectMode !== ReconnectMode.Enabled) {\n return;\n }\n\n const delayMs = getRetryDelayFromError(error);\n if (error !== undefined && delayMs !== undefined) {\n this.props.reconnectionDelayHandler(delayMs, error);\n await waitForConnectedState(delayMs);\n }\n\n this.triggerConnect(requestedMode);\n }\n\n public prepareMessageToSend(message: Omit<IDocumentMessage, \"clientSequenceNumber\">): IDocumentMessage | undefined {\n if (this.readonly === true) {\n assert(this.readOnlyInfo.readonly === true, 0x1f0 /* \"Unexpected mismatch in readonly\" */);\n const error = new GenericError(\"deltaManagerReadonlySubmit\", undefined /* error */, {\n readonly: this.readOnlyInfo.readonly,\n forcedReadonly: this.readOnlyInfo.forced,\n readonlyPermissions: this.readOnlyInfo.permissions,\n storageOnly: this.readOnlyInfo.storageOnly,\n });\n this.props.closeHandler(error);\n return undefined;\n }\n\n // reset clientSequenceNumber if we are using new clientId.\n // we keep info about old connection as long as possible to be able to account for all non-acked ops\n // that we pick up on next connection.\n assert(!!this.connection, 0x0e4 /* \"Lost old connection!\" */);\n if (this.lastSubmittedClientId !== this.connection?.clientId) {\n this.lastSubmittedClientId = this.connection?.clientId;\n this.clientSequenceNumber = 0;\n this.clientSequenceNumberObserved = 0;\n }\n\n if (!isRuntimeMessage(message)) {\n this.localOpsToIgnore++;\n } else {\n this.localOpsToIgnore = 0;\n }\n\n return {\n ...message,\n clientSequenceNumber: ++this.clientSequenceNumber,\n };\n }\n\n public submitSignal(content: any) {\n if (this.connection !== undefined) {\n this.connection.submitSignal(content);\n } else {\n this.logger.sendErrorEvent({ eventName: \"submitSignalDisconnected\" });\n }\n }\n\n public sendMessages(messages: IDocumentMessage[]) {\n assert(this.connected, 0x2b4 /* \"not connected on sending ops!\" */);\n // If connection is \"read\" or implicit \"read\" (got leave op for \"write\" connection),\n // then op can't make it through - we will get a nack if op is sent.\n // We can short-circuit this process.\n // Note that we also want nacks to be rare and be treated as catastrophic failures.\n // Be careful with reentrancy though - disconnected event should not be be raised in the\n // middle of the current workflow, but rather on clean stack!\n if (this.connectionMode === \"read\") {\n if (!this.pendingReconnect) {\n this.pendingReconnect = true;\n Promise.resolve().then(async () => {\n if (this.pendingReconnect) { // still valid?\n await this.reconnect(\n \"write\", // connectionMode\n \"Switch to write\", // message\n );\n }\n }).catch(() => { });\n }\n return;\n }\n\n assert(!this.pendingReconnect, 0x2b5 /* \"logic error\" */);\n\n this._outbound.push(messages);\n }\n\n public beforeProcessingIncomingOp(message: ISequencedDocumentMessage) {\n // if we have connection, and message is local, then we better treat is as local!\n assert(this.clientId !== message.clientId || this.lastSubmittedClientId === message.clientId,\n 0x0ee /* \"Not accounting local messages correctly\" */,\n );\n\n if (this.lastSubmittedClientId !== undefined && this.lastSubmittedClientId === message.clientId) {\n const clientSequenceNumber = message.clientSequenceNumber;\n\n assert(this.clientSequenceNumberObserved < clientSequenceNumber, 0x0ef /* \"client seq# not growing\" */);\n assert(clientSequenceNumber <= this.clientSequenceNumber,\n 0x0f0 /* \"Incoming local client seq# > generated by this client\" */);\n\n this.clientSequenceNumberObserved = clientSequenceNumber;\n }\n\n if (message.type === MessageType.ClientLeave) {\n const systemLeaveMessage = message as ISequencedDocumentSystemMessage;\n const clientId = JSON.parse(systemLeaveMessage.data) as string;\n if (clientId === this.clientId) {\n // We have been kicked out from quorum\n this.logger.sendPerformanceEvent({ eventName: \"ReadConnectionTransition\" });\n\n // Please see #8483 for more details on why maintaining connection further as is would not work.\n // Short story - connection properties are immutable, and many processes (consensus DDSes, summarizer)\n // assume that connection stays \"write\" connection until disconnect, and act accordingly, which may\n // not work well with de-facto \"read\" connection we are in after receiving own leave op on timeout.\n // Clients need to be able to transition to \"read\" state after some time of inactivity!\n // Note - this may close container!\n this.reconnect(\n \"read\", // connectionMode\n \"Switch to read\", // message\n ).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"SwitchToReadConnection\" }, error);\n });\n }\n }\n }\n\n private readonly opHandler = (documentId: string, messagesArg: ISequencedDocumentMessage[]) => {\n const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];\n this.props.incomingOpHandler(messages, \"opHandler\");\n };\n\n // Always connect in write mode after getting nacked.\n private readonly nackHandler = (documentId: string, messages: INack[]) => {\n const message = messages[0];\n if (this._readonlyPermissions === true) {\n this.props.closeHandler(createWriteError(\"writeOnReadOnlyDocument\", { driverVersion: undefined }));\n return;\n }\n\n const reconnectInfo = getNackReconnectInfo(message.content);\n\n // If the nack indicates we cannot retry, then close the container outright\n if (!reconnectInfo.canRetry) {\n this.props.closeHandler(reconnectInfo);\n return;\n }\n\n this.reconnectOnError(\n \"write\",\n reconnectInfo,\n );\n };\n\n // Connection mode is always read on disconnect/error unless the system mode was write.\n private readonly disconnectHandlerInternal = (disconnectReason: IAnyDriverError) => {\n // Note: we might get multiple disconnect calls on same socket, as early disconnect notification\n // (\"server_disconnect\", ODSP-specific) is mapped to \"disconnect\"\n this.reconnectOnError(\n this.defaultReconnectionMode,\n disconnectReason,\n );\n };\n\n private readonly errorHandler = (error: IAnyDriverError) => {\n this.reconnectOnError(\n this.defaultReconnectionMode,\n error,\n );\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connectionManager.js","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAM9D,+DAAsF;AAOtF,qEAA2E;AAO3E,+DASsC;AACtC,+EAe8C;AAC9C,qEAGyC;AACzC,2CAIqB;AACrB,6CAA0C;AAC1C,yCAAwC;AAExC,MA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C;YAC/D,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE;gBAC5B,sCAAsC;gBACtC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,CAAC;gBAE5E,gGAAgG;gBAChG,sGAAsG;gBACtG,mGAAmG;gBACnG,mGAAmG;gBACnG,uFAAuF;gBACvF,mCAAmC;gBACnC,IAAI,CAAC,SAAS,CACV,MAAM,EAAE,iBAAiB;gBACzB,gBAAgB,CACnB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACd,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC/E,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;CA6CJ;AA70BD,8CA60BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport {\n IDisposable,\n ITelemetryLogger,\n ITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { assert, performance, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n IDeltaQueue,\n ReadOnlyInfo,\n IConnectionDetails,\n ICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport { GenericError, UsageError } from \"@fluidframework/container-utils\";\nimport {\n IAnyDriverError,\n IDocumentService,\n IDocumentDeltaConnection,\n IDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport {\n canRetryOnError,\n createWriteError,\n createGenericNetworkError,\n getRetryDelayFromError,\n waitForConnectedState,\n DeltaStreamConnectionForbiddenError,\n logNetworkFailure,\n isRuntimeMessage,\n} from \"@fluidframework/driver-utils\";\nimport {\n ConnectionMode,\n IClient,\n IClientConfiguration,\n IClientDetails,\n IDocumentMessage,\n INack,\n INackContent,\n ISequencedDocumentMessage,\n ISignalClient,\n ISignalMessage,\n ITokenClaims,\n MessageType,\n ScopeType,\n ISequencedDocumentSystemMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n TelemetryLogger,\n normalizeError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n ReconnectMode,\n IConnectionManager,\n IConnectionManagerFactoryArgs,\n} from \"./contracts\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport { SignalType } from \"./protocol\";\n\nconst MaxReconnectDelayInMs = 8000;\nconst InitialReconnectDelayInMs = 1000;\nconst DefaultChunkSize = 16 * 1024;\n\nconst fatalConnectErrorProp = { fatalConnectError: true };\n\nfunction getNackReconnectInfo(nackContent: INackContent) {\n const message = `Nack (${nackContent.type}): ${nackContent.message}`;\n const canRetry = nackContent.code !== 403;\n const retryAfterMs = nackContent.retryAfter !== undefined ? nackContent.retryAfter * 1000 : undefined;\n return createGenericNetworkError(\n message,\n { canRetry, retryAfterMs },\n { statusCode: nackContent.code, driverVersion: undefined });\n}\n\n/**\n * Implementation of IDocumentDeltaConnection that does not support submitting\n * or receiving ops. Used in storage-only mode.\n */\nconst clientNoDeltaStream: IClient = {\n mode: \"read\",\n details: { capabilities: { interactive: true } },\n permission: [],\n user: { id: \"storage-only client\" }, // we need some \"fake\" ID here.\n scopes: [],\n};\nconst clientIdNoDeltaStream: string = \"storage-only client\";\n\nclass NoDeltaStream\n extends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n implements IDocumentDeltaConnection, IDisposable {\n clientId = clientIdNoDeltaStream;\n claims: ITokenClaims = {\n scopes: [ScopeType.DocRead],\n } as any;\n mode: ConnectionMode = \"read\";\n existing: boolean = true;\n maxMessageSize: number = 0;\n version: string = \"\";\n initialMessages: ISequencedDocumentMessage[] = [];\n initialSignals: ISignalMessage[] = [];\n initialClients: ISignalClient[] = [{ client: clientNoDeltaStream, clientId: clientIdNoDeltaStream }];\n serviceConfiguration: IClientConfiguration = {\n maxMessageSize: 0,\n blockSize: 0,\n };\n checkpointSequenceNumber?: number | undefined = undefined;\n submit(messages: IDocumentMessage[]): void {\n this.emit(\"nack\", this.clientId, messages.map((operation) => {\n return {\n operation,\n content: { message: \"Cannot submit with storage-only connection\", code: 403 },\n };\n }));\n }\n submitSignal(message: any): void {\n this.emit(\"nack\", this.clientId, {\n operation: message,\n content: { message: \"Cannot submit signal with storage-only connection\", code: 403 },\n });\n }\n\n private _disposed = false;\n public get disposed() { return this._disposed; }\n public dispose() { this._disposed = true; }\n}\n\n/**\n * Interface to track the current in-progress connection attempt.\n */\ninterface IPendingConnection {\n /**\n * Used to cancel an in-progress connection attempt.\n */\n abort(): void;\n\n /**\n * Desired ConnectionMode of this in-progress connection attempt.\n */\n connectionMode: ConnectionMode;\n}\n\n/**\n * Implementation of IConnectionManager, used by Container class\n * Implements constant connectivity to relay service, by reconnecting in case of lost connection or error.\n * Exposes various controls to influence this process, including manual reconnects, forced read-only mode, etc.\n */\nexport class ConnectionManager implements IConnectionManager {\n /** Connection mode used when reconnecting on error or disconnect. */\n private readonly defaultReconnectionMode: ConnectionMode;\n\n /**\n * Tracks the current in-progress connection attempt. Undefined if there is none.\n * Note: Once the connection attempt fires and the code becomes asynchronous, its possible that a new connection\n * attempt was fired and this.pendingConnection was overwritten to reflect the new attempt.\n */\n private pendingConnection: IPendingConnection | undefined;\n private connection: IDocumentDeltaConnection | undefined;\n\n /** file ACL - whether user has only read-only access to a file */\n private _readonlyPermissions: boolean | undefined;\n\n /** tracks host requiring read-only mode. */\n private _forceReadonly = false;\n\n /**\n * Controls whether the DeltaManager will automatically reconnect to the delta stream after receiving a disconnect.\n */\n private _reconnectMode: ReconnectMode;\n\n /** True if there is pending (async) reconnection from \"read\" to \"write\" */\n private pendingReconnect = false;\n\n private clientSequenceNumber = 0;\n private clientSequenceNumberObserved = 0;\n /** Counts the number of non-runtime ops sent by the client which may not be acked. */\n private localOpsToIgnore = 0;\n\n /** track clientId used last time when we sent any ops */\n private lastSubmittedClientId: string | undefined;\n\n private connectFirstConnection = true;\n\n private _connectionVerboseProps: Record<string, string | number> = {};\n\n private _connectionProps: ITelemetryProperties = {};\n\n private _disposed = false;\n\n private readonly _outbound: DeltaQueue<IDocumentMessage[]>;\n\n public get connectionVerboseProps() { return this._connectionVerboseProps; }\n\n public readonly clientDetails: IClientDetails;\n\n /**\n * The current connection mode, initially read.\n */\n public get connectionMode(): ConnectionMode {\n return this.connection?.mode ?? \"read\";\n }\n\n public get connected() { return this.connection !== undefined; }\n\n public get clientId() { return this.connection?.clientId; }\n /**\n * Automatic reconnecting enabled or disabled.\n * If set to Never, then reconnecting will never be allowed.\n */\n public get reconnectMode(): ReconnectMode {\n return this._reconnectMode;\n }\n\n public get maxMessageSize(): number {\n return this.connection?.serviceConfiguration?.maxMessageSize\n ?? DefaultChunkSize;\n }\n\n public get version(): string {\n if (this.connection === undefined) {\n throw new Error(\"Cannot check version without a connection\");\n }\n return this.connection.version;\n }\n\n public get serviceConfiguration(): IClientConfiguration | undefined {\n return this.connection?.serviceConfiguration;\n }\n\n public get scopes(): string[] | undefined {\n return this.connection?.claims.scopes;\n }\n\n public get outbound(): IDeltaQueue<IDocumentMessage[]> {\n return this._outbound;\n }\n\n /**\n * Returns set of props that can be logged in telemetry that provide some insights / statistics\n * about current or last connection (if there is no connection at the moment)\n */\n public get connectionProps(): ITelemetryProperties {\n return this.connection !== undefined\n ? this._connectionProps\n : {\n ...this._connectionProps,\n // Report how many ops this client sent in last disconnected session\n sentOps: this.clientSequenceNumber,\n };\n }\n\n public shouldJoinWrite(): boolean {\n // We don't have to wait for ack for topmost NoOps. So subtract those.\n return this.clientSequenceNumberObserved < (this.clientSequenceNumber - this.localOpsToIgnore);\n }\n\n /**\n * Tells if container is in read-only mode.\n * Data stores should listen for \"readonly\" notifications and disallow user\n * making changes to data stores.\n * Readonly state can be because of no storage write permission,\n * or due to host forcing readonly mode for container.\n * It is undefined if we have not yet established websocket connection\n * and do not know if user has write access to a file.\n */\n private get readonly(): boolean | undefined {\n if (this._forceReadonly) {\n return true;\n }\n return this._readonlyPermissions;\n }\n\n public get readOnlyInfo(): ReadOnlyInfo {\n const storageOnly = this.connection !== undefined && this.connection instanceof NoDeltaStream;\n if (storageOnly || this._forceReadonly || this._readonlyPermissions === true) {\n return {\n readonly: true,\n forced: this._forceReadonly,\n permissions: this._readonlyPermissions,\n storageOnly,\n };\n }\n\n return { readonly: this._readonlyPermissions };\n }\n\n private static detailsFromConnection(connection: IDocumentDeltaConnection): IConnectionDetails {\n return {\n claims: connection.claims,\n clientId: connection.clientId,\n existing: connection.existing,\n checkpointSequenceNumber: connection.checkpointSequenceNumber,\n get initialClients() { return connection.initialClients; },\n mode: connection.mode,\n serviceConfiguration: connection.serviceConfiguration,\n version: connection.version,\n };\n }\n\n constructor(\n private readonly serviceProvider: () => IDocumentService | undefined,\n private client: IClient,\n reconnectAllowed: boolean,\n private readonly logger: ITelemetryLogger,\n private readonly props: IConnectionManagerFactoryArgs,\n ) {\n this.clientDetails = this.client.details;\n this.defaultReconnectionMode = this.client.mode;\n this._reconnectMode = reconnectAllowed ? ReconnectMode.Enabled : ReconnectMode.Never;\n\n // Outbound message queue. The outbound queue is represented as a queue of an array of ops. Ops contained\n // within an array *must* fit within the maxMessageSize and are guaranteed to be ordered sequentially.\n this._outbound = new DeltaQueue<IDocumentMessage[]>(\n (messages) => {\n if (this.connection === undefined) {\n throw new Error(\"Attempted to submit an outbound message without connection\");\n }\n this.connection.submit(messages);\n });\n\n this._outbound.on(\"error\", (error) => {\n this.props.closeHandler(normalizeError(error));\n });\n }\n\n public dispose(error?: ICriticalContainerError, switchToReadonly: boolean = true) {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.pendingConnection = undefined;\n\n // Ensure that things like triggerConnect() will short circuit\n this._reconnectMode = ReconnectMode.Never;\n\n this._outbound.clear();\n\n const disconnectReason = error !== undefined\n ? `Closing DeltaManager (${error.message})`\n : \"Closing DeltaManager\";\n\n // This raises \"disconnect\" event if we have active connection.\n this.disconnectFromDeltaStream(disconnectReason);\n\n if (switchToReadonly) {\n // Notify everyone we are in read-only state.\n // Useful for data stores in case we hit some critical error,\n // to switch to a mode where user edits are not accepted\n this.set_readonlyPermissions(true);\n }\n }\n\n /**\n * Enables or disables automatic reconnecting.\n * Will throw an error if reconnectMode set to Never.\n */\n public setAutoReconnect(mode: ReconnectMode): void {\n assert(mode !== ReconnectMode.Never && this._reconnectMode !== ReconnectMode.Never,\n 0x278 /* \"API is not supported for non-connecting or closed container\" */);\n\n this._reconnectMode = mode;\n\n if (mode !== ReconnectMode.Enabled) {\n // immediately disconnect - do not rely on service eventually dropping connection.\n this.disconnectFromDeltaStream(\"setAutoReconnect\");\n }\n }\n\n /**\n * Sends signal to runtime (and data stores) to be read-only.\n * Hosts may have read only views, indicating to data stores that no edits are allowed.\n * This is independent from this._readonlyPermissions (permissions) and this.connectionMode\n * (server can return \"write\" mode even when asked for \"read\")\n * Leveraging same \"readonly\" event as runtime & data stores should behave the same in such case\n * as in read-only permissions.\n * But this.active can be used by some DDSes to figure out if ops can be sent\n * (for example, read-only view still participates in code proposals / upgrades decisions)\n *\n * Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour\n * the readonly flag. If ops are generated, they will accumulate locally and not be sent. If\n * there are pending in the outbound queue, it will stop sending until force readonly is\n * cleared.\n *\n * @param readonly - set or clear force readonly.\n */\n public forceReadonly(readonly: boolean) {\n if (readonly !== this._forceReadonly) {\n this.logger.sendTelemetryEvent({\n eventName: \"ForceReadOnly\",\n value: readonly,\n });\n }\n const oldValue = this.readonly;\n this._forceReadonly = readonly;\n\n if (oldValue !== this.readonly) {\n if (this._reconnectMode === ReconnectMode.Never) {\n throw new UsageError(\"API is not supported for non-connecting or closed container\");\n }\n let reconnect = false;\n if (this.readonly === true) {\n // If we switch to readonly while connected, we should disconnect first\n // See comment in the \"readonly\" event handler to deltaManager set up by\n // the ContainerRuntime constructor\n\n if (this.shouldJoinWrite()) {\n // If we have pending changes, then we will never send them - it smells like\n // host logic error.\n this.logger.sendErrorEvent({ eventName: \"ForceReadonlyPendingChanged\" });\n }\n\n reconnect = this.disconnectFromDeltaStream(\"Force readonly\");\n }\n this.props.readonlyChangeHandler(this.readonly);\n if (reconnect) {\n // reconnect if we disconnected from before.\n this.triggerConnect(\"read\");\n }\n }\n }\n\n private set_readonlyPermissions(readonly: boolean) {\n const oldValue = this.readonly;\n this._readonlyPermissions = readonly;\n if (oldValue !== this.readonly) {\n this.props.readonlyChangeHandler(this.readonly);\n }\n }\n\n public connect(connectionMode?: ConnectionMode) {\n this.connectCore(connectionMode).catch((error) => {\n const normalizedError = normalizeError(error, { props: fatalConnectErrorProp });\n this.props.closeHandler(normalizedError);\n });\n }\n\n private async connectCore(connectionMode?: ConnectionMode): Promise<void> {\n assert(!this._disposed, 0x26a /* \"not closed\" */);\n\n if (this.connection !== undefined) {\n return; // Connection attempt already completed successfully\n }\n\n let pendingConnectionMode;\n if (this.pendingConnection !== undefined) {\n pendingConnectionMode = this.pendingConnection.connectionMode;\n this.cancelConnection(); // Throw out in-progress connection attempt in favor of new attempt\n assert(this.pendingConnection === undefined, 0x344 /* this.pendingConnection should be undefined */);\n }\n // If there is no specified ConnectionMode, try the previous mode, if there is no previous mode use default\n let requestedMode = connectionMode ?? pendingConnectionMode ?? this.defaultReconnectionMode;\n\n // if we have any non-acked ops from last connection, reconnect as \"write\".\n // without that we would connect in view-only mode, which will result in immediate\n // firing of \"connected\" event from Container and switch of current clientId (as tracked\n // by all DDSes). This will make it impossible to figure out if ops actually made it through,\n // so DDSes will immediately resubmit all pending ops, and some of them will be duplicates, corrupting document\n if (this.shouldJoinWrite()) {\n requestedMode = \"write\";\n }\n\n const docService = this.serviceProvider();\n assert(docService !== undefined, 0x2a7 /* \"Container is not attached\" */);\n\n let connection: IDocumentDeltaConnection | undefined;\n\n if (docService.policies?.storageOnly === true) {\n connection = new NoDeltaStream();\n this.setupNewSuccessfulConnection(connection, \"read\");\n assert(this.pendingConnection === undefined, 0x2b3 /* \"logic error\" */);\n return;\n }\n\n let delayMs = InitialReconnectDelayInMs;\n let connectRepeatCount = 0;\n const connectStartTime = performance.now();\n let lastError: any;\n\n const abortController = new AbortController();\n const abortSignal = abortController.signal;\n this.pendingConnection = { abort: () => { abortController.abort(); }, connectionMode: requestedMode };\n\n // This loop will keep trying to connect until successful, with a delay between each iteration.\n while (connection === undefined) {\n if (this._disposed) {\n throw new Error(\"Attempting to connect a closed DeltaManager\");\n }\n if (abortSignal.aborted === true) {\n this.logger.sendTelemetryEvent({\n eventName: \"ConnectionAttemptCancelled\",\n attempts: connectRepeatCount,\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n connectionEstablished: false,\n });\n return;\n }\n connectRepeatCount++;\n\n try {\n this.client.mode = requestedMode;\n connection = await docService.connectToDeltaStream({ ...this.client, mode: requestedMode });\n\n if (connection.disposed) {\n // Nobody observed this connection, so drop it on the floor and retry.\n this.logger.sendTelemetryEvent({ eventName: \"ReceivedClosedConnection\" });\n connection = undefined;\n }\n } catch (origError: any) {\n if (typeof origError === \"object\" && origError !== null &&\n origError?.errorType === DeltaStreamConnectionForbiddenError.errorType) {\n connection = new NoDeltaStream();\n requestedMode = \"read\";\n break;\n }\n\n // Socket.io error when we connect to wrong socket, or hit some multiplexing bug\n if (!canRetryOnError(origError)) {\n const error = normalizeError(origError, { props: fatalConnectErrorProp });\n this.props.closeHandler(error);\n throw error;\n }\n\n // Since the error is retryable this will not log to the error table\n logNetworkFailure(\n this.logger,\n {\n attempts: connectRepeatCount,\n delay: delayMs, // milliseconds\n eventName: \"DeltaConnectionFailureToConnect\",\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n },\n origError);\n\n lastError = origError;\n\n const retryDelayFromError = getRetryDelayFromError(origError);\n delayMs = retryDelayFromError ?? Math.min(delayMs * 2, MaxReconnectDelayInMs);\n\n if (retryDelayFromError !== undefined) {\n this.props.reconnectionDelayHandler(retryDelayFromError, origError);\n }\n await waitForConnectedState(delayMs);\n }\n }\n\n // If we retried more than once, log an event about how long it took (this will not log to error table)\n if (connectRepeatCount > 1) {\n logNetworkFailure(\n this.logger,\n {\n eventName: \"MultipleDeltaConnectionFailures\",\n attempts: connectRepeatCount,\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n },\n lastError,\n );\n }\n\n // Check for abort signal after while loop as well\n if (abortSignal.aborted === true) {\n connection.dispose();\n this.logger.sendTelemetryEvent({\n eventName: \"ConnectionAttemptCancelled\",\n attempts: connectRepeatCount,\n duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),\n connectionEstablished: true,\n });\n return;\n }\n\n this.setupNewSuccessfulConnection(connection, requestedMode);\n }\n\n /**\n * Start the connection. Any error should result in container being closed.\n * And report the error if it escapes for any reason.\n * @param args - The connection arguments\n */\n private triggerConnect(connectionMode: ConnectionMode) {\n // reconnect() has async await of waitForConnectedState(), and that causes potential race conditions\n // where we might already have a connection. If it were to happen, it's possible that we will connect\n // with different mode to `connectionMode`. Glancing through the caller chains, it looks like code should be\n // fine (if needed, reconnect flow will get triggered again). Places where new mode matters should encode it\n // directly in connectCore - see this.shouldJoinWrite() test as an example.\n // assert(this.connection === undefined, 0x239 /* \"called only in disconnected state\" */);\n\n if (this.reconnectMode !== ReconnectMode.Enabled) {\n return;\n }\n this.connect(connectionMode);\n }\n\n /**\n * Disconnect the current connection.\n * @param reason - Text description of disconnect reason to emit with disconnect event\n * @returns A boolean that indicates if there was an existing connection (or pending connection) to disconnect\n */\n private disconnectFromDeltaStream(reason: string): boolean {\n this.pendingReconnect = false;\n\n if (this.connection === undefined) {\n if (this.pendingConnection !== undefined) {\n this.cancelConnection();\n return true;\n }\n return false;\n }\n\n assert(this.pendingConnection === undefined, 0x27b /* \"reentrancy may result in incorrect behavior\" */);\n\n const connection = this.connection;\n // Avoid any re-entrancy - clear object reference\n this.connection = undefined;\n\n // Remove listeners first so we don't try to retrigger this flow accidentally through reconnectOnError\n connection.off(\"op\", this.opHandler);\n connection.off(\"signal\", this.props.signalHandler);\n connection.off(\"nack\", this.nackHandler);\n connection.off(\"disconnect\", this.disconnectHandlerInternal);\n connection.off(\"error\", this.errorHandler);\n connection.off(\"pong\", this.props.pongHandler);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._outbound.pause();\n this._outbound.clear();\n this.props.disconnectHandler(reason);\n\n connection.dispose();\n\n this._connectionVerboseProps = {};\n\n return true;\n }\n\n /**\n * Cancel in-progress connection attempt.\n */\n private cancelConnection() {\n assert(this.pendingConnection !== undefined,\n 0x345 /* this.pendingConnection is undefined when trying to cancel */);\n this.pendingConnection.abort();\n this.pendingConnection = undefined;\n this.logger.sendTelemetryEvent({ eventName: \"ConnectionCancelReceived\" });\n }\n\n /**\n * Once we've successfully gotten a connection, we need to set up state, attach event listeners, and process\n * initial messages.\n * @param connection - The newly established connection\n */\n private setupNewSuccessfulConnection(connection: IDocumentDeltaConnection, requestedMode: ConnectionMode) {\n // Old connection should have been cleaned up before establishing a new one\n assert(this.connection === undefined, 0x0e6 /* \"old connection exists on new connection setup\" */);\n assert(!connection.disposed, 0x28a /* \"can't be disposed - Callers need to ensure that!\" */);\n\n this.pendingConnection = undefined;\n\n this.connection = connection;\n\n // Does information in scopes & mode matches?\n // If we asked for \"write\" and got \"read\", then file is read-only\n // But if we ask read, server can still give us write.\n const readonly = !connection.claims.scopes.includes(ScopeType.DocWrite);\n\n if (connection.mode !== requestedMode) {\n this.logger.sendTelemetryEvent({ eventName: \"ConnectionModeMismatch\", requestedMode, mode: connection.mode });\n }\n // This connection mode validation logic is moving to the driver layer in 0.44. These two asserts can be\n // removed after those packages have released and become ubiquitous.\n assert(requestedMode === \"read\" || readonly === (this.connectionMode === \"read\"),\n 0x0e7 /* \"claims/connectionMode mismatch\" */);\n assert(!readonly || this.connectionMode === \"read\", 0x0e8 /* \"readonly perf with write connection\" */);\n\n this.set_readonlyPermissions(readonly);\n\n if (this._disposed) {\n // Raise proper events, Log telemetry event and close connection.\n this.disconnectFromDeltaStream(\"ConnectionManager already closed\");\n return;\n }\n\n this._outbound.resume();\n\n connection.on(\"op\", this.opHandler);\n connection.on(\"signal\", this.props.signalHandler);\n connection.on(\"nack\", this.nackHandler);\n connection.on(\"disconnect\", this.disconnectHandlerInternal);\n connection.on(\"error\", this.errorHandler);\n connection.on(\"pong\", this.props.pongHandler);\n\n // Initial messages are always sorted. However, due to early op handler installed by drivers and appending those\n // ops to initialMessages, resulting set is no longer sorted, which would result in client hitting storage to\n // fill in gap. We will recover by cancelling this request once we process remaining ops, but it's a waste that\n // we could avoid\n const initialMessages = connection.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\n // Some storages may provide checkpointSequenceNumber to identify how far client is behind.\n let checkpointSequenceNumber = connection.checkpointSequenceNumber;\n\n this._connectionVerboseProps = {\n clientId: connection.clientId,\n mode: connection.mode,\n };\n\n // reset connection props\n this._connectionProps = {};\n\n if (connection.relayServiceAgent !== undefined) {\n this._connectionVerboseProps.relayServiceAgent = connection.relayServiceAgent;\n this._connectionProps.relayServiceAgent = connection.relayServiceAgent;\n }\n this._connectionProps.socketDocumentId = connection.claims.documentId;\n this._connectionProps.connectionMode = connection.mode;\n\n let last = -1;\n if (initialMessages.length !== 0) {\n this._connectionVerboseProps.connectionInitialOpsFrom = initialMessages[0].sequenceNumber;\n last = initialMessages[initialMessages.length - 1].sequenceNumber;\n this._connectionVerboseProps.connectionInitialOpsTo = last + 1;\n // Update knowledge of how far we are behind, before raising \"connect\" event\n // This is duplication of what incomingOpHandler() does, but we have to raise event before we get there,\n // so duplicating update logic here as well.\n if (checkpointSequenceNumber === undefined || checkpointSequenceNumber < last) {\n checkpointSequenceNumber = last;\n }\n }\n\n this.props.incomingOpHandler(\n initialMessages,\n this.connectFirstConnection ? \"InitialOps\" : \"ReconnectOps\");\n\n const details = ConnectionManager.detailsFromConnection(connection);\n details.checkpointSequenceNumber = checkpointSequenceNumber;\n this.props.connectHandler(details);\n\n this.connectFirstConnection = false;\n\n // Synthesize clear & join signals out of initialClients state.\n // This allows us to have single way to process signals, and makes it simpler to initialize\n // protocol in Container.\n const clearSignal: ISignalMessage = {\n clientId: null, // system message\n content: JSON.stringify({\n type: SignalType.Clear,\n }),\n };\n this.props.signalHandler(clearSignal);\n\n for (const priorClient of connection.initialClients ?? []) {\n const joinSignal: ISignalMessage = {\n clientId: null, // system signal\n content: JSON.stringify({\n type: SignalType.ClientJoin,\n content: priorClient, // ISignalClient\n }),\n };\n this.props.signalHandler(joinSignal);\n }\n\n // Unfortunately, there is no defined order between initialSignals (including join & leave signals)\n // and connection.initialClients. In practice, connection.initialSignals quite often contains join signal\n // for \"self\" and connection.initialClients does not contain \"self\", so we have to process them after\n // \"clear\" signal above.\n if (connection.initialSignals !== undefined) {\n for (const signal of connection.initialSignals) {\n this.props.signalHandler(signal);\n }\n }\n }\n\n /**\n * Disconnect the current connection and reconnect. Closes the container if it fails.\n * @param connection - The connection that wants to reconnect - no-op if it's different from this.connection\n * @param requestedMode - Read or write\n * @param error - Error reconnect information including whether or not to reconnect\n * @returns A promise that resolves when the connection is reestablished or we stop trying\n */\n private reconnectOnError(\n requestedMode: ConnectionMode,\n error: IAnyDriverError,\n ) {\n this.reconnect(\n requestedMode,\n error.message,\n error)\n .catch(this.props.closeHandler);\n }\n\n /**\n * Disconnect the current connection and reconnect.\n * @param connection - The connection that wants to reconnect - no-op if it's different from this.connection\n * @param requestedMode - Read or write\n * @param error - Error reconnect information including whether or not to reconnect\n * @returns A promise that resolves when the connection is reestablished or we stop trying\n */\n private async reconnect(\n requestedMode: ConnectionMode,\n disconnectMessage: string,\n error?: IAnyDriverError,\n ) {\n // We quite often get protocol errors before / after observing nack/disconnect\n // we do not want to run through same sequence twice.\n // If we're already disconnected/disconnecting it's not appropriate to call this again.\n assert(this.connection !== undefined, 0x0eb /* \"Missing connection for reconnect\" */);\n\n this.disconnectFromDeltaStream(disconnectMessage);\n\n // We will always trigger reconnect, even if canRetry is false.\n // Any truly fatal error state will result in container close upon attempted reconnect,\n // which is a preferable to closing abruptly when a live connection fails.\n if (error !== undefined && !error.canRetry) {\n this.logger.sendTelemetryEvent({\n eventName: \"reconnectingDespiteFatalError\",\n reconnectMode: this.reconnectMode,\n }, error);\n }\n\n if (this.reconnectMode === ReconnectMode.Never) {\n // Do not raise container error if we are closing just because we lost connection.\n // Those errors (like IdleDisconnect) would show up in telemetry dashboards and\n // are very misleading, as first initial reaction - some logic is broken.\n this.props.closeHandler();\n }\n\n // If closed then we can't reconnect\n if (this._disposed || this.reconnectMode !== ReconnectMode.Enabled) {\n return;\n }\n\n const delayMs = getRetryDelayFromError(error);\n if (error !== undefined && delayMs !== undefined) {\n this.props.reconnectionDelayHandler(delayMs, error);\n await waitForConnectedState(delayMs);\n }\n\n this.triggerConnect(requestedMode);\n }\n\n public prepareMessageToSend(message: Omit<IDocumentMessage, \"clientSequenceNumber\">): IDocumentMessage | undefined {\n if (this.readonly === true) {\n assert(this.readOnlyInfo.readonly === true, 0x1f0 /* \"Unexpected mismatch in readonly\" */);\n const error = new GenericError(\"deltaManagerReadonlySubmit\", undefined /* error */, {\n readonly: this.readOnlyInfo.readonly,\n forcedReadonly: this.readOnlyInfo.forced,\n readonlyPermissions: this.readOnlyInfo.permissions,\n storageOnly: this.readOnlyInfo.storageOnly,\n });\n this.props.closeHandler(error);\n return undefined;\n }\n\n // reset clientSequenceNumber if we are using new clientId.\n // we keep info about old connection as long as possible to be able to account for all non-acked ops\n // that we pick up on next connection.\n assert(!!this.connection, 0x0e4 /* \"Lost old connection!\" */);\n if (this.lastSubmittedClientId !== this.connection?.clientId) {\n this.lastSubmittedClientId = this.connection?.clientId;\n this.clientSequenceNumber = 0;\n this.clientSequenceNumberObserved = 0;\n }\n\n if (!isRuntimeMessage(message)) {\n this.localOpsToIgnore++;\n } else {\n this.localOpsToIgnore = 0;\n }\n\n return {\n ...message,\n clientSequenceNumber: ++this.clientSequenceNumber,\n };\n }\n\n public submitSignal(content: any) {\n if (this.connection !== undefined) {\n this.connection.submitSignal(content);\n } else {\n this.logger.sendErrorEvent({ eventName: \"submitSignalDisconnected\" });\n }\n }\n\n public sendMessages(messages: IDocumentMessage[]) {\n assert(this.connected, 0x2b4 /* \"not connected on sending ops!\" */);\n // If connection is \"read\" or implicit \"read\" (got leave op for \"write\" connection),\n // then op can't make it through - we will get a nack if op is sent.\n // We can short-circuit this process.\n // Note that we also want nacks to be rare and be treated as catastrophic failures.\n // Be careful with reentrancy though - disconnected event should not be be raised in the\n // middle of the current workflow, but rather on clean stack!\n if (this.connectionMode === \"read\") {\n if (!this.pendingReconnect) {\n this.pendingReconnect = true;\n Promise.resolve().then(async () => {\n if (this.pendingReconnect) { // still valid?\n await this.reconnect(\n \"write\", // connectionMode\n \"Switch to write\", // message\n );\n }\n }).catch(() => { });\n }\n return;\n }\n\n assert(!this.pendingReconnect, 0x2b5 /* \"logic error\" */);\n\n this._outbound.push(messages);\n }\n\n public beforeProcessingIncomingOp(message: ISequencedDocumentMessage) {\n // if we have connection, and message is local, then we better treat is as local!\n assert(this.clientId !== message.clientId || this.lastSubmittedClientId === message.clientId,\n 0x0ee /* \"Not accounting local messages correctly\" */,\n );\n\n if (this.lastSubmittedClientId !== undefined && this.lastSubmittedClientId === message.clientId) {\n const clientSequenceNumber = message.clientSequenceNumber;\n\n assert(this.clientSequenceNumberObserved < clientSequenceNumber, 0x0ef /* \"client seq# not growing\" */);\n assert(clientSequenceNumber <= this.clientSequenceNumber,\n 0x0f0 /* \"Incoming local client seq# > generated by this client\" */);\n\n this.clientSequenceNumberObserved = clientSequenceNumber;\n }\n\n if (message.type === MessageType.ClientLeave) {\n const systemLeaveMessage = message as ISequencedDocumentSystemMessage;\n const clientId = JSON.parse(systemLeaveMessage.data) as string;\n if (clientId === this.clientId) {\n // We have been kicked out from quorum\n this.logger.sendPerformanceEvent({ eventName: \"ReadConnectionTransition\" });\n\n // Please see #8483 for more details on why maintaining connection further as is would not work.\n // Short story - connection properties are immutable, and many processes (consensus DDSes, summarizer)\n // assume that connection stays \"write\" connection until disconnect, and act accordingly, which may\n // not work well with de-facto \"read\" connection we are in after receiving own leave op on timeout.\n // Clients need to be able to transition to \"read\" state after some time of inactivity!\n // Note - this may close container!\n this.reconnect(\n \"read\", // connectionMode\n \"Switch to read\", // message\n ).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"SwitchToReadConnection\" }, error);\n });\n }\n }\n }\n\n private readonly opHandler = (documentId: string, messagesArg: ISequencedDocumentMessage[]) => {\n const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];\n this.props.incomingOpHandler(messages, \"opHandler\");\n };\n\n // Always connect in write mode after getting nacked.\n private readonly nackHandler = (documentId: string, messages: INack[]) => {\n const message = messages[0];\n if (this._readonlyPermissions === true) {\n this.props.closeHandler(createWriteError(\"writeOnReadOnlyDocument\", { driverVersion: undefined }));\n return;\n }\n\n const reconnectInfo = getNackReconnectInfo(message.content);\n\n // If the nack indicates we cannot retry, then close the container outright\n if (!reconnectInfo.canRetry) {\n this.props.closeHandler(reconnectInfo);\n return;\n }\n\n this.reconnectOnError(\n \"write\",\n reconnectInfo,\n );\n };\n\n // Connection mode is always read on disconnect/error unless the system mode was write.\n private readonly disconnectHandlerInternal = (disconnectReason: IAnyDriverError) => {\n // Note: we might get multiple disconnect calls on same socket, as early disconnect notification\n // (\"server_disconnect\", ODSP-specific) is mapped to \"disconnect\"\n this.reconnectOnError(\n this.defaultReconnectionMode,\n disconnectReason,\n );\n };\n\n private readonly errorHandler = (error: IAnyDriverError) => {\n this.reconnectOnError(\n this.defaultReconnectionMode,\n error,\n );\n };\n}\n"]}
|
package/dist/container.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export interface IContainerConfig {
|
|
|
60
60
|
*/
|
|
61
61
|
export declare function waitContainerToCatchUp(container: IContainer): Promise<boolean>;
|
|
62
62
|
/**
|
|
63
|
-
* Helper function to report to telemetry cases where operation takes longer than expected (
|
|
63
|
+
* Helper function to report to telemetry cases where operation takes longer than expected (200ms)
|
|
64
64
|
* @param logger - logger to use
|
|
65
65
|
* @param eventName - event name
|
|
66
66
|
* @param action - functor to call and measure
|
|
@@ -97,6 +97,21 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
97
97
|
subLogger: TelemetryLogger;
|
|
98
98
|
private readonly _canReconnect;
|
|
99
99
|
private readonly mc;
|
|
100
|
+
/**
|
|
101
|
+
* Lifecycle state of the container, used mainly to prevent re-entrancy and telemetry
|
|
102
|
+
*
|
|
103
|
+
* States are allowed to progress to further states:
|
|
104
|
+
* "loading" - "loaded" - "closing" - "disposing" - "closed" - "disposed"
|
|
105
|
+
*
|
|
106
|
+
* For example, moving from "closed" to "disposing" is not allowed since it is an earlier state.
|
|
107
|
+
*
|
|
108
|
+
* loading: Container has been created, but is not yet in normal/loaded state
|
|
109
|
+
* loaded: Container is in normal/loaded state
|
|
110
|
+
* closing: Container has started closing process (for re-entrancy prevention)
|
|
111
|
+
* disposing: Container has started disposing process (for re-entrancy prevention)
|
|
112
|
+
* closed: Container has closed
|
|
113
|
+
* disposed: Container has been disposed
|
|
114
|
+
*/
|
|
100
115
|
private _lifecycleState;
|
|
101
116
|
private setLoaded;
|
|
102
117
|
get closed(): boolean;
|
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EAEvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,QAAQ,EACR,SAAS,EACT,YAAY,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EAET,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EAEvB,WAAW,EAEX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAGpB,MAAM,uCAAuC,CAAC;AAK/C,OAAO,EAEH,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAW5C,OAAO,EAEH,oBAAoB,EAC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AO,CAAC,yBAAyB;IAQjC;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;CAWnC"}
|
package/dist/container.js
CHANGED
|
@@ -113,7 +113,7 @@ const getCodeProposal =
|
|
|
113
113
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
114
114
|
(quorum) => { var _a; return (_a = quorum.get("code")) !== null && _a !== void 0 ? _a : quorum.get("code2"); };
|
|
115
115
|
/**
|
|
116
|
-
* Helper function to report to telemetry cases where operation takes longer than expected (
|
|
116
|
+
* Helper function to report to telemetry cases where operation takes longer than expected (200ms)
|
|
117
117
|
* @param logger - logger to use
|
|
118
118
|
* @param eventName - event name
|
|
119
119
|
* @param action - functor to call and measure
|
|
@@ -141,6 +141,21 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
141
141
|
// Tells if container can reconnect on losing fist connection
|
|
142
142
|
// If false, container gets closed on loss of connection.
|
|
143
143
|
this._canReconnect = true;
|
|
144
|
+
/**
|
|
145
|
+
* Lifecycle state of the container, used mainly to prevent re-entrancy and telemetry
|
|
146
|
+
*
|
|
147
|
+
* States are allowed to progress to further states:
|
|
148
|
+
* "loading" - "loaded" - "closing" - "disposing" - "closed" - "disposed"
|
|
149
|
+
*
|
|
150
|
+
* For example, moving from "closed" to "disposing" is not allowed since it is an earlier state.
|
|
151
|
+
*
|
|
152
|
+
* loading: Container has been created, but is not yet in normal/loaded state
|
|
153
|
+
* loaded: Container is in normal/loaded state
|
|
154
|
+
* closing: Container has started closing process (for re-entrancy prevention)
|
|
155
|
+
* disposing: Container has started disposing process (for re-entrancy prevention)
|
|
156
|
+
* closed: Container has closed
|
|
157
|
+
* disposed: Container has been disposed
|
|
158
|
+
*/
|
|
144
159
|
this._lifecycleState = "loading";
|
|
145
160
|
this._attachState = container_definitions_1.AttachState.Detached;
|
|
146
161
|
/** During initialization we pause the inbound queues. We track this state to ensure we only call resume once */
|
|
@@ -364,7 +379,8 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
364
379
|
}
|
|
365
380
|
}
|
|
366
381
|
get closed() {
|
|
367
|
-
return (this._lifecycleState === "closing" || this._lifecycleState === "closed"
|
|
382
|
+
return (this._lifecycleState === "closing" || this._lifecycleState === "closed"
|
|
383
|
+
|| this._lifecycleState === "disposing" || this._lifecycleState === "disposed");
|
|
368
384
|
}
|
|
369
385
|
get storage() {
|
|
370
386
|
return this.storageService;
|
|
@@ -526,11 +542,21 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
526
542
|
}
|
|
527
543
|
disposeCore(error) {
|
|
528
544
|
var _a, _b, _c;
|
|
529
|
-
(0, common_utils_1.assert)(!this._disposed,
|
|
545
|
+
(0, common_utils_1.assert)(!this._disposed, 0x54c /* Container already disposed */);
|
|
530
546
|
this._disposed = true;
|
|
531
547
|
try {
|
|
532
548
|
// Ensure that we raise all key events even if one of these throws
|
|
533
549
|
try {
|
|
550
|
+
// Raise event first, to ensure we capture _lifecycleState before transition.
|
|
551
|
+
// This gives us a chance to know what errors happened on open vs. on fully loaded container.
|
|
552
|
+
this.mc.logger.sendTelemetryEvent({
|
|
553
|
+
eventName: "ContainerDispose",
|
|
554
|
+
category: error === undefined ? "generic" : "error",
|
|
555
|
+
}, error);
|
|
556
|
+
// ! Progressing from "closed" to "disposing" is not allowed
|
|
557
|
+
if (this._lifecycleState !== "closed") {
|
|
558
|
+
this._lifecycleState = "disposing";
|
|
559
|
+
}
|
|
534
560
|
(_a = this._protocolHandler) === null || _a === void 0 ? void 0 : _a.close();
|
|
535
561
|
this.connectionStateHandler.dispose();
|
|
536
562
|
(_b = this._context) === null || _b === void 0 ? void 0 : _b.dispose(error !== undefined ? new Error(error.message) : undefined);
|
|
@@ -883,8 +909,8 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
883
909
|
if (!this.closed) {
|
|
884
910
|
if (opsBeforeReturnP !== undefined) {
|
|
885
911
|
this._deltaManager.inbound.resume();
|
|
886
|
-
await
|
|
887
|
-
await
|
|
912
|
+
await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "WaitOps" }, async () => opsBeforeReturnP);
|
|
913
|
+
await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "WaitOpProcessing" }, async () => this._deltaManager.inbound.waitTillProcessingDone());
|
|
888
914
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
889
915
|
this._deltaManager.inbound.pause();
|
|
890
916
|
}
|