@fluidframework/container-loader 2.0.0-internal.8.0.1 → 2.0.0-rc.1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +0 -6
  3. package/api-extractor-esm.json +4 -0
  4. package/api-extractor-lint.json +1 -10
  5. package/api-extractor.json +1 -9
  6. package/api-report/container-loader.api.md +3 -3
  7. package/dist/{audience.cjs → audience.js} +1 -1
  8. package/dist/audience.js.map +1 -0
  9. package/dist/{catchUpMonitor.cjs → catchUpMonitor.js} +1 -1
  10. package/dist/catchUpMonitor.js.map +1 -0
  11. package/dist/{connectionManager.cjs → connectionManager.js} +5 -5
  12. package/dist/connectionManager.js.map +1 -0
  13. package/dist/connectionState.d.ts +1 -1
  14. package/dist/{connectionState.cjs → connectionState.js} +2 -2
  15. package/dist/connectionState.js.map +1 -0
  16. package/dist/{connectionStateHandler.cjs → connectionStateHandler.js} +3 -3
  17. package/dist/connectionStateHandler.js.map +1 -0
  18. package/dist/container-loader-alpha.d.ts +52 -5
  19. package/dist/container-loader-beta.d.ts +24 -13
  20. package/dist/container-loader-public.d.ts +24 -13
  21. package/dist/container-loader-untrimmed.d.ts +3 -3
  22. package/dist/container.d.ts +1 -1
  23. package/dist/{container.cjs → container.js} +16 -16
  24. package/dist/container.js.map +1 -0
  25. package/dist/{containerContext.cjs → containerContext.js} +1 -1
  26. package/dist/containerContext.js.map +1 -0
  27. package/dist/{containerStorageAdapter.cjs → containerStorageAdapter.js} +3 -3
  28. package/dist/containerStorageAdapter.js.map +1 -0
  29. package/dist/{contracts.cjs → contracts.js} +1 -1
  30. package/dist/contracts.js.map +1 -0
  31. package/dist/{debugLogger.cjs → debugLogger.js} +1 -1
  32. package/dist/debugLogger.js.map +1 -0
  33. package/dist/{deltaManager.cjs → deltaManager.js} +3 -3
  34. package/dist/deltaManager.js.map +1 -0
  35. package/dist/{deltaQueue.cjs → deltaQueue.js} +1 -1
  36. package/dist/deltaQueue.js.map +1 -0
  37. package/dist/{disposal.cjs → disposal.js} +1 -1
  38. package/dist/disposal.js.map +1 -0
  39. package/dist/{error.cjs → error.js} +1 -1
  40. package/dist/error.js.map +1 -0
  41. package/dist/{index.cjs → index.js} +6 -6
  42. package/dist/index.js.map +1 -0
  43. package/dist/{loader.cjs → loader.js} +5 -5
  44. package/dist/loader.js.map +1 -0
  45. package/dist/location-redirection-utilities/{index.cjs → index.js} +2 -2
  46. package/dist/location-redirection-utilities/index.js.map +1 -0
  47. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +1 -1
  48. package/dist/location-redirection-utilities/{resolveWithLocationRedirection.cjs → resolveWithLocationRedirection.js} +2 -2
  49. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  50. package/dist/{noopHeuristic.cjs → noopHeuristic.js} +1 -1
  51. package/dist/noopHeuristic.js.map +1 -0
  52. package/dist/packageVersion.d.ts +1 -1
  53. package/dist/packageVersion.d.ts.map +1 -1
  54. package/dist/{packageVersion.cjs → packageVersion.js} +2 -2
  55. package/dist/packageVersion.js.map +1 -0
  56. package/dist/{protocol.cjs → protocol.js} +1 -1
  57. package/dist/protocol.js.map +1 -0
  58. package/dist/{protocolTreeDocumentStorageService.cjs → protocolTreeDocumentStorageService.js} +1 -1
  59. package/dist/protocolTreeDocumentStorageService.js.map +1 -0
  60. package/dist/{quorum.cjs → quorum.js} +1 -1
  61. package/dist/quorum.js.map +1 -0
  62. package/dist/{retriableDocumentStorageService.cjs → retriableDocumentStorageService.js} +1 -1
  63. package/dist/retriableDocumentStorageService.js.map +1 -0
  64. package/dist/{utils.cjs → utils.js} +1 -1
  65. package/dist/utils.js.map +1 -0
  66. package/lib/{audience.d.ts → audience.d.mts} +1 -1
  67. package/lib/audience.d.mts.map +1 -0
  68. package/lib/{catchUpMonitor.d.ts → catchUpMonitor.d.mts} +1 -1
  69. package/lib/catchUpMonitor.d.mts.map +1 -0
  70. package/lib/{connectionManager.d.ts → connectionManager.d.mts} +1 -1
  71. package/lib/connectionManager.d.mts.map +1 -0
  72. package/lib/{connectionState.d.ts → connectionState.d.mts} +2 -2
  73. package/lib/connectionState.d.mts.map +1 -0
  74. package/lib/connectionState.mjs +1 -1
  75. package/lib/connectionState.mjs.map +1 -1
  76. package/lib/{connectionStateHandler.d.ts → connectionStateHandler.d.mts} +1 -1
  77. package/lib/connectionStateHandler.d.mts.map +1 -0
  78. package/lib/{container-loader-alpha.d.ts → container-loader-alpha.d.mts} +52 -5
  79. package/lib/{container-loader-public.d.ts → container-loader-beta.d.mts} +24 -13
  80. package/lib/{container-loader-beta.d.ts → container-loader-public.d.mts} +24 -13
  81. package/lib/{container-loader-untrimmed.d.ts → container-loader-untrimmed.d.mts} +3 -3
  82. package/lib/{container.d.ts → container.d.mts} +2 -2
  83. package/lib/container.d.mts.map +1 -0
  84. package/lib/container.mjs +1 -1
  85. package/lib/container.mjs.map +1 -1
  86. package/lib/{containerContext.d.ts → containerContext.d.mts} +1 -1
  87. package/lib/containerContext.d.mts.map +1 -0
  88. package/lib/{containerStorageAdapter.d.ts → containerStorageAdapter.d.mts} +1 -1
  89. package/lib/containerStorageAdapter.d.mts.map +1 -0
  90. package/lib/{contracts.d.ts → contracts.d.mts} +1 -1
  91. package/lib/contracts.d.mts.map +1 -0
  92. package/lib/{debugLogger.d.ts → debugLogger.d.mts} +1 -1
  93. package/lib/debugLogger.d.mts.map +1 -0
  94. package/lib/{deltaManager.d.ts → deltaManager.d.mts} +1 -1
  95. package/lib/deltaManager.d.mts.map +1 -0
  96. package/lib/{deltaQueue.d.ts → deltaQueue.d.mts} +1 -1
  97. package/lib/deltaQueue.d.mts.map +1 -0
  98. package/lib/{disposal.d.ts → disposal.d.mts} +1 -1
  99. package/lib/disposal.d.mts.map +1 -0
  100. package/lib/{error.d.ts → error.d.mts} +1 -1
  101. package/lib/error.d.mts.map +1 -0
  102. package/lib/{index.d.ts → index.d.mts} +1 -1
  103. package/lib/index.d.mts.map +1 -0
  104. package/lib/{loader.d.ts → loader.d.mts} +1 -1
  105. package/lib/loader.d.mts.map +1 -0
  106. package/lib/location-redirection-utilities/{index.d.ts → index.d.mts} +1 -1
  107. package/lib/location-redirection-utilities/index.d.mts.map +1 -0
  108. package/lib/location-redirection-utilities/{resolveWithLocationRedirection.d.ts → resolveWithLocationRedirection.d.mts} +2 -2
  109. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +1 -0
  110. package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs +1 -1
  111. package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +1 -1
  112. package/lib/{noopHeuristic.d.ts → noopHeuristic.d.mts} +1 -1
  113. package/lib/noopHeuristic.d.mts.map +1 -0
  114. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  115. package/lib/packageVersion.d.mts.map +1 -0
  116. package/lib/packageVersion.mjs +1 -1
  117. package/lib/packageVersion.mjs.map +1 -1
  118. package/lib/{protocol.d.ts → protocol.d.mts} +1 -1
  119. package/lib/protocol.d.mts.map +1 -0
  120. package/lib/{protocolTreeDocumentStorageService.d.ts → protocolTreeDocumentStorageService.d.mts} +1 -1
  121. package/lib/protocolTreeDocumentStorageService.d.mts.map +1 -0
  122. package/lib/{quorum.d.ts → quorum.d.mts} +1 -1
  123. package/lib/quorum.d.mts.map +1 -0
  124. package/lib/{retriableDocumentStorageService.d.ts → retriableDocumentStorageService.d.mts} +1 -1
  125. package/lib/retriableDocumentStorageService.d.mts.map +1 -0
  126. package/lib/{utils.d.ts → utils.d.mts} +1 -1
  127. package/lib/utils.d.mts.map +1 -0
  128. package/package.json +129 -38
  129. package/src/connectionState.ts +1 -1
  130. package/src/container.ts +1 -1
  131. package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +1 -1
  132. package/src/packageVersion.ts +1 -1
  133. package/dist/audience.cjs.map +0 -1
  134. package/dist/catchUpMonitor.cjs.map +0 -1
  135. package/dist/connectionManager.cjs.map +0 -1
  136. package/dist/connectionState.cjs.map +0 -1
  137. package/dist/connectionStateHandler.cjs.map +0 -1
  138. package/dist/container.cjs.map +0 -1
  139. package/dist/containerContext.cjs.map +0 -1
  140. package/dist/containerStorageAdapter.cjs.map +0 -1
  141. package/dist/contracts.cjs.map +0 -1
  142. package/dist/debugLogger.cjs.map +0 -1
  143. package/dist/deltaManager.cjs.map +0 -1
  144. package/dist/deltaQueue.cjs.map +0 -1
  145. package/dist/disposal.cjs.map +0 -1
  146. package/dist/error.cjs.map +0 -1
  147. package/dist/index.cjs.map +0 -1
  148. package/dist/loader.cjs.map +0 -1
  149. package/dist/location-redirection-utilities/index.cjs.map +0 -1
  150. package/dist/location-redirection-utilities/resolveWithLocationRedirection.cjs.map +0 -1
  151. package/dist/noopHeuristic.cjs.map +0 -1
  152. package/dist/packageVersion.cjs.map +0 -1
  153. package/dist/protocol.cjs.map +0 -1
  154. package/dist/protocolTreeDocumentStorageService.cjs.map +0 -1
  155. package/dist/quorum.cjs.map +0 -1
  156. package/dist/retriableDocumentStorageService.cjs.map +0 -1
  157. package/dist/utils.cjs.map +0 -1
  158. package/lib/audience.d.ts.map +0 -1
  159. package/lib/catchUpMonitor.d.ts.map +0 -1
  160. package/lib/connectionManager.d.ts.map +0 -1
  161. package/lib/connectionState.d.ts.map +0 -1
  162. package/lib/connectionStateHandler.d.ts.map +0 -1
  163. package/lib/container.d.ts.map +0 -1
  164. package/lib/containerContext.d.ts.map +0 -1
  165. package/lib/containerStorageAdapter.d.ts.map +0 -1
  166. package/lib/contracts.d.ts.map +0 -1
  167. package/lib/debugLogger.d.ts.map +0 -1
  168. package/lib/deltaManager.d.ts.map +0 -1
  169. package/lib/deltaQueue.d.ts.map +0 -1
  170. package/lib/disposal.d.ts.map +0 -1
  171. package/lib/error.d.ts.map +0 -1
  172. package/lib/index.d.ts.map +0 -1
  173. package/lib/loader.d.ts.map +0 -1
  174. package/lib/location-redirection-utilities/index.d.ts.map +0 -1
  175. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +0 -1
  176. package/lib/noopHeuristic.d.ts.map +0 -1
  177. package/lib/packageVersion.d.ts.map +0 -1
  178. package/lib/protocol.d.ts.map +0 -1
  179. package/lib/protocolTreeDocumentStorageService.d.ts.map +0 -1
  180. package/lib/quorum.d.ts.map +0 -1
  181. package/lib/retriableDocumentStorageService.d.ts.map +0 -1
  182. package/lib/utils.d.ts.map +0 -1
  183. package/tsc-multi.test.json +0 -4
@@ -1 +0,0 @@
1
- {"version":3,"file":"connectionManager.cjs","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA8F;AAC9F,2DAAoD;AACpD,+DAA8E;AAM9E,2EAO4C;AAC5C,+DAQsC;AACtC,+EAe8C;AAC9C,qEAOyC;AACzC,+CAMqB;AACrB,iDAA0C;AAC1C,6CAAwC;AACxC,uCAAgE;AAEhE,8GAA8G;AAC9G,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEnC,MAAM,qBAAqB,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;AAE1D,SAAS,oBAAoB,CAAC,WAAyB;IACtD,MAAM,OAAO,GAAG,SAAS,WAAW,CAAC,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACrE,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,KAAK,GAAG,CAAC;IAC1C,MAAM,YAAY,GACjB,WAAW,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,OAAO,IAAA,wCAAyB,EAC/B,OAAO,EACP,EAAE,QAAQ,EAAE,YAAY,EAAE,EAC1B,EAAE,UAAU,EAAE,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,CAC1D,CAAC;AACH,CAAC;AA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yright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryProperties, LogLevel } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { performance, TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tICriticalContainerError,\n\tIDeltaQueue,\n\tReadOnlyInfo,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIAnyDriverError,\n\tIDocumentService,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\t// eslint-disable-next-line import/no-deprecated\n\tDriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tcanRetryOnError,\n\tcreateWriteError,\n\tcreateGenericNetworkError,\n\tgetRetryDelayFromError,\n\tlogNetworkFailure,\n\tisRuntimeMessage,\n\tcalculateMaxWaitTime,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tConnectionMode,\n\tIClient,\n\tIClientConfiguration,\n\tIClientDetails,\n\tIDocumentMessage,\n\tINack,\n\tINackContent,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tMessageType,\n\tScopeType,\n\tISequencedDocumentSystemMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tformatTick,\n\tGenericError,\n\tisFluidError,\n\tITelemetryLoggerExt,\n\tnormalizeError,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tReconnectMode,\n\tIConnectionManager,\n\tIConnectionManagerFactoryArgs,\n\tIConnectionDetailsInternal,\n\tIConnectionStateChangeReason,\n} from \"./contracts\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport { SignalType } from \"./protocol\";\nimport { isDeltaStreamConnectionForbiddenError } from \"./utils\";\n\n// We double this value in first try in when we calculate time to wait for in \"calculateMaxWaitTime\" function.\nconst InitialReconnectDelayInMs = 500;\nconst DefaultChunkSize = 16 * 1024;\n\nconst fatalConnectErrorProp = { fatalConnectError: true };\n\nfunction getNackReconnectInfo(nackContent: INackContent) {\n\tconst message = `Nack (${nackContent.type}): ${nackContent.message}`;\n\tconst canRetry = nackContent.code !== 403;\n\tconst retryAfterMs =\n\t\tnackContent.retryAfter !== undefined ? nackContent.retryAfter * 1000 : undefined;\n\treturn createGenericNetworkError(\n\t\tmessage,\n\t\t{ canRetry, retryAfterMs },\n\t\t{ statusCode: nackContent.code, driverVersion: undefined },\n\t);\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\tmode: \"read\",\n\tdetails: { capabilities: { interactive: true } },\n\tpermission: [],\n\tuser: { id: \"storage-only client\" }, // we need some \"fake\" ID here.\n\tscopes: [],\n};\nconst clientIdNoDeltaStream: string = \"storage-only client\";\n\nclass NoDeltaStream\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\tclientId = clientIdNoDeltaStream;\n\tclaims: ITokenClaims = {\n\t\tscopes: [ScopeType.DocRead],\n\t} as any;\n\tmode: ConnectionMode = \"read\";\n\texisting: boolean = true;\n\tmaxMessageSize: number = 0;\n\tversion: string = \"\";\n\tinitialMessages: ISequencedDocumentMessage[] = [];\n\tinitialSignals: ISignalMessage[] = [];\n\tinitialClients: ISignalClient[] = [\n\t\t{ client: clientNoDeltaStream, clientId: clientIdNoDeltaStream },\n\t];\n\tserviceConfiguration: IClientConfiguration = {\n\t\tmaxMessageSize: 0,\n\t\tblockSize: 0,\n\t};\n\tcheckpointSequenceNumber?: number | undefined = undefined;\n\t/**\n\t * Connection which is not connected to socket.\n\t * @param storageOnlyReason - Reason on why the connection to delta stream is not allowed.\n\t * @param readonlyConnectionReason - reason/error if any which lead to using NoDeltaStream.\n\t */\n\tconstructor(\n\t\tpublic readonly storageOnlyReason?: string,\n\t\tpublic readonly readonlyConnectionReason?: IConnectionStateChangeReason,\n\t) {\n\t\tsuper();\n\t}\n\tsubmit(messages: IDocumentMessage[]): void {\n\t\tthis.emit(\n\t\t\t\"nack\",\n\t\t\tthis.clientId,\n\t\t\tmessages.map((operation) => {\n\t\t\t\treturn {\n\t\t\t\t\toperation,\n\t\t\t\t\tcontent: { message: \"Cannot submit with storage-only connection\", code: 403 },\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\t}\n\tsubmitSignal(message: any): void {\n\t\tthis.emit(\"nack\", this.clientId, {\n\t\t\toperation: message,\n\t\t\tcontent: { message: \"Cannot submit signal with storage-only connection\", code: 403 },\n\t\t});\n\t}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n}\n\nfunction isNoDeltaStreamConnection(connection: any): connection is NoDeltaStream {\n\treturn connection instanceof NoDeltaStream;\n}\n\nconst waitForOnline = async (): Promise<void> => {\n\t// Only wait if we have a strong signal that we're offline - otherwise assume we're online.\n\tif (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tconst resolveAndRemoveListener = () => {\n\t\t\t\tresolve();\n\t\t\t\tglobalThis.removeEventListener(\"online\", resolveAndRemoveListener);\n\t\t\t};\n\t\t\tglobalThis.addEventListener(\"online\", resolveAndRemoveListener);\n\t\t});\n\t}\n};\n\n/**\n * Interface to track the current in-progress connection attempt.\n */\ninterface IPendingConnection {\n\t/**\n\t * Used to cancel an in-progress connection attempt.\n\t */\n\tabort(): void;\n\n\t/**\n\t * Desired ConnectionMode of this in-progress connection attempt.\n\t */\n\tconnectionMode: 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\t/** Connection mode used when reconnecting on error or disconnect. */\n\tprivate readonly defaultReconnectionMode: ConnectionMode;\n\n\t/**\n\t * Tracks the current in-progress connection attempt. Undefined if there is none.\n\t * Note: Once the connection attempt fires and the code becomes asynchronous, its possible that a new connection\n\t * attempt was fired and this.pendingConnection was overwritten to reflect the new attempt.\n\t */\n\tprivate pendingConnection: IPendingConnection | undefined;\n\tprivate connection: IDocumentDeltaConnection | undefined;\n\n\t/** file ACL - whether user has only read-only access to a file */\n\tprivate _readonlyPermissions: boolean | undefined;\n\n\t/** tracks host requiring read-only mode. */\n\tprivate _forceReadonly = false;\n\n\t/**\n\t * Controls whether the DeltaManager will automatically reconnect to the delta stream after receiving a disconnect.\n\t */\n\tprivate _reconnectMode: ReconnectMode;\n\n\t/** True if there is pending (async) reconnection from \"read\" to \"write\" */\n\tprivate pendingReconnect = false;\n\n\tprivate clientSequenceNumber = 0;\n\tprivate clientSequenceNumberObserved = 0;\n\t/** Counts the number of non-runtime ops sent by the client which may not be acked. */\n\tprivate localOpsToIgnore = 0;\n\n\t/** track clientId used last time when we sent any ops */\n\tprivate lastSubmittedClientId: string | undefined;\n\n\tprivate connectFirstConnection = true;\n\n\tprivate _connectionVerboseProps: Record<string, string | number> = {};\n\n\tprivate _connectionProps: ITelemetryProperties = {};\n\n\tprivate _disposed = false;\n\n\tprivate readonly _outbound: DeltaQueue<IDocumentMessage[]>;\n\n\tpublic get connectionVerboseProps() {\n\t\treturn this._connectionVerboseProps;\n\t}\n\n\tpublic readonly clientDetails: IClientDetails;\n\n\t/**\n\t * The current connection mode, initially read.\n\t */\n\tpublic get connectionMode(): ConnectionMode {\n\t\treturn this.connection?.mode ?? \"read\";\n\t}\n\n\tpublic get connected() {\n\t\treturn this.connection !== undefined;\n\t}\n\n\tpublic get clientId() {\n\t\treturn this.connection?.clientId;\n\t}\n\t/**\n\t * Automatic reconnecting enabled or disabled.\n\t * If set to Never, then reconnecting will never be allowed.\n\t */\n\tpublic get reconnectMode(): ReconnectMode {\n\t\treturn this._reconnectMode;\n\t}\n\n\tpublic get maxMessageSize(): number {\n\t\treturn this.connection?.serviceConfiguration?.maxMessageSize ?? DefaultChunkSize;\n\t}\n\n\tpublic get version(): string {\n\t\tif (this.connection === undefined) {\n\t\t\tthrow new Error(\"Cannot check version without a connection\");\n\t\t}\n\t\treturn this.connection.version;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration | undefined {\n\t\treturn this.connection?.serviceConfiguration;\n\t}\n\n\tpublic get scopes(): string[] | undefined {\n\t\treturn this.connection?.claims.scopes;\n\t}\n\n\tpublic get outbound(): IDeltaQueue<IDocumentMessage[]> {\n\t\treturn this._outbound;\n\t}\n\n\t/**\n\t * Returns set of props that can be logged in telemetry that provide some insights / statistics\n\t * about current or last connection (if there is no connection at the moment)\n\t */\n\tpublic get connectionProps(): ITelemetryProperties {\n\t\treturn this.connection !== undefined\n\t\t\t? this._connectionProps\n\t\t\t: {\n\t\t\t\t\t...this._connectionProps,\n\t\t\t\t\t// Report how many ops this client sent in last disconnected session\n\t\t\t\t\tsentOps: this.clientSequenceNumber,\n\t\t\t };\n\t}\n\n\tpublic shouldJoinWrite(): boolean {\n\t\t// We don't have to wait for ack for topmost NoOps. So subtract those.\n\t\tconst outstandingOps =\n\t\t\tthis.clientSequenceNumberObserved < this.clientSequenceNumber - this.localOpsToIgnore;\n\n\t\t// Previous behavior was to force write mode here only when there are outstanding ops (besides\n\t\t// no-ops). The dirty signal from runtime should provide the same behavior, but also support\n\t\t// stashed ops that weren't submitted to container layer yet. For safety, we want to retain the\n\t\t// same behavior whenever dirty is false.\n\t\tconst isDirty = this.containerDirty();\n\t\tif (outstandingOps !== isDirty) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"DesiredConnectionModeMismatch\",\n\t\t\t\tdetails: JSON.stringify({ outstandingOps, isDirty }),\n\t\t\t});\n\t\t}\n\t\treturn outstandingOps || isDirty;\n\t}\n\n\t/**\n\t * Tells if container is in read-only mode.\n\t * Data stores should listen for \"readonly\" notifications and disallow user\n\t * making changes to data stores.\n\t * Readonly state can be because of no storage write permission,\n\t * or due to host forcing readonly mode for container.\n\t * It is undefined if we have not yet established websocket connection\n\t * and do not know if user has write access to a file.\n\t */\n\tprivate get readonly(): boolean | undefined {\n\t\treturn this.readOnlyInfo.readonly;\n\t}\n\n\tpublic get readOnlyInfo(): ReadOnlyInfo {\n\t\tlet storageOnly: boolean = false;\n\t\tlet storageOnlyReason: string | undefined;\n\t\tif (isNoDeltaStreamConnection(this.connection)) {\n\t\t\tstorageOnly = true;\n\t\t\tstorageOnlyReason = this.connection.storageOnlyReason;\n\t\t}\n\t\tif (storageOnly || this._forceReadonly || this._readonlyPermissions === true) {\n\t\t\treturn {\n\t\t\t\treadonly: true,\n\t\t\t\tforced: this._forceReadonly,\n\t\t\t\tpermissions: this._readonlyPermissions,\n\t\t\t\tstorageOnly,\n\t\t\t\tstorageOnlyReason,\n\t\t\t};\n\t\t}\n\n\t\treturn { readonly: this._readonlyPermissions };\n\t}\n\n\tprivate static detailsFromConnection(\n\t\tconnection: IDocumentDeltaConnection,\n\t\treason: IConnectionStateChangeReason,\n\t): IConnectionDetailsInternal {\n\t\treturn {\n\t\t\tclaims: connection.claims,\n\t\t\tclientId: connection.clientId,\n\t\t\tcheckpointSequenceNumber: connection.checkpointSequenceNumber,\n\t\t\tget initialClients() {\n\t\t\t\treturn connection.initialClients;\n\t\t\t},\n\t\t\tmode: connection.mode,\n\t\t\tserviceConfiguration: connection.serviceConfiguration,\n\t\t\tversion: connection.version,\n\t\t\treason,\n\t\t};\n\t}\n\n\tconstructor(\n\t\tprivate readonly serviceProvider: () => IDocumentService | undefined,\n\t\tpublic readonly containerDirty: () => boolean,\n\t\tprivate readonly client: IClient,\n\t\treconnectAllowed: boolean,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly props: IConnectionManagerFactoryArgs,\n\t) {\n\t\tthis.clientDetails = this.client.details;\n\t\tthis.defaultReconnectionMode = this.client.mode;\n\t\tthis._reconnectMode = reconnectAllowed ? ReconnectMode.Enabled : ReconnectMode.Never;\n\n\t\t// Outbound message queue. The outbound queue is represented as a queue of an array of ops. Ops contained\n\t\t// within an array *must* fit within the maxMessageSize and are guaranteed to be ordered sequentially.\n\t\tthis._outbound = new DeltaQueue<IDocumentMessage[]>((messages) => {\n\t\t\tif (this.connection === undefined) {\n\t\t\t\tthrow new Error(\"Attempted to submit an outbound message without connection\");\n\t\t\t}\n\t\t\tthis.connection.submit(messages);\n\t\t});\n\n\t\tthis._outbound.on(\"error\", (error) => {\n\t\t\tthis.props.closeHandler(normalizeError(error));\n\t\t});\n\t}\n\n\tpublic dispose(error?: ICriticalContainerError, switchToReadonly: boolean = true) {\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis._disposed = true;\n\n\t\t// Ensure that things like triggerConnect() will short circuit\n\t\tthis._reconnectMode = ReconnectMode.Never;\n\n\t\tthis._outbound.clear();\n\n\t\tconst disconnectReason: IConnectionStateChangeReason = {\n\t\t\ttext: \"Closing DeltaManager\",\n\t\t\terror,\n\t\t};\n\n\t\tconst oldReadonlyValue = this.readonly;\n\t\t// This raises \"disconnect\" event if we have active connection.\n\t\tthis.disconnectFromDeltaStream(disconnectReason);\n\n\t\tif (switchToReadonly) {\n\t\t\t// Notify everyone we are in read-only state.\n\t\t\t// Useful for data stores in case we hit some critical error,\n\t\t\t// to switch to a mode where user edits are not accepted\n\t\t\tthis.set_readonlyPermissions(true, oldReadonlyValue, disconnectReason);\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables automatic reconnecting.\n\t * Will throw an error if reconnectMode set to Never.\n\t */\n\tpublic setAutoReconnect(mode: ReconnectMode, reason: IConnectionStateChangeReason): void {\n\t\tassert(\n\t\t\tmode !== ReconnectMode.Never && this._reconnectMode !== ReconnectMode.Never,\n\t\t\t0x278 /* \"API is not supported for non-connecting or closed container\" */,\n\t\t);\n\n\t\tthis._reconnectMode = mode;\n\n\t\tif (mode !== ReconnectMode.Enabled) {\n\t\t\t// immediately disconnect - do not rely on service eventually dropping connection.\n\t\t\tthis.disconnectFromDeltaStream(reason);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc Container.forceReadonly}\n\t */\n\tpublic forceReadonly(readonly: boolean) {\n\t\tif (readonly !== this._forceReadonly) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"ForceReadOnly\",\n\t\t\t\tvalue: readonly,\n\t\t\t});\n\t\t}\n\t\tconst oldValue = this.readonly;\n\t\tthis._forceReadonly = readonly;\n\n\t\tif (oldValue !== this.readonly) {\n\t\t\tif (this._reconnectMode === ReconnectMode.Never) {\n\t\t\t\tthrow new UsageError(\"API is not supported for non-connecting or closed container\");\n\t\t\t}\n\t\t\tlet reconnect = false;\n\t\t\tif (this.readonly === true) {\n\t\t\t\t// If we switch to readonly while connected, we should disconnect first\n\t\t\t\t// See comment in the \"readonly\" event handler to deltaManager set up by\n\t\t\t\t// the ContainerRuntime constructor\n\n\t\t\t\tif (this.shouldJoinWrite()) {\n\t\t\t\t\t// If we have pending changes, then we will never send them - it smells like\n\t\t\t\t\t// host logic error.\n\t\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"ForceReadonlyPendingChanged\" });\n\t\t\t\t}\n\n\t\t\t\treconnect = this.disconnectFromDeltaStream({ text: \"Force readonly\" });\n\t\t\t}\n\t\t\tthis.props.readonlyChangeHandler(this.readonly);\n\t\t\tif (reconnect) {\n\t\t\t\t// reconnect if we disconnected from before.\n\t\t\t\tthis.triggerConnect({ text: \"Force Readonly\" }, \"read\");\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate set_readonlyPermissions(\n\t\tnewReadonlyValue: boolean,\n\t\toldReadonlyValue: boolean | undefined,\n\t\treadonlyConnectionReason?: IConnectionStateChangeReason,\n\t) {\n\t\tthis._readonlyPermissions = newReadonlyValue;\n\t\tif (oldReadonlyValue !== this.readonly) {\n\t\t\tthis.props.readonlyChangeHandler(this.readonly, readonlyConnectionReason);\n\t\t}\n\t}\n\n\tpublic connect(reason: IConnectionStateChangeReason, connectionMode?: ConnectionMode) {\n\t\tthis.connectCore(reason, connectionMode).catch((e) => {\n\t\t\tconst normalizedError = normalizeError(e, { props: fatalConnectErrorProp });\n\t\t\tthis.props.closeHandler(normalizedError);\n\t\t});\n\t}\n\n\tprivate async connectCore(\n\t\treason: IConnectionStateChangeReason,\n\t\tconnectionMode?: ConnectionMode,\n\t): Promise<void> {\n\t\tassert(!this._disposed, 0x26a /* \"not closed\" */);\n\n\t\tif (this.connection !== undefined) {\n\t\t\treturn; // Connection attempt already completed successfully\n\t\t}\n\n\t\tlet pendingConnectionMode;\n\t\tif (this.pendingConnection !== undefined) {\n\t\t\tpendingConnectionMode = this.pendingConnection.connectionMode;\n\t\t\tthis.cancelConnection(reason); // Throw out in-progress connection attempt in favor of new attempt\n\t\t\tassert(\n\t\t\t\tthis.pendingConnection === undefined,\n\t\t\t\t0x344 /* this.pendingConnection should be undefined */,\n\t\t\t);\n\t\t}\n\t\t// If there is no specified ConnectionMode, try the previous mode, if there is no previous mode use default\n\t\tlet requestedMode = connectionMode ?? pendingConnectionMode ?? this.defaultReconnectionMode;\n\n\t\t// if we have any non-acked ops from last connection, reconnect as \"write\".\n\t\t// without that we would connect in view-only mode, which will result in immediate\n\t\t// firing of \"connected\" event from Container and switch of current clientId (as tracked\n\t\t// by all DDSes). This will make it impossible to figure out if ops actually made it through,\n\t\t// so DDSes will immediately resubmit all pending ops, and some of them will be duplicates, corrupting document\n\t\tif (this.shouldJoinWrite()) {\n\t\t\trequestedMode = \"write\";\n\t\t}\n\n\t\tconst docService = this.serviceProvider();\n\t\tassert(docService !== undefined, 0x2a7 /* \"Container is not attached\" */);\n\n\t\tlet connection: IDocumentDeltaConnection | undefined;\n\n\t\tif (docService.policies?.storageOnly === true) {\n\t\t\tconnection = new NoDeltaStream();\n\t\t\tthis.setupNewSuccessfulConnection(connection, \"read\", reason);\n\t\t\tassert(this.pendingConnection === undefined, 0x2b3 /* \"logic error\" */);\n\t\t\treturn;\n\t\t}\n\n\t\tlet delayMs = InitialReconnectDelayInMs;\n\t\tlet connectRepeatCount = 0;\n\t\tconst connectStartTime = performance.now();\n\t\tlet lastError: any;\n\n\t\tconst abortController = new AbortController();\n\t\tconst abortSignal = abortController.signal;\n\t\tthis.pendingConnection = {\n\t\t\tabort: () => {\n\t\t\t\tabortController.abort();\n\t\t\t},\n\t\t\tconnectionMode: requestedMode,\n\t\t};\n\n\t\tthis.props.establishConnectionHandler(reason);\n\t\t// This loop will keep trying to connect until successful, with a delay between each iteration.\n\t\twhile (connection === undefined) {\n\t\t\tif (this._disposed) {\n\t\t\t\tthrow new Error(\"Attempting to connect a closed DeltaManager\");\n\t\t\t}\n\t\t\tif (abortSignal.aborted === true) {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"ConnectionAttemptCancelled\",\n\t\t\t\t\tattempts: connectRepeatCount,\n\t\t\t\t\tduration: formatTick(performance.now() - connectStartTime),\n\t\t\t\t\tconnectionEstablished: false,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconnectRepeatCount++;\n\n\t\t\ttry {\n\t\t\t\tthis.client.mode = requestedMode;\n\t\t\t\tconnection = await docService.connectToDeltaStream({\n\t\t\t\t\t...this.client,\n\t\t\t\t\tmode: requestedMode,\n\t\t\t\t});\n\n\t\t\t\tif (connection.disposed) {\n\t\t\t\t\t// Nobody observed this connection, so drop it on the floor and retry.\n\t\t\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"ReceivedClosedConnection\" });\n\t\t\t\t\tconnection = undefined;\n\t\t\t\t}\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"ConnectionReceived\",\n\t\t\t\t\t\tconnected: connection !== undefined && connection.disposed === false,\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t\tLogLevel.verbose,\n\t\t\t\t);\n\t\t\t} catch (origError: any) {\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"ConnectToDeltaStreamException\",\n\t\t\t\t\t\tconnected: connection !== undefined && connection.disposed === false,\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t\tLogLevel.verbose,\n\t\t\t\t);\n\t\t\t\tif (isDeltaStreamConnectionForbiddenError(origError)) {\n\t\t\t\t\tconnection = new NoDeltaStream(origError.storageOnlyReason, {\n\t\t\t\t\t\ttext: origError.message,\n\t\t\t\t\t\terror: origError,\n\t\t\t\t\t});\n\t\t\t\t\trequestedMode = \"read\";\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (\n\t\t\t\t\tisFluidError(origError) &&\n\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\torigError.errorType === DriverErrorType.outOfStorageError\n\t\t\t\t) {\n\t\t\t\t\t// If we get out of storage error from calling joinsession, then use the NoDeltaStream object so\n\t\t\t\t\t// that user can at least load the container.\n\t\t\t\t\tconnection = new NoDeltaStream(undefined, {\n\t\t\t\t\t\ttext: origError.message,\n\t\t\t\t\t\terror: origError,\n\t\t\t\t\t});\n\t\t\t\t\trequestedMode = \"read\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Socket.io error when we connect to wrong socket, or hit some multiplexing bug\n\t\t\t\tif (!canRetryOnError(origError)) {\n\t\t\t\t\tconst error = normalizeError(origError, { props: fatalConnectErrorProp });\n\t\t\t\t\tthis.props.closeHandler(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\t// Since the error is retryable this will not log to the error table\n\t\t\t\tlogNetworkFailure(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\tattempts: connectRepeatCount,\n\t\t\t\t\t\tdelay: delayMs, // milliseconds\n\t\t\t\t\t\teventName: \"DeltaConnectionFailureToConnect\",\n\t\t\t\t\t\tduration: formatTick(performance.now() - connectStartTime),\n\t\t\t\t\t},\n\t\t\t\t\torigError,\n\t\t\t\t);\n\n\t\t\t\tlastError = origError;\n\n\t\t\t\tconst waitStartTime = performance.now();\n\t\t\t\tconst retryDelayFromError = getRetryDelayFromError(origError);\n\t\t\t\t// If the error told us to wait or browser signals us that we are offline, then calculate the time we\n\t\t\t\t// want to wait for before retrying. then we wait for that time. If the error didn't tell us to wait,\n\t\t\t\t// let's still wait a little bit before retrying. We can skip this delay if we're confident we're offline,\n\t\t\t\t// because we probably just need to wait to come back online. But we never have strong signal of being\n\t\t\t\t// offline, so we at least wait for sometime.\n\t\t\t\tif (retryDelayFromError !== undefined || globalThis.navigator?.onLine !== false) {\n\t\t\t\t\tdelayMs = calculateMaxWaitTime(delayMs, origError);\n\t\t\t\t}\n\t\t\t\t// Raise event in case the delay was there.\n\t\t\t\tthis.props.reconnectionDelayHandler(delayMs, origError);\n\t\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\t\tsetTimeout(resolve, delayMs);\n\t\t\t\t});\n\n\t\t\t\t// If we believe we're offline, we assume there's no point in trying until we at least think we're online.\n\t\t\t\t// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic\n\t\t\t\t// should probably live in the driver.\n\t\t\t\tawait waitForOnline();\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"WaitBetweenConnectionAttempts\",\n\t\t\t\t\tduration: performance.now() - waitStartTime,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tretryDelayFromError,\n\t\t\t\t\t\tdelayMs,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// If we retried more than once, log an event about how long it took (this will not log to error table)\n\t\tif (connectRepeatCount > 1) {\n\t\t\tlogNetworkFailure(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"MultipleDeltaConnectionFailures\",\n\t\t\t\t\tattempts: connectRepeatCount,\n\t\t\t\t\tduration: formatTick(performance.now() - connectStartTime),\n\t\t\t\t},\n\t\t\t\tlastError,\n\t\t\t);\n\t\t}\n\n\t\t// Check for abort signal after while loop as well or we've been disposed\n\t\tif (abortSignal.aborted === true || this._disposed) {\n\t\t\tconnection.dispose();\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"ConnectionAttemptCancelled\",\n\t\t\t\tattempts: connectRepeatCount,\n\t\t\t\tduration: formatTick(performance.now() - connectStartTime),\n\t\t\t\tconnectionEstablished: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setupNewSuccessfulConnection(connection, requestedMode, reason);\n\t}\n\n\t/**\n\t * Start the connection. Any error should result in container being closed.\n\t * And report the error if it escapes for any reason.\n\t * @param args - The connection arguments\n\t */\n\tprivate triggerConnect(reason: IConnectionStateChangeReason, connectionMode: ConnectionMode) {\n\t\t// reconnect() includes async awaits, and that causes potential race conditions\n\t\t// where we might already have a connection. If it were to happen, it's possible that we will connect\n\t\t// with different mode to `connectionMode`. Glancing through the caller chains, it looks like code should be\n\t\t// fine (if needed, reconnect flow will get triggered again). Places where new mode matters should encode it\n\t\t// directly in connectCore - see this.shouldJoinWrite() test as an example.\n\t\t// assert(this.connection === undefined, 0x239 /* \"called only in disconnected state\" */);\n\n\t\tif (this.reconnectMode !== ReconnectMode.Enabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis.connect(reason, connectionMode);\n\t}\n\n\t/**\n\t * Disconnect the current connection.\n\t * @param reason - Text description of disconnect reason to emit with disconnect event\n\t * @param error - Error causing the disconnect if any.\n\t * @returns A boolean that indicates if there was an existing connection (or pending connection) to disconnect\n\t */\n\tprivate disconnectFromDeltaStream(reason: IConnectionStateChangeReason): boolean {\n\t\tthis.pendingReconnect = false;\n\n\t\tif (this.connection === undefined) {\n\t\t\tif (this.pendingConnection !== undefined) {\n\t\t\t\tthis.cancelConnection(reason);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(\n\t\t\tthis.pendingConnection === undefined,\n\t\t\t0x27b /* \"reentrancy may result in incorrect behavior\" */,\n\t\t);\n\n\t\tconst connection = this.connection;\n\t\t// Avoid any re-entrancy - clear object reference\n\t\tthis.connection = undefined;\n\n\t\t// Remove listeners first so we don't try to retrigger this flow accidentally through reconnectOnError\n\t\tconnection.off(\"op\", this.opHandler);\n\t\tconnection.off(\"signal\", this.signalHandler);\n\t\tconnection.off(\"nack\", this.nackHandler);\n\t\tconnection.off(\"disconnect\", this.disconnectHandlerInternal);\n\t\tconnection.off(\"error\", this.errorHandler);\n\t\tconnection.off(\"pong\", this.props.pongHandler);\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis._outbound.pause();\n\t\tthis._outbound.clear();\n\t\tconnection.dispose();\n\n\t\tthis.props.disconnectHandler(reason);\n\n\t\tthis._connectionVerboseProps = {};\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Cancel in-progress connection attempt.\n\t */\n\tprivate cancelConnection(reason: IConnectionStateChangeReason) {\n\t\tassert(\n\t\t\tthis.pendingConnection !== undefined,\n\t\t\t0x345 /* this.pendingConnection is undefined when trying to cancel */,\n\t\t);\n\t\tthis.pendingConnection.abort();\n\t\tthis.pendingConnection = undefined;\n\t\tthis.logger.sendTelemetryEvent({ eventName: \"ConnectionCancelReceived\" });\n\t\tthis.props.cancelConnectionHandler({\n\t\t\ttext: `Cancel Pending Connection due to ${reason.text}`,\n\t\t\terror: reason.error,\n\t\t});\n\t}\n\n\t/**\n\t * Once we've successfully gotten a connection, we need to set up state, attach event listeners, and process\n\t * initial messages.\n\t * @param connection - The newly established connection\n\t */\n\tprivate setupNewSuccessfulConnection(\n\t\tconnection: IDocumentDeltaConnection,\n\t\trequestedMode: ConnectionMode,\n\t\treason: IConnectionStateChangeReason,\n\t) {\n\t\t// Old connection should have been cleaned up before establishing a new one\n\t\tassert(\n\t\t\tthis.connection === undefined,\n\t\t\t0x0e6 /* \"old connection exists on new connection setup\" */,\n\t\t);\n\t\tassert(\n\t\t\t!connection.disposed,\n\t\t\t0x28a /* \"can't be disposed - Callers need to ensure that!\" */,\n\t\t);\n\n\t\tthis.pendingConnection = undefined;\n\n\t\tconst oldReadonlyValue = this.readonly;\n\t\tthis.connection = connection;\n\n\t\t// Does information in scopes & mode matches?\n\t\t// If we asked for \"write\" and got \"read\", then file is read-only\n\t\t// But if we ask read, server can still give us write.\n\t\tconst readonly = !connection.claims.scopes.includes(ScopeType.DocWrite);\n\n\t\tif (connection.mode !== requestedMode) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"ConnectionModeMismatch\",\n\t\t\t\trequestedMode,\n\t\t\t\tmode: connection.mode,\n\t\t\t});\n\t\t}\n\t\t// This connection mode validation logic is moving to the driver layer in 0.44. These two asserts can be\n\t\t// removed after those packages have released and become ubiquitous.\n\t\tassert(\n\t\t\trequestedMode === \"read\" || readonly === (this.connectionMode === \"read\"),\n\t\t\t0x0e7 /* \"claims/connectionMode mismatch\" */,\n\t\t);\n\t\tassert(\n\t\t\t!readonly || this.connectionMode === \"read\",\n\t\t\t0x0e8 /* \"readonly perf with write connection\" */,\n\t\t);\n\n\t\tthis.set_readonlyPermissions(\n\t\t\treadonly,\n\t\t\toldReadonlyValue,\n\t\t\tisNoDeltaStreamConnection(connection) ? connection.readonlyConnectionReason : undefined,\n\t\t);\n\n\t\tif (this._disposed) {\n\t\t\t// Raise proper events, Log telemetry event and close connection.\n\t\t\tthis.disconnectFromDeltaStream({ text: \"ConnectionManager already closed\" });\n\t\t\treturn;\n\t\t}\n\n\t\tthis._outbound.resume();\n\n\t\tconnection.on(\"op\", this.opHandler);\n\t\tconnection.on(\"signal\", this.signalHandler);\n\t\tconnection.on(\"nack\", this.nackHandler);\n\t\tconnection.on(\"disconnect\", this.disconnectHandlerInternal);\n\t\tconnection.on(\"error\", this.errorHandler);\n\t\tconnection.on(\"pong\", this.props.pongHandler);\n\n\t\t// Initial messages are always sorted. However, due to early op handler installed by drivers and appending those\n\t\t// ops to initialMessages, resulting set is no longer sorted, which would result in client hitting storage to\n\t\t// fill in gap. We will recover by cancelling this request once we process remaining ops, but it's a waste that\n\t\t// we could avoid\n\t\tconst initialMessages = connection.initialMessages.sort(\n\t\t\t(a, b) => a.sequenceNumber - b.sequenceNumber,\n\t\t);\n\n\t\t// Some storages may provide checkpointSequenceNumber to identify how far client is behind.\n\t\tlet checkpointSequenceNumber = connection.checkpointSequenceNumber;\n\n\t\tthis._connectionVerboseProps = {\n\t\t\tclientId: connection.clientId,\n\t\t\tmode: connection.mode,\n\t\t};\n\n\t\t// reset connection props\n\t\tthis._connectionProps = {};\n\n\t\tif (connection.relayServiceAgent !== undefined) {\n\t\t\tthis._connectionVerboseProps.relayServiceAgent = connection.relayServiceAgent;\n\t\t\tthis._connectionProps.relayServiceAgent = connection.relayServiceAgent;\n\t\t}\n\t\tthis._connectionProps.socketDocumentId = connection.claims.documentId;\n\t\tthis._connectionProps.connectionMode = connection.mode;\n\n\t\tlet last = -1;\n\t\tif (initialMessages.length !== 0) {\n\t\t\tthis._connectionVerboseProps.connectionInitialOpsFrom =\n\t\t\t\tinitialMessages[0].sequenceNumber;\n\t\t\tlast = initialMessages[initialMessages.length - 1].sequenceNumber;\n\t\t\tthis._connectionVerboseProps.connectionInitialOpsTo = last + 1;\n\t\t\t// Update knowledge of how far we are behind, before raising \"connect\" event\n\t\t\t// This is duplication of what incomingOpHandler() does, but we have to raise event before we get there,\n\t\t\t// so duplicating update logic here as well.\n\t\t\tif (checkpointSequenceNumber === undefined || checkpointSequenceNumber < last) {\n\t\t\t\tcheckpointSequenceNumber = last;\n\t\t\t}\n\t\t}\n\n\t\tthis.props.incomingOpHandler(\n\t\t\tinitialMessages,\n\t\t\tthis.connectFirstConnection ? \"InitialOps\" : \"ReconnectOps\",\n\t\t);\n\n\t\tconst details = ConnectionManager.detailsFromConnection(connection, reason);\n\t\tdetails.checkpointSequenceNumber = checkpointSequenceNumber;\n\t\tthis.props.connectHandler(details);\n\n\t\tthis.connectFirstConnection = false;\n\n\t\t// Synthesize clear & join signals out of initialClients state.\n\t\t// This allows us to have single way to process signals, and makes it simpler to initialize\n\t\t// protocol in Container.\n\t\tconst clearSignal: ISignalMessage = {\n\t\t\tclientId: null, // system message\n\t\t\tcontent: JSON.stringify({\n\t\t\t\ttype: SignalType.Clear,\n\t\t\t}),\n\t\t};\n\n\t\t// list of signals to process due to this new connection\n\t\tlet signalsToProcess: ISignalMessage[] = [clearSignal];\n\n\t\tconst clientJoinSignals: ISignalMessage[] = (connection.initialClients ?? []).map(\n\t\t\t(priorClient) => ({\n\t\t\t\tclientId: null, // system signal\n\t\t\t\tcontent: JSON.stringify({\n\t\t\t\t\ttype: SignalType.ClientJoin,\n\t\t\t\t\tcontent: priorClient, // ISignalClient\n\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t\tif (clientJoinSignals.length > 0) {\n\t\t\tsignalsToProcess = signalsToProcess.concat(clientJoinSignals);\n\t\t}\n\n\t\t// Unfortunately, there is no defined order between initialSignals (including join & leave signals)\n\t\t// and connection.initialClients. In practice, connection.initialSignals quite often contains join signal\n\t\t// for \"self\" and connection.initialClients does not contain \"self\", so we have to process them after\n\t\t// \"clear\" signal above.\n\t\tif (connection.initialSignals !== undefined && connection.initialSignals.length > 0) {\n\t\t\tsignalsToProcess = signalsToProcess.concat(connection.initialSignals);\n\t\t}\n\n\t\tthis.props.signalHandler(signalsToProcess);\n\t}\n\n\t/**\n\t * Disconnect the current connection and reconnect. Closes the container if it fails.\n\t * @param connection - The connection that wants to reconnect - no-op if it's different from this.connection\n\t * @param requestedMode - Read or write\n\t * @param error - Error reconnect information including whether or not to reconnect\n\t * @returns A promise that resolves when the connection is reestablished or we stop trying\n\t */\n\tprivate reconnectOnError(requestedMode: ConnectionMode, error: IAnyDriverError) {\n\t\tthis.reconnect(requestedMode, { text: error.message, error }).catch(\n\t\t\tthis.props.closeHandler,\n\t\t);\n\t}\n\n\t/**\n\t * Disconnect the current connection and reconnect.\n\t * @param connection - The connection that wants to reconnect - no-op if it's different from this.connection\n\t * @param requestedMode - Read or write\n\t * @param error - Error reconnect information including whether or not to reconnect\n\t * @returns A promise that resolves when the connection is reestablished or we stop trying\n\t */\n\tprivate async reconnect(\n\t\trequestedMode: ConnectionMode,\n\t\treason: IConnectionStateChangeReason<IAnyDriverError>,\n\t) {\n\t\t// We quite often get protocol errors before / after observing nack/disconnect\n\t\t// we do not want to run through same sequence twice.\n\t\t// If we're already disconnected/disconnecting it's not appropriate to call this again.\n\t\tassert(this.connection !== undefined, 0x0eb /* \"Missing connection for reconnect\" */);\n\n\t\tthis.disconnectFromDeltaStream(reason);\n\n\t\t// We will always trigger reconnect, even if canRetry is false.\n\t\t// Any truly fatal error state will result in container close upon attempted reconnect,\n\t\t// which is a preferable to closing abruptly when a live connection fails.\n\t\tif (reason.error?.canRetry === false) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"reconnectingDespiteFatalError\",\n\t\t\t\t\treconnectMode: this.reconnectMode,\n\t\t\t\t},\n\t\t\t\treason.error,\n\t\t\t);\n\t\t}\n\n\t\tif (this.reconnectMode === ReconnectMode.Never) {\n\t\t\t// Do not raise container error if we are closing just because we lost connection.\n\t\t\t// Those errors (like IdleDisconnect) would show up in telemetry dashboards and\n\t\t\t// are very misleading, as first initial reaction - some logic is broken.\n\t\t\tthis.props.closeHandler();\n\t\t}\n\n\t\t// If closed then we can't reconnect\n\t\tif (this._disposed || this.reconnectMode !== ReconnectMode.Enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the error tells us to wait before retrying, then do so.\n\t\tconst delayMs = getRetryDelayFromError(reason.error);\n\t\tif (reason.error !== undefined && delayMs !== undefined) {\n\t\t\tthis.props.reconnectionDelayHandler(delayMs, reason.error);\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tsetTimeout(resolve, delayMs);\n\t\t\t});\n\t\t}\n\n\t\t// If we believe we're offline, we assume there's no point in trying again until we at least think we're online.\n\t\t// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic\n\t\t// should probably live in the driver.\n\t\tawait waitForOnline();\n\n\t\tthis.triggerConnect(\n\t\t\t{\n\t\t\t\ttext:\n\t\t\t\t\treason.error !== undefined\n\t\t\t\t\t\t? \"Reconnecting due to Error\"\n\t\t\t\t\t\t: `Reconnecting due to: ${reason.text}`,\n\t\t\t\terror: reason.error,\n\t\t\t},\n\t\t\trequestedMode,\n\t\t);\n\t}\n\n\tpublic prepareMessageToSend(\n\t\tmessage: Omit<IDocumentMessage, \"clientSequenceNumber\">,\n\t): IDocumentMessage | undefined {\n\t\tif (this.readonly === true) {\n\t\t\tassert(\n\t\t\t\tthis.readOnlyInfo.readonly === true,\n\t\t\t\t0x1f0 /* \"Unexpected mismatch in readonly\" */,\n\t\t\t);\n\t\t\tconst error = new GenericError(\"deltaManagerReadonlySubmit\", undefined /* error */, {\n\t\t\t\treadonly: this.readOnlyInfo.readonly,\n\t\t\t\tforcedReadonly: this.readOnlyInfo.forced,\n\t\t\t\treadonlyPermissions: this.readOnlyInfo.permissions,\n\t\t\t\tstorageOnly: this.readOnlyInfo.storageOnly,\n\t\t\t\tstorageOnlyReason: this.readOnlyInfo.storageOnlyReason,\n\t\t\t});\n\t\t\tthis.props.closeHandler(error);\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// reset clientSequenceNumber if we are using new clientId.\n\t\t// we keep info about old connection as long as possible to be able to account for all non-acked ops\n\t\t// that we pick up on next connection.\n\t\tassert(!!this.connection, 0x0e4 /* \"Lost old connection!\" */);\n\t\tif (this.lastSubmittedClientId !== this.connection?.clientId) {\n\t\t\tthis.lastSubmittedClientId = this.connection?.clientId;\n\t\t\tthis.clientSequenceNumber = 0;\n\t\t\tthis.clientSequenceNumberObserved = 0;\n\t\t}\n\n\t\tif (!isRuntimeMessage(message)) {\n\t\t\tthis.localOpsToIgnore++;\n\t\t} else {\n\t\t\tthis.localOpsToIgnore = 0;\n\t\t}\n\n\t\treturn {\n\t\t\t...message,\n\t\t\tclientSequenceNumber: ++this.clientSequenceNumber,\n\t\t};\n\t}\n\n\tpublic submitSignal(content: any, targetClientId?: string) {\n\t\tif (this.connection !== undefined) {\n\t\t\tthis.connection.submitSignal(content, targetClientId);\n\t\t} else {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"submitSignalDisconnected\" });\n\t\t}\n\t}\n\n\tpublic sendMessages(messages: IDocumentMessage[]) {\n\t\tassert(this.connected, 0x2b4 /* \"not connected on sending ops!\" */);\n\t\t// If connection is \"read\" or implicit \"read\" (got leave op for \"write\" connection),\n\t\t// then op can't make it through - we will get a nack if op is sent.\n\t\t// We can short-circuit this process.\n\t\t// Note that we also want nacks to be rare and be treated as catastrophic failures.\n\t\t// Be careful with reentrancy though - disconnected event should not be be raised in the\n\t\t// middle of the current workflow, but rather on clean stack!\n\t\tif (this.connectionMode === \"read\") {\n\t\t\tif (!this.pendingReconnect) {\n\t\t\t\tthis.pendingReconnect = true;\n\t\t\t\tPromise.resolve()\n\t\t\t\t\t.then(async () => {\n\t\t\t\t\t\tif (this.pendingReconnect) {\n\t\t\t\t\t\t\t// still valid?\n\t\t\t\t\t\t\tawait this.reconnect(\n\t\t\t\t\t\t\t\t\"write\", // connectionMode\n\t\t\t\t\t\t\t\t{ text: \"Switch to write\" }, // message\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(() => {});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tassert(!this.pendingReconnect, 0x2b5 /* \"logic error\" */);\n\n\t\tthis._outbound.push(messages);\n\t}\n\n\tpublic beforeProcessingIncomingOp(message: ISequencedDocumentMessage) {\n\t\t// if we have connection, and message is local, then we better treat is as local!\n\t\tassert(\n\t\t\tthis.clientId !== message.clientId || this.lastSubmittedClientId === message.clientId,\n\t\t\t0x0ee /* \"Not accounting local messages correctly\" */,\n\t\t);\n\n\t\tif (\n\t\t\tthis.lastSubmittedClientId !== undefined &&\n\t\t\tthis.lastSubmittedClientId === message.clientId\n\t\t) {\n\t\t\tconst clientSequenceNumber = message.clientSequenceNumber;\n\n\t\t\tassert(\n\t\t\t\tthis.clientSequenceNumberObserved < clientSequenceNumber,\n\t\t\t\t0x0ef /* \"client seq# not growing\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tclientSequenceNumber <= this.clientSequenceNumber,\n\t\t\t\t0x0f0 /* \"Incoming local client seq# > generated by this client\" */,\n\t\t\t);\n\n\t\t\tthis.clientSequenceNumberObserved = clientSequenceNumber;\n\t\t}\n\n\t\tif (message.type === MessageType.ClientLeave) {\n\t\t\tconst systemLeaveMessage = message as ISequencedDocumentSystemMessage;\n\t\t\tconst clientId = JSON.parse(systemLeaveMessage.data) as string;\n\t\t\tif (clientId === this.clientId) {\n\t\t\t\t// We have been kicked out from quorum\n\t\t\t\tthis.logger.sendPerformanceEvent({ eventName: \"ReadConnectionTransition\" });\n\n\t\t\t\t// Please see #8483 for more details on why maintaining connection further as is would not work.\n\t\t\t\t// Short story - connection properties are immutable, and many processes (consensus DDSes, summarizer)\n\t\t\t\t// assume that connection stays \"write\" connection until disconnect, and act accordingly, which may\n\t\t\t\t// not work well with de-facto \"read\" connection we are in after receiving own leave op on timeout.\n\t\t\t\t// Clients need to be able to transition to \"read\" state after some time of inactivity!\n\t\t\t\t// Note - this may close container!\n\t\t\t\tthis.reconnect(\n\t\t\t\t\t\"read\", // connectionMode\n\t\t\t\t\t{ text: \"Switch to read\" }, // message\n\t\t\t\t).catch((error) => {\n\t\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"SwitchToReadConnection\" }, error);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly opHandler = (documentId: string, messagesArg: ISequencedDocumentMessage[]) => {\n\t\tconst messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];\n\t\tthis.props.incomingOpHandler(messages, \"opHandler\");\n\t};\n\n\tprivate readonly signalHandler = (signalsArg: ISignalMessage | ISignalMessage[]) => {\n\t\tconst signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];\n\t\tthis.props.signalHandler(signals);\n\t};\n\n\t// Always connect in write mode after getting nacked.\n\tprivate readonly nackHandler = (documentId: string, messages: INack[]) => {\n\t\tconst message = messages[0];\n\t\tif (this._readonlyPermissions === true) {\n\t\t\tthis.props.closeHandler(\n\t\t\t\tcreateWriteError(\"writeOnReadOnlyDocument\", { driverVersion: undefined }),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst reconnectInfo = getNackReconnectInfo(message.content);\n\n\t\t// If the nack indicates we cannot retry, then close the container outright\n\t\tif (!reconnectInfo.canRetry) {\n\t\t\tthis.props.closeHandler(reconnectInfo);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.reconnectOnError(\"write\", reconnectInfo);\n\t};\n\n\t// Connection mode is always read on disconnect/error unless the system mode was write.\n\tprivate readonly disconnectHandlerInternal = (disconnectReason: IAnyDriverError) => {\n\t\t// Note: we might get multiple disconnect calls on same socket, as early disconnect notification\n\t\t// (\"server_disconnect\", ODSP-specific) is mapped to \"disconnect\"\n\t\tthis.reconnectOnError(this.defaultReconnectionMode, disconnectReason);\n\t};\n\n\tprivate readonly errorHandler = (error: IAnyDriverError) => {\n\t\tthis.reconnectOnError(this.defaultReconnectionMode, error);\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"connectionState.cjs","sourceRoot":"","sources":["../src/connectionState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,IAAY,eAuBX;AAvBD,WAAY,eAAe;IAC1B;;;;OAIG;IACH,qEAAgB,CAAA;IAEhB;;;OAGG;IACH,yFAA0B,CAAA;IAE1B;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,+DAAa,CAAA;AACd,CAAC,EAvBW,eAAe,+BAAf,eAAe,QAuB1B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @internal\n */\nexport enum ConnectionState {\n\t/**\n\t * The container is not connected to the ordering service\n\t * Note - When in this state the container may be about to reconnect,\n\t * or may remain disconnected until explicitly told to connect.\n\t */\n\tDisconnected = 0,\n\n\t/**\n\t * The container is disconnected but actively trying to establish a new connection\n\t * PLEASE NOTE that this numerical value falls out of the order you may expect for this state\n\t */\n\tEstablishingConnection = 3,\n\n\t/**\n\t * The container has an inbound connection only, and is catching up to the latest known state from the service.\n\t */\n\tCatchingUp = 1,\n\n\t/**\n\t * The container is fully connected and syncing\n\t */\n\tConnected = 2,\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"connectionStateHandler.cjs","sourceRoot":"","sources":["../src/connectionStateHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA2D;AAG3D,qEAIyC;AAEzC,yDAAmE;AACnE,2DAAoD;AAIpD,qGAAqG;AACrG,kGAAkG;AAClG,iEAAiE;AACjE,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,2DAA2D;AAC3D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AA8CjC,SAAgB,4BAA4B,CAC3C,MAAqC,EACrC,YAAqC,EACrC,QAAiB;IAEjB,MAAM,EAAE,GAAG,IAAA,2CAAyB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpD,OAAO,gCAAgC,CACtC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,iDAAiD,CAAC,KAAK,IAAI,EAAE,8BAA8B;IAChH,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,sCAAsC,CAAC,KAAK,IAAI,EAAE,+BAA+B;IACtG,MAAM,EACN,YAAY,EACZ,QAAQ,CACR,CAAC;AACH,CAAC;AAbD,oEAaC;AAED,SAAgB,gCAAgC,CAC/C,2BAAoC,EACpC,4BAAqC,EACrC,MAAqC,EACrC,YAAqC,EACrC,QAAiB;IAEjB,IAAI,CAAC,2BAA2B,EAAE;QACjC,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,4BAA4B,E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vC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,EAAE;YAChD,IAAA,mBAAM,EACL,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,SAAS,EACjD,KAAK,CAAC,kCAAkC,CACxC,CAAC;YACF,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH;;;;;;UAMQ;QACR,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;YACzC,oEAAoE;YACpE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,eAAgB,CAAC,CAAC;SACnD;QAED,wFAAwF;QACxF,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACjE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;SACnC;IACF,CAAC;IAES,SAAS,CAAC,QAAiB;QACpC,OAAO,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC;IACjE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties, TelemetryEventCategory } from \"@fluidframework/core-interfaces\";\nimport { assert, Timer } from \"@fluidframework/core-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { ISequencedClient, IClient } from \"@fluidframework/protocol-definitions\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { IAnyDriverError } from \"@fluidframework/driver-definitions\";\nimport { CatchUpMonitor, ICatchUpMonitor } from \"./catchUpMonitor\";\nimport { ConnectionState } from \"./connectionState\";\nimport { IConnectionDetailsInternal, IConnectionStateChangeReason } from \"./contracts\";\nimport { IProtocolHandler } from \"./protocol\";\n\n// Based on recent data, it looks like majority of cases where we get stuck are due to really slow or\n// timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so\n// if retrying fixes the problem, we should not see these events.\nconst JoinOpTimeoutMs = 45000;\n\n// Timeout waiting for \"self\" join signal, before giving up\nconst JoinSignalTimeoutMs = 5000;\n\n/** Constructor parameter type for passing in dependencies needed by the ConnectionStateHandler */\nexport interface IConnectionStateHandlerInputs {\n\tlogger: ITelemetryLoggerExt;\n\t/** Log to telemetry any change in state, included to Connecting */\n\tconnectionStateChanged: (\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason,\n\t) => void;\n\t/** Whether to expect the client to join in write mode on next connection */\n\tshouldClientJoinWrite: () => boolean;\n\t/** (Optional) How long should we wait on our previous client's Leave op before transitioning to Connected again */\n\tmaxClientLeaveWaitTime: number | undefined;\n\t/** Log an issue encountered while in the Connecting state. details will be logged as a JSON string */\n\tlogConnectionIssue: (\n\t\teventName: string,\n\t\tcategory: TelemetryEventCategory,\n\t\tdetails?: ITelemetryProperties,\n\t) => void;\n\t/** Callback to note that an old local client ID is still present in the Quorum that should have left and should now be considered invalid */\n\tclientShouldHaveLeft: (clientId: string) => void;\n}\n\n/**\n * interface that connection state handler implements\n */\nexport interface IConnectionStateHandler {\n\treadonly connectionState: ConnectionState;\n\treadonly pendingClientId: string | undefined;\n\n\tcontainerSaved(): void;\n\tdispose(): void;\n\tinitProtocol(protocol: IProtocolHandler): void;\n\treceivedConnectEvent(details: IConnectionDetailsInternal): void;\n\treceivedDisconnectEvent(reason: IConnectionStateChangeReason): void;\n\testablishingConnection(reason: IConnectionStateChangeReason): void;\n\t/**\n\t * Switches state to disconnected when we are still establishing connection during container.load(),\n\t * container connect() or reconnect and the container gets closed or disposed or disconnect happens.\n\t * @param reason - reason for cancelling the connection.\n\t */\n\tcancelEstablishingConnection(reason: IConnectionStateChangeReason): void;\n}\n\nexport function createConnectionStateHandler(\n\tinputs: IConnectionStateHandlerInputs,\n\tdeltaManager: IDeltaManager<any, any>,\n\tclientId?: string,\n) {\n\tconst mc = loggerToMonitoringContext(inputs.logger);\n\treturn createConnectionStateHandlerCore(\n\t\tmc.config.getBoolean(\"Fluid.Container.CatchUpBeforeDeclaringConnected\") === true, // connectedRaisedWhenCaughtUp\n\t\tmc.config.getBoolean(\"Fluid.Container.EnableJoinSignalWait\") === true, // readClientsWaitForJoinSignal\n\t\tinputs,\n\t\tdeltaManager,\n\t\tclientId,\n\t);\n}\n\nexport function createConnectionStateHandlerCore(\n\tconnectedRaisedWhenCaughtUp: boolean,\n\treadClientsWaitForJoinSignal: boolean,\n\tinputs: IConnectionStateHandlerInputs,\n\tdeltaManager: IDeltaManager<any, any>,\n\tclientId?: string,\n) {\n\tif (!connectedRaisedWhenCaughtUp) {\n\t\treturn new ConnectionStateHandler(inputs, readClientsWaitForJoinSignal, clientId);\n\t}\n\treturn new ConnectionStateCatchup(\n\t\tinputs,\n\t\t(handler: IConnectionStateHandlerInputs) =>\n\t\t\tnew ConnectionStateHandler(handler, readClientsWaitForJoinSignal, clientId),\n\t\tdeltaManager,\n\t);\n}\n\n/**\n * Helper internal interface to abstract away Audience & Quorum\n */\ninterface IMembership {\n\ton(\n\t\teventName: \"addMember\" | \"removeMember\",\n\t\tlistener: (clientId: string, details: IClient | ISequencedClient) => void,\n\t);\n\tgetMember(clientId: string): undefined | unknown;\n}\n\n/**\n * Class that can be used as a base class for building IConnectionStateHandler adapters / pipeline.\n * It implements both ends of communication interfaces and passes data back and forward\n */\nclass ConnectionStateHandlerPassThrough\n\timplements IConnectionStateHandler, IConnectionStateHandlerInputs\n{\n\tprotected readonly pimpl: IConnectionStateHandler;\n\n\tconstructor(\n\t\tprotected readonly inputs: IConnectionStateHandlerInputs,\n\t\tpimplFactory: (handler: IConnectionStateHandlerInputs) => IConnectionStateHandler,\n\t) {\n\t\tthis.pimpl = pimplFactory(this);\n\t}\n\n\t/**\n\t * IConnectionStateHandler\n\t */\n\tpublic get connectionState() {\n\t\treturn this.pimpl.connectionState;\n\t}\n\tpublic get pendingClientId() {\n\t\treturn this.pimpl.pendingClientId;\n\t}\n\n\tpublic containerSaved() {\n\t\treturn this.pimpl.containerSaved();\n\t}\n\tpublic dispose() {\n\t\treturn this.pimpl.dispose();\n\t}\n\tpublic initProtocol(protocol: IProtocolHandler) {\n\t\treturn this.pimpl.initProtocol(protocol);\n\t}\n\tpublic receivedDisconnectEvent(reason: IConnectionStateChangeReason<IAnyDriverError>) {\n\t\treturn this.pimpl.receivedDisconnectEvent(reason);\n\t}\n\n\tpublic establishingConnection(reason: IConnectionStateChangeReason) {\n\t\treturn this.pimpl.establishingConnection(reason);\n\t}\n\n\tpublic cancelEstablishingConnection(reason: IConnectionStateChangeReason) {\n\t\treturn this.pimpl.cancelEstablishingConnection(reason);\n\t}\n\n\tpublic receivedConnectEvent(details: IConnectionDetailsInternal) {\n\t\treturn this.pimpl.receivedConnectEvent(details);\n\t}\n\n\t/**\n\t * IConnectionStateHandlerInputs\n\t */\n\n\tpublic get logger() {\n\t\treturn this.inputs.logger;\n\t}\n\tpublic connectionStateChanged(\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason,\n\t) {\n\t\treturn this.inputs.connectionStateChanged(value, oldState, reason);\n\t}\n\tpublic shouldClientJoinWrite() {\n\t\treturn this.inputs.shouldClientJoinWrite();\n\t}\n\tpublic get maxClientLeaveWaitTime() {\n\t\treturn this.inputs.maxClientLeaveWaitTime;\n\t}\n\tpublic logConnectionIssue(\n\t\teventName: string,\n\t\tcategory: TelemetryEventCategory,\n\t\tdetails?: ITelemetryProperties,\n\t) {\n\t\treturn this.inputs.logConnectionIssue(eventName, category, details);\n\t}\n\tpublic clientShouldHaveLeft(clientId: string) {\n\t\treturn this.inputs.clientShouldHaveLeft(clientId);\n\t}\n}\n\n/**\n * Implementation of IConnectionStateHandler pass-through adapter that waits for specific sequence number\n * before raising connected event\n */\nclass ConnectionStateCatchup extends ConnectionStateHandlerPassThrough {\n\tprivate catchUpMonitor: ICatchUpMonitor | undefined;\n\n\tconstructor(\n\t\tinputs: IConnectionStateHandlerInputs,\n\t\tpimplFactory: (handler: IConnectionStateHandlerInputs) => IConnectionStateHandler,\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t) {\n\t\tsuper(inputs, pimplFactory);\n\t\tthis._connectionState = this.pimpl.connectionState;\n\t}\n\n\tprivate _connectionState: ConnectionState;\n\tpublic get connectionState() {\n\t\treturn this._connectionState;\n\t}\n\n\tpublic connectionStateChanged(\n\t\tvalue: ConnectionState,\n\t\toldState: ConnectionState,\n\t\treason?: IConnectionStateChangeReason<IAnyDriverError>,\n\t) {\n\t\tswitch (value) {\n\t\t\tcase ConnectionState.Connected:\n\t\t\t\tassert(\n\t\t\t\t\tthis._connectionState === ConnectionState.CatchingUp,\n\t\t\t\t\t0x3e1 /* connectivity transitions */,\n\t\t\t\t);\n\t\t\t\t// Create catch-up monitor here (not earlier), as we might get more exact info by now about how far\n\t\t\t\t// client is behind through join signal. This is only true if base layer uses signals (i.e. audience,\n\t\t\t\t// not quorum, including for \"rea\" connections) to make decisions about moving to \"connected\" state.\n\t\t\t\t// In addition to that, in its current form, doing this in ConnectionState.CatchingUp is dangerous as\n\t\t\t\t// we might get callback right away, and it will screw up state transition (as code outside of switch\n\t\t\t\t// statement will overwrite current state).\n\t\t\t\tassert(\n\t\t\t\t\tthis.catchUpMonitor === undefined,\n\t\t\t\t\t0x3eb /* catchUpMonitor should be gone */,\n\t\t\t\t);\n\t\t\t\tthis.catchUpMonitor = new CatchUpMonitor(\n\t\t\t\t\tthis.deltaManager,\n\t\t\t\t\tthis.transitionToConnectedState,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase ConnectionState.Disconnected:\n\t\t\t\tthis.catchUpMonitor?.dispose();\n\t\t\t\tthis.catchUpMonitor = undefined;\n\t\t\t\tbreak;\n\t\t\t// ConnectionState.EstablishingConnection state would be set when we start establishing connection\n\t\t\t// during container.connect() or reconnect because of an error.\n\t\t\tcase ConnectionState.EstablishingConnection:\n\t\t\t\tassert(\n\t\t\t\t\tthis._connectionState === ConnectionState.Disconnected,\n\t\t\t\t\t0x6d2 /* connectivity transition to establishing connection */,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase ConnectionState.CatchingUp:\n\t\t\t\tassert(\n\t\t\t\t\tthis._connectionState === ConnectionState.EstablishingConnection,\n\t\t\t\t\t0x3e3 /* connectivity transitions */,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t}\n\t\tthis._connectionState = value;\n\t\tthis.inputs.connectionStateChanged(value, oldState, reason);\n\t}\n\n\tprivate readonly transitionToConnectedState = () => {\n\t\t// Defensive measure, we should always be in Connecting state when this is called.\n\t\tconst state = this.pimpl.connectionState;\n\t\tassert(state === ConnectionState.Connected, 0x3e5 /* invariant broken */);\n\t\tassert(this._connectionState === ConnectionState.CatchingUp, 0x3e6 /* invariant broken */);\n\t\tthis._connectionState = ConnectionState.Connected;\n\t\tthis.inputs.connectionStateChanged(ConnectionState.Connected, ConnectionState.CatchingUp, {\n\t\t\ttext: \"caught up\",\n\t\t});\n\t};\n}\n\n/**\n * In the lifetime of a container, the connection will likely disconnect and reconnect periodically.\n * This class ensures that any ops sent by this container instance on previous connection are either\n * sequenced or blocked by the server before emitting the new \"connected\" event and allowing runtime to resubmit ops.\n *\n * Each connection is assigned a clientId by the service, and the connection is book-ended by a Join and a Leave op\n * generated by the service. Due to the distributed nature of the Relay Service, in the case of reconnect we cannot\n * make any assumptions about ordering of operations between the old and new connections - i.e. new Join op could\n * be sequenced before old Leave op (and some acks from pending ops that were in flight when we disconnected).\n *\n * The job of this class is to encapsulate the transition period during reconnect, which is identified by\n * ConnectionState.CatchingUp. Specifically, before moving to Connected state with the new clientId, it ensures that:\n *\n * a. We process the Leave op for the previous clientId. This allows us to properly handle any acks from in-flight ops\n * that got sequenced with the old clientId (we'll recognize them as local ops). After the Leave op, any other\n * pending ops can safely be submitted with the new clientId without fear of duplication in the sequenced op stream.\n *\n * b. We process the Join op for the new clientId (identified when the underlying connection was first established),\n * indicating the service is ready to sequence ops sent with the new clientId.\n *\n * c. We process all ops known at the time the underlying connection was established (so we are \"caught up\")\n *\n * For (a) we give up waiting after some time (same timeout as server uses), and go ahead and transition to Connected.\n *\n * For (b) we log telemetry if it takes too long, but still only transition to Connected when the Join op/signal is\n * processed.\n *\n * For (c) this is optional behavior, controlled by the parameters of receivedConnectEvent\n */\nclass ConnectionStateHandler implements IConnectionStateHandler {\n\tprivate _connectionState = ConnectionState.Disconnected;\n\tprivate _pendingClientId: string | undefined;\n\n\t/**\n\t * Tracks that we observe the \"leave\" op within the timeout for our previous clientId (see comment on ConnectionStateHandler class)\n\t * ! This ensures we do not switch to a new clientId until we process all potential messages from old clientId\n\t * ! i.e. We will always see the \"leave\" op for a client after we have seen all the ops it has sent\n\t * ! This check helps prevent the same op from being resubmitted by the PendingStateManager upon reconnecting\n\t */\n\tprivate readonly prevClientLeftTimer: Timer;\n\n\t/**\n\t * Tracks that we observe our own \"join\" op within the timeout after receiving a \"connected\" event from the DeltaManager\n\t */\n\tprivate readonly joinOpTimer: Timer;\n\n\tprivate protocol?: IProtocolHandler;\n\tprivate connection?: IConnectionDetailsInternal;\n\tprivate _clientId?: string;\n\n\t/** Track how long we waited to see \"leave\" op for previous clientId */\n\tprivate waitEvent: PerformanceEvent | undefined;\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this._connectionState;\n\t}\n\n\tprivate get clientId(): string | undefined {\n\t\treturn this._clientId;\n\t}\n\n\tpublic get pendingClientId(): string | undefined {\n\t\treturn this._pendingClientId;\n\t}\n\n\tconstructor(\n\t\tprivate readonly handler: IConnectionStateHandlerInputs,\n\t\tprivate readonly readClientsWaitForJoinSignal: boolean,\n\t\tclientIdFromPausedSession?: string,\n\t) {\n\t\tthis._clientId = clientIdFromPausedSession;\n\t\tthis.prevClientLeftTimer = new Timer(\n\t\t\t// Default is 5 min for which we are going to wait for its own \"leave\" message. This is same as\n\t\t\t// the max time on server after which leave op is sent.\n\t\t\tthis.handler.maxClientLeaveWaitTime ?? 300000,\n\t\t\t() => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.connectionState !== ConnectionState.Connected,\n\t\t\t\t\t0x2ac /* \"Connected when timeout waiting for leave from previous session fired!\" */,\n\t\t\t\t);\n\t\t\t\tthis.applyForConnectedState(\"timeout\");\n\t\t\t},\n\t\t);\n\n\t\tthis.joinOpTimer = new Timer(\n\t\t\t0, // default value is not used - startJoinOpTimer() explicitly provides timeout\n\t\t\t() => {\n\t\t\t\t// I've observed timer firing within couple ms from disconnect event, looks like\n\t\t\t\t// queued timer callback is not cancelled if timer is cancelled while callback sits in the queue.\n\t\t\t\tif (this.connectionState !== ConnectionState.CatchingUp) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst details = {\n\t\t\t\t\tprotocolInitialized: this.protocol !== undefined,\n\t\t\t\t\tpendingClientId: this.pendingClientId,\n\t\t\t\t\tclientJoined: this.hasMember(this.pendingClientId),\n\t\t\t\t\twaitingForLeaveOp: this.waitingForLeaveOp,\n\t\t\t\t};\n\t\t\t\tthis.handler.logConnectionIssue(\"NoJoinOp\", \"error\", details);\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate startJoinOpTimer() {\n\t\tassert(!this.joinOpTimer.hasTimer, 0x234 /* \"has joinOpTimer\" */);\n\t\tassert(this.connection !== undefined, 0x4b3 /* have connection */);\n\t\tthis.joinOpTimer.start(\n\t\t\tthis.connection.mode === \"write\" ? JoinOpTimeoutMs : JoinSignalTimeoutMs,\n\t\t);\n\t}\n\n\tprivate stopJoinOpTimer() {\n\t\tassert(this.joinOpTimer.hasTimer, 0x235 /* \"no joinOpTimer\" */);\n\t\tthis.joinOpTimer.clear();\n\t}\n\n\tprivate get waitingForLeaveOp() {\n\t\treturn this.prevClientLeftTimer.hasTimer;\n\t}\n\n\tpublic dispose() {\n\t\tassert(!this.joinOpTimer.hasTimer, 0x2a5 /* \"join timer\" */);\n\t\tthis.prevClientLeftTimer.clear();\n\t}\n\n\tpublic containerSaved() {\n\t\t// If we were waiting for moving to Connected state, then only apply for state change. Since the container\n\t\t// is now saved and we don't have any ops to roundtrip, we can clear the timer and apply for connected state.\n\t\tif (this.waitingForLeaveOp) {\n\t\t\tthis.prevClientLeftTimer.clear();\n\t\t\tthis.applyForConnectedState(\"containerSaved\");\n\t\t}\n\t}\n\n\tprivate receivedAddMemberEvent(clientId: string) {\n\t\t// This is the only one that requires the pending client ID\n\t\tif (clientId === this.pendingClientId) {\n\t\t\tif (this.joinOpTimer.hasTimer) {\n\t\t\t\tthis.stopJoinOpTimer();\n\t\t\t} else if (this.shouldWaitForJoinSignal()) {\n\t\t\t\t// timer has already fired, meaning it took too long to get join op/signal.\n\t\t\t\t// Record how long it actually took to recover.\n\t\t\t\t// This is generic event, as it by itself is not an error.\n\t\t\t\t// We also have a case where NoJoinOp happens during container boot (we do not report it as error in such case),\n\t\t\t\t// if this log statement happens after boot - we do not want to consider it error case.\n\t\t\t\tthis.handler.logConnectionIssue(\"ReceivedJoinOp\", \"generic\");\n\t\t\t}\n\t\t\t// Start the event in case we are waiting for leave or timeout.\n\t\t\tif (this.waitingForLeaveOp) {\n\t\t\t\tthis.waitEvent = PerformanceEvent.start(this.handler.logger, {\n\t\t\t\t\teventName: \"WaitBeforeClientLeave\",\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\twaitOnClientId: this._clientId,\n\t\t\t\t\t\thadOutstandingOps: this.handler.shouldClientJoinWrite(),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.applyForConnectedState(\"addMemberEvent\");\n\t\t} else if (clientId === this.clientId) {\n\t\t\t// If we see our clientId and it's not also our pending ID, it's our own join op\n\t\t\t// being replayed, so start the timer in case our previous client is still in quorum\n\t\t\tassert(\n\t\t\t\t!this.waitingForLeaveOp,\n\t\t\t\t0x5d2 /* Unexpected join op with current clientId while waiting */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.connectionState !== ConnectionState.Connected,\n\t\t\t\t0x5d3 /* Unexpected join op with current clientId while connected */,\n\t\t\t);\n\t\t\tthis.prevClientLeftTimer.restart();\n\t\t}\n\t}\n\n\tprivate applyForConnectedState(\n\t\tsource: \"removeMemberEvent\" | \"addMemberEvent\" | \"timeout\" | \"containerSaved\",\n\t) {\n\t\tassert(\n\t\t\tthis.protocol !== undefined,\n\t\t\t0x236 /* \"In all cases it should be already installed\" */,\n\t\t);\n\n\t\tassert(\n\t\t\t!this.waitingForLeaveOp || this.hasMember(this.clientId),\n\t\t\t0x2e2 /* \"Must only wait for leave message when clientId in quorum\" */,\n\t\t);\n\n\t\t// Move to connected state only if:\n\t\t// 1. We have seen our own \"join\" op (i.e. for this.pendingClientId)\n\t\t// 2. There is no \"leave\" timer running, meaning this is our first connection or the previous client has left (via this.prevClientLeftTimer)\n\t\tif (\n\t\t\tthis.pendingClientId !== this.clientId &&\n\t\t\tthis.hasMember(this.pendingClientId) &&\n\t\t\t!this.waitingForLeaveOp\n\t\t) {\n\t\t\tthis.waitEvent?.end({ source });\n\t\t\tthis.setConnectionState(ConnectionState.Connected);\n\t\t} else {\n\t\t\t// Adding this event temporarily so that we can get help debugging if something goes wrong.\n\t\t\t// We may not see any ops due to being disconnected all that time - that's not an error!\n\t\t\tconst error =\n\t\t\t\tsource === \"timeout\" && this.connectionState !== ConnectionState.Disconnected;\n\t\t\tthis.handler.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"connectedStateRejected\",\n\t\t\t\tcategory: error ? \"error\" : \"generic\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tsource,\n\t\t\t\t\tpendingClientId: this.pendingClientId,\n\t\t\t\t\tclientId: this.clientId,\n\t\t\t\t\twaitingForLeaveOp: this.waitingForLeaveOp,\n\t\t\t\t\tclientJoined: this.hasMember(this.pendingClientId),\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate receivedRemoveMemberEvent(clientId: string) {\n\t\t// If the client which has left was us, then finish the timer.\n\t\tif (this.clientId === clientId) {\n\t\t\tthis.prevClientLeftTimer.clear();\n\t\t\tthis.applyForConnectedState(\"removeMemberEvent\");\n\t\t}\n\t}\n\n\tpublic receivedDisconnectEvent(reason: IConnectionStateChangeReason<IAnyDriverError>) {\n\t\tthis.connection = undefined;\n\t\tthis.setConnectionState(ConnectionState.Disconnected, reason);\n\t}\n\n\tpublic cancelEstablishingConnection(reason: IConnectionStateChangeReason) {\n\t\tassert(\n\t\t\tthis._connectionState === ConnectionState.EstablishingConnection,\n\t\t\t0x6d3 /* Connection state should be EstablishingConnection */,\n\t\t);\n\t\tassert(this.connection === undefined, 0x6d4 /* No connetion should be present */);\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = ConnectionState.Disconnected;\n\t\tthis.handler.connectionStateChanged(ConnectionState.Disconnected, oldState, reason);\n\t}\n\n\tpublic establishingConnection(reason: IConnectionStateChangeReason) {\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = ConnectionState.EstablishingConnection;\n\t\tthis.handler.connectionStateChanged(ConnectionState.EstablishingConnection, oldState, {\n\t\t\ttext: `Establishing Connection due to ${reason.text}`,\n\t\t\terror: reason.error,\n\t\t});\n\t}\n\n\tprivate shouldWaitForJoinSignal() {\n\t\tassert(\n\t\t\tthis.connection !== undefined,\n\t\t\t0x4b4 /* all callers call here with active connection */,\n\t\t);\n\t\treturn this.connection.mode === \"write\" || this.readClientsWaitForJoinSignal;\n\t}\n\n\t/**\n\t * The \"connect\" event indicates the connection to the Relay Service is live.\n\t * However, some additional conditions must be met before we can fully transition to\n\t * \"Connected\" state. This function handles that interim period, known as \"Connecting\" state.\n\t * @param details - Connection details returned from the Relay Service\n\t * @param deltaManager - DeltaManager to be used for delaying Connected transition until caught up.\n\t * If it's undefined, then don't delay and transition to Connected as soon as Leave/Join op are accounted for\n\t */\n\tpublic receivedConnectEvent(details: IConnectionDetailsInternal) {\n\t\tthis.connection = details;\n\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = ConnectionState.CatchingUp;\n\n\t\t// The following checks are wrong. They are only valid if user has write access to a file.\n\t\t// If user lost such access mid-session, user will not be able to get \"write\" connection.\n\t\t//\n\t\t// const writeConnection = details.mode === \"write\";\n\t\t// assert(!this.handler.shouldClientJoinWrite() || writeConnection,\n\t\t// 0x30a /* shouldClientJoinWrite should imply this is a writeConnection */);\n\t\t// assert(!this.waitingForLeaveOp || writeConnection,\n\t\t// 0x2a6 /* \"waitingForLeaveOp should imply writeConnection (we need to be ready to flush pending ops)\" */);\n\n\t\t// Stash the clientID to detect when transitioning from connecting (socket.io channel open) to connected\n\t\t// (have received the join message for the client ID)\n\t\t// This is especially important in the reconnect case. It's possible there could be outstanding\n\t\t// ops sent by this client, so we should keep the old client id until we see our own client's\n\t\t// join message. after we see the join message for our new connection with our new client id,\n\t\t// we know there can no longer be outstanding ops that we sent with the previous client id.\n\t\tthis._pendingClientId = details.clientId;\n\n\t\t// IMPORTANT: Report telemetry after we set _pendingClientId, but before transitioning to Connected state\n\t\tthis.handler.connectionStateChanged(ConnectionState.CatchingUp, oldState, details.reason);\n\n\t\t// Check if we need to wait for join op/signal, and if we need to wait for leave op from previous connection.\n\t\t// Pending clientId could have joined already (i.e. join op/signal already processed):\n\t\t// We are fetching ops from storage in parallel to connecting to Relay Service,\n\t\t// and given async processes, it's possible that we have already processed our own join message before\n\t\t// connection was fully established.\n\t\tif (!this.hasMember(this._pendingClientId) && this.shouldWaitForJoinSignal()) {\n\t\t\t// We are waiting for our own join op / signal. When it is processed\n\t\t\t// we'll attempt to transition to Connected state via receivedAddMemberEvent() flow.\n\t\t\tthis.startJoinOpTimer();\n\t\t} else if (!this.waitingForLeaveOp) {\n\t\t\t// We're not waiting for Join or Leave op (if read-only connection those don't even apply),\n\t\t\t// go ahead and declare the state to be Connected!\n\t\t\t// If we are waiting for Leave op still, do nothing for now, we will transition to Connected later.\n\t\t\tthis.setConnectionState(ConnectionState.Connected);\n\t\t}\n\t\t// else - We are waiting for Leave op still, do nothing for now, we will transition to Connected later\n\t}\n\n\tprivate setConnectionState(\n\t\tvalue: ConnectionState.Disconnected,\n\t\treason: IConnectionStateChangeReason,\n\t): void;\n\tprivate setConnectionState(value: ConnectionState.Connected): void;\n\tprivate setConnectionState(\n\t\tvalue: ConnectionState.Disconnected | ConnectionState.Connected,\n\t\treason?: IConnectionStateChangeReason,\n\t): void {\n\t\tif (this.connectionState === value) {\n\t\t\t// Already in the desired state - exit early\n\t\t\tthis.handler.logger.sendErrorEvent({ eventName: \"setConnectionStateSame\", value });\n\t\t\treturn;\n\t\t}\n\n\t\tconst oldState = this._connectionState;\n\t\tthis._connectionState = value;\n\n\t\t// This is the only place in code that deals with quorum. The rest works with audience\n\t\t// The code below ensures that we do not send ops until we know that old \"write\" client's disconnect\n\t\t// produced (and sequenced) leave op\n\t\tconst currentClientInQuorum =\n\t\t\tthis._clientId !== undefined &&\n\t\t\tthis.protocol?.quorum?.getMember(this._clientId) !== undefined;\n\t\tif (value === ConnectionState.Connected) {\n\t\t\tassert(\n\t\t\t\toldState === ConnectionState.CatchingUp,\n\t\t\t\t0x1d8 /* \"Should only transition from Connecting state\" */,\n\t\t\t);\n\t\t\t// Mark our old client should have left in the quorum if it's still there\n\t\t\tif (currentClientInQuorum) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.handler.clientShouldHaveLeft(this._clientId!);\n\t\t\t}\n\t\t\tthis._clientId = this.pendingClientId;\n\t\t} else if (value === ConnectionState.Disconnected) {\n\t\t\t// Clear pending state immediately to prepare for reconnect\n\t\t\tthis._pendingClientId = undefined;\n\n\t\t\tif (this.joinOpTimer.hasTimer) {\n\t\t\t\tthis.stopJoinOpTimer();\n\t\t\t}\n\n\t\t\t// Only wait for \"leave\" message if the connected client exists in the quorum and had some non-acked ops\n\t\t\t// Also check if the timer is not already running as\n\t\t\t// we could receive \"Disconnected\" event multiple times without getting connected and in that case we\n\t\t\t// don't want to reset the timer as we still want to wait on original client which started this timer.\n\t\t\tif (\n\t\t\t\tcurrentClientInQuorum &&\n\t\t\t\tthis.handler.shouldClientJoinWrite() &&\n\t\t\t\t!this.waitingForLeaveOp // same as !this.prevClientLeftTimer.hasTimer\n\t\t\t) {\n\t\t\t\tthis.prevClientLeftTimer.restart();\n\t\t\t} else {\n\t\t\t\t// Adding this event temporarily so that we can get help debugging if something goes wrong.\n\t\t\t\tthis.handler.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"noWaitOnDisconnected\",\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tclientId: this._clientId,\n\t\t\t\t\t\tinQuorum: currentClientInQuorum,\n\t\t\t\t\t\twaitingForLeaveOp: this.waitingForLeaveOp,\n\t\t\t\t\t\thadOutstandingOps: this.handler.shouldClientJoinWrite(),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Report transition before we propagate event across layers\n\t\tthis.handler.connectionStateChanged(this._connectionState, oldState, reason);\n\t}\n\n\t// Helper method to switch between quorum and audience.\n\t// Old design was checking only quorum for \"write\" clients.\n\t// Latest change checks audience for all types of connections.\n\tprotected get membership(): IMembership | undefined {\n\t\t// We could always use audience here, and in practice it will probably be correct.\n\t\t// (including case when this.readClientsWaitForJoinSignal === false).\n\t\t// But only if it's superset of quorum, i.e. when filtered to \"write\" clients, they are always identical!\n\t\t// It's safer to assume that we have bugs and engaging kill-bit switch should bring us back to well-known\n\t\t// and tested state!\n\t\treturn this.readClientsWaitForJoinSignal ? this.protocol?.audience : this.protocol?.quorum;\n\t}\n\n\tpublic initProtocol(protocol: IProtocolHandler) {\n\t\tthis.protocol = protocol;\n\n\t\tthis.membership?.on(\"addMember\", (clientId, details) => {\n\t\t\tassert(\n\t\t\t\t(details as IClient).mode === \"read\" ||\n\t\t\t\t\tprotocol.quorum.getMember(clientId) !== undefined,\n\t\t\t\t0x4b5 /* Audience is subset of quorum */,\n\t\t\t);\n\t\t\tthis.receivedAddMemberEvent(clientId);\n\t\t});\n\n\t\tthis.membership?.on(\"removeMember\", (clientId) => {\n\t\t\tassert(\n\t\t\t\tprotocol.quorum.getMember(clientId) === undefined,\n\t\t\t\t0x4b6 /* Audience is subset of quorum */,\n\t\t\t);\n\t\t\tthis.receivedRemoveMemberEvent(clientId);\n\t\t});\n\n\t\t/* There is a tiny tiny race possible, where these events happen in this order:\n 1. A connection is established (no \"cached\" mode is used, so it happens in parallel / faster than other steps)\n 2. Some other client produces a summary\n 3. We get \"lucky\" and load from that summary as our initial snapshot\n 4. ConnectionStateHandler.initProtocol is called, \"self\" is already in the quorum.\n We could avoid this sequence (and delete test case for it) if we move connection lower in Container.load()\n */\n\t\tif (this.hasMember(this.pendingClientId)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.receivedAddMemberEvent(this.pendingClientId!);\n\t\t}\n\n\t\t// if we have a clientId from a previous container we need to wait for its leave message\n\t\tif (this.clientId !== undefined && this.hasMember(this.clientId)) {\n\t\t\tthis.prevClientLeftTimer.restart();\n\t\t}\n\t}\n\n\tprotected hasMember(clientId?: string) {\n\t\treturn this.membership?.getMember(clientId ?? \"\") !== undefined;\n\t}\n}\n"]}