@fluidframework/container-loader 2.20.0 → 2.21.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/connectionManager.js +7 -7
  3. package/dist/connectionManager.js.map +1 -1
  4. package/dist/container.d.ts.map +1 -1
  5. package/dist/container.js +18 -14
  6. package/dist/container.js.map +1 -1
  7. package/dist/containerContext.d.ts +6 -1
  8. package/dist/containerContext.d.ts.map +1 -1
  9. package/dist/containerContext.js +7 -0
  10. package/dist/containerContext.js.map +1 -1
  11. package/dist/debugLogger.js +1 -1
  12. package/dist/debugLogger.js.map +1 -1
  13. package/dist/deltaQueue.d.ts.map +1 -1
  14. package/dist/deltaQueue.js +2 -2
  15. package/dist/deltaQueue.js.map +1 -1
  16. package/dist/layerCompatState.d.ts +19 -0
  17. package/dist/layerCompatState.d.ts.map +1 -0
  18. package/dist/layerCompatState.js +64 -0
  19. package/dist/layerCompatState.js.map +1 -0
  20. package/dist/packageVersion.d.ts +1 -1
  21. package/dist/packageVersion.js +1 -1
  22. package/dist/packageVersion.js.map +1 -1
  23. package/dist/protocol/quorum.d.ts +0 -10
  24. package/dist/protocol/quorum.d.ts.map +1 -1
  25. package/dist/protocol/quorum.js +0 -14
  26. package/dist/protocol/quorum.js.map +1 -1
  27. package/lib/connectionManager.js +8 -8
  28. package/lib/connectionManager.js.map +1 -1
  29. package/lib/container.d.ts.map +1 -1
  30. package/lib/container.js +19 -15
  31. package/lib/container.js.map +1 -1
  32. package/lib/containerContext.d.ts +6 -1
  33. package/lib/containerContext.d.ts.map +1 -1
  34. package/lib/containerContext.js +7 -0
  35. package/lib/containerContext.js.map +1 -1
  36. package/lib/debugLogger.js +2 -2
  37. package/lib/debugLogger.js.map +1 -1
  38. package/lib/deltaQueue.d.ts.map +1 -1
  39. package/lib/deltaQueue.js +3 -3
  40. package/lib/deltaQueue.js.map +1 -1
  41. package/lib/layerCompatState.d.ts +19 -0
  42. package/lib/layerCompatState.d.ts.map +1 -0
  43. package/lib/layerCompatState.js +60 -0
  44. package/lib/layerCompatState.js.map +1 -0
  45. package/lib/packageVersion.d.ts +1 -1
  46. package/lib/packageVersion.js +1 -1
  47. package/lib/packageVersion.js.map +1 -1
  48. package/lib/protocol/quorum.d.ts +0 -10
  49. package/lib/protocol/quorum.d.ts.map +1 -1
  50. package/lib/protocol/quorum.js +0 -14
  51. package/lib/protocol/quorum.js.map +1 -1
  52. package/package.json +14 -14
  53. package/src/connectionManager.ts +8 -8
  54. package/src/container.ts +28 -15
  55. package/src/containerContext.ts +14 -1
  56. package/src/debugLogger.ts +2 -2
  57. package/src/deltaQueue.ts +3 -3
  58. package/src/layerCompatState.ts +75 -0
  59. package/src/packageVersion.ts +1 -1
  60. package/src/protocol/quorum.ts +0 -16
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
5
+ import { TypedEventEmitter, performanceNow } from "@fluid-internal/client-utils";
6
6
  import { LogLevel, } from "@fluidframework/core-interfaces";
7
7
  import { assert } from "@fluidframework/core-utils/internal";
8
8
  import { DriverErrorTypes, MessageType, ScopeType, } from "@fluidframework/driver-definitions/internal";
@@ -422,7 +422,7 @@ export class ConnectionManager {
422
422
  }
423
423
  let delayMs = InitialReconnectDelayInMs;
424
424
  let connectRepeatCount = 0;
425
- const connectStartTime = performance.now();
425
+ const connectStartTime = performanceNow();
426
426
  let lastError;
427
427
  const abortController = new AbortController();
428
428
  const abortSignal = abortController.signal;
@@ -441,7 +441,7 @@ export class ConnectionManager {
441
441
  this.logger.sendTelemetryEvent({
442
442
  eventName: "ConnectionAttemptCancelled",
443
443
  attempts: connectRepeatCount,
444
- duration: formatTick(performance.now() - connectStartTime),
444
+ duration: formatTick(performanceNow() - connectStartTime),
445
445
  connectionEstablished: false,
446
446
  });
447
447
  return;
@@ -498,7 +498,7 @@ export class ConnectionManager {
498
498
  attempts: connectRepeatCount,
499
499
  delay: delayMs, // milliseconds
500
500
  eventName: "DeltaConnectionFailureToConnect",
501
- duration: formatTick(performance.now() - connectStartTime),
501
+ duration: formatTick(performanceNow() - connectStartTime),
502
502
  }, origError);
503
503
  lastError = origError;
504
504
  // We will not perform retries if the container disconnected and the ReconnectMode is set to Disabled or Never
@@ -506,7 +506,7 @@ export class ConnectionManager {
506
506
  if (this.reconnectMode !== ReconnectMode.Enabled) {
507
507
  return;
508
508
  }
509
- const waitStartTime = performance.now();
509
+ const waitStartTime = performanceNow();
510
510
  const retryDelayFromError = getRetryDelayFromError(origError);
511
511
  // If the error told us to wait or browser signals us that we are offline, then calculate the time we
512
512
  // want to wait for before retrying. then we wait for that time. If the error didn't tell us to wait,
@@ -529,7 +529,7 @@ export class ConnectionManager {
529
529
  await waitForOnline();
530
530
  this.logger.sendPerformanceEvent({
531
531
  eventName: "WaitBetweenConnectionAttempts",
532
- duration: performance.now() - waitStartTime,
532
+ duration: performanceNow() - waitStartTime,
533
533
  details: JSON.stringify({
534
534
  retryDelayFromError,
535
535
  delayMs,
@@ -542,7 +542,7 @@ export class ConnectionManager {
542
542
  logNetworkFailure(this.logger, {
543
543
  eventName: "MultipleDeltaConnectionFailures",
544
544
  attempts: connectRepeatCount,
545
- duration: formatTick(performance.now() - connectStartTime),
545
+ duration: formatTick(performanceNow() - connectStartTime),
546
546
  }, lastError);
547
547
  }
548
548
  // Check for abort signal after while loop as well or we've been disposed
@@ -551,7 +551,7 @@ export class ConnectionManager {
551
551
  this.logger.sendTelemetryEvent({
552
552
  eventName: "ConnectionAttemptCancelled",
553
553
  attempts: connectRepeatCount,
554
- duration: formatTick(performance.now() - connectStartTime),
554
+ duration: formatTick(performanceNow() - connectStartTime),
555
555
  connectionEstablished: true,
556
556
  });
557
557
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"connectionManager.js","sourceRoot":"","sources":["../src/connectionMan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QAAQ,EAC9C,CAAC;YACF,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAE1D,MAAM,CACL,IAAI,CAAC,4BAA4B,GAAG,oBAAoB,EACxD,KAAK,CAAC,+BAA+B,CACrC,CAAC;YACF,MAAM,CACL,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,EACjD,KAAK,CAAC,6DAA6D,CACnE,CAAC;YAEF,IAAI,CAAC,4BAA4B,GAAG,oBAAoB,CAAC;QAC1D,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;YAC9C,MAAM,kBAAkB,GAAG,OAA0C,CAAC;YACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAW,CAAC;YAC/D,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,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,CACb,MAAM,EAAE,iBAAiB;gBACzB,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAC1B,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACjB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC5E,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC;CA8CD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter, performance } from \"@fluid-internal/client-utils\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { IDeltaQueue, ReadOnlyInfo } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tIDisposable,\n\tITelemetryBaseProperties,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ConnectionMode, IClient, IClientDetails } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentService,\n\tDriverErrorTypes,\n\tIAnyDriverError,\n\tIClientConfiguration,\n\tIDocumentMessage,\n\tINack,\n\tINackContent,\n\tISequencedDocumentSystemMessage,\n\tISignalClient,\n\tITokenClaims,\n\tMessageType,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tcalculateMaxWaitTime,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tgetRetryDelayFromError,\n\tisRuntimeMessage,\n\tlogNetworkFailure,\n\ttype GenericNetworkError,\n\ttype ThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tGenericError,\n\tUsageError,\n\tformatTick,\n\tgenerateStack,\n\tisFluidError,\n\tnormalizeError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tIConnectionDetailsInternal,\n\tIConnectionManager,\n\tIConnectionManagerFactoryArgs,\n\tIConnectionStateChangeReason,\n\tReconnectMode,\n} from \"./contracts.js\";\nimport { DeltaQueue } from \"./deltaQueue.js\";\nimport { SignalType } from \"./protocol.js\";\nimport { isDeltaStreamConnectionForbiddenError } from \"./utils.js\";\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(\n\tnackContent: INackContent,\n): ThrottlingError | GenericNetworkError {\n\tconst message = `Nack (${nackContent.type}): ${nackContent.message}`;\n\tconst canRetry = nackContent.code !== 403;\n\tconst retryAfterMs =\n\t\tnackContent.retryAfter === undefined ? undefined : nackContent.retryAfter * 1000;\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\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tclaims = {\n\t\tscopes: [ScopeType.DocRead],\n\t} as ITokenClaims;\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: unknown): 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(): boolean {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n}\n\nfunction isNoDeltaStreamConnection(connection: unknown): 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 = (): void => {\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/**\n\t * Connection mode used when reconnecting on error or disconnect.\n\t */\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/**\n\t * Details about connection. undefined if there is no active connection.\n\t */\n\tprivate _connectionDetails?: IConnectionDetailsInternal;\n\n\t/**\n\t * file ACL - whether user has only read-only access to a file\n\t */\n\tprivate _readonlyPermissions: boolean | undefined;\n\n\t/**\n\t * tracks host requiring read-only mode.\n\t */\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/**\n\t * True if there is pending (async) reconnection from \"read\" to \"write\"\n\t */\n\tprivate pendingReconnect = false;\n\n\tprivate clientSequenceNumber = 0;\n\tprivate clientSequenceNumberObserved = 0;\n\t/**\n\t * Counts the number of non-runtime ops sent by the client which may not be acked.\n\t */\n\tprivate localOpsToIgnore = 0;\n\n\t/**\n\t * track clientId used last time when we sent any ops\n\t */\n\tprivate lastSubmittedClientId: string | undefined;\n\n\tprivate connectFirstConnection = true;\n\n\tprivate _connectionVerboseProps: Record<string, string | number> = {};\n\n\tprivate _connectionProps: ITelemetryBaseProperties = {};\n\n\tprivate _disposed = false;\n\n\tprivate readonly _outbound: DeltaQueue<IDocumentMessage[]>;\n\n\tpublic get connectionVerboseProps(): Record<string, string | number> {\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(): boolean {\n\t\treturn this.connection !== undefined;\n\t}\n\n\tpublic get clientId(): string | undefined {\n\t\treturn this.connection?.clientId;\n\t}\n\n\t/**\n\t * Details about connection. Returns undefined if there is no active connection.\n\t */\n\tpublic get connectionDetails(): IConnectionDetailsInternal | undefined {\n\t\treturn this._connectionDetails;\n\t}\n\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(): ITelemetryBaseProperties {\n\t\treturn this.connection === undefined\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\t}\n\t\t\t: this._connectionProps;\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(): ISignalClient[] {\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): void {\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): void {\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): void {\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): void {\n\t\tthis.connectCore(reason, connectionMode).catch((error) => {\n\t\t\tconst normalizedError = normalizeError(error, { 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\tlet requestedMode = connectionMode ?? 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\tif (this.connection !== undefined || this.pendingConnection !== undefined) {\n\t\t\t// Connection attempt already completed successfully or is in progress\n\t\t\t// In general, there should be no issues if the modes do not match:\n\t\t\t// If at some point it was Ok to connect as \"read\" (i.e. there were no pending ops we had to track),\n\t\t\t// then it should be Ok to use \"read\" connection even if for some reason request came in to connect as \"write\"\n\t\t\t// (though that should never happen)\n\t\t\t// The opposite should be fine as well: we may have had idle \"write\" connection, and request to reconnect came in,\n\t\t\t// using default \"read\" mode.\n\t\t\t// That all said, let's understand better where such mismatches are coming from.\n\t\t\tconst mode = this.connection?.mode ?? this.pendingConnection?.connectionMode;\n\t\t\tif (mode !== requestedMode) {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"ConnectionModeMismatch\",\n\t\t\t\t\tconnected: this.connection !== undefined,\n\t\t\t\t\tmode,\n\t\t\t\t\trequestedMode,\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst docService = this.serviceProvider();\n\t\tassert(docService !== undefined, 0x2a7 /* \"Container is not attached\" */);\n\n\t\tthis.props.establishConnectionHandler(reason);\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: unknown;\n\n\t\tconst abortController = new AbortController();\n\t\tconst abortSignal = abortController.signal;\n\t\tthis.pendingConnection = {\n\t\t\tabort: (): void => {\n\t\t\t\tabortController.abort();\n\t\t\t},\n\t\t\tconnectionMode: requestedMode,\n\t\t};\n\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: unknown) {\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\torigError.errorType === DriverErrorTypes.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\t// We will not perform retries if the container disconnected and the ReconnectMode is set to Disabled or Never\n\t\t\t\t// so break out of the re-connecting while-loop after first attempt\n\t\t\t\tif (this.reconnectMode !== ReconnectMode.Enabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\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\n\t\t\t\t// Raise event in case the delay was there from the error.\n\t\t\t\tif (retryDelayFromError !== undefined) {\n\t\t\t\t\tthis.props.reconnectionDelayHandler(delayMs, origError);\n\t\t\t\t}\n\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(\n\t\treason: IConnectionStateChangeReason,\n\t\tconnectionMode: ConnectionMode,\n\t): void {\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\t\tthis._connectionDetails = 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): void {\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({\n\t\t\teventName: \"ConnectionCancelReceived\",\n\t\t\treason: reason.text,\n\t\t});\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): void {\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 readonlyPermission = !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\n\t\tassert(\n\t\t\t!readonlyPermission || this.connectionMode === \"read\",\n\t\t\t0x0e8 /* \"readonly perf with write connection\" */,\n\t\t);\n\n\t\tthis.set_readonlyPermissions(\n\t\t\treadonlyPermission,\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\tthis._connectionDetails = ConnectionManager.detailsFromConnection(connection, reason);\n\t\tthis._connectionDetails.checkpointSequenceNumber = checkpointSequenceNumber;\n\t\tthis.props.connectHandler(this._connectionDetails);\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\t// API uses null\n\t\t\t// eslint-disable-next-line unicorn/no-null\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\t// API uses null\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\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, ...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, ...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): void {\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): Promise<void> {\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: ${reason.text}`\n\t\t\t\t\t\t: \"Reconnecting due to Error\",\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 = 0;\n\t\t} else {\n\t\t\tthis.localOpsToIgnore++;\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: string, targetClientId?: string): void {\n\t\tif (this.connection === undefined) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"submitSignalDisconnected\" });\n\t\t} else {\n\t\t\tthis.connection.submitSignal(content, targetClientId);\n\t\t}\n\t}\n\n\tpublic sendMessages(messages: IDocumentMessage[]): void {\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): void {\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 = (\n\t\tdocumentId: string,\n\t\tmessagesArg: ISequencedDocumentMessage[],\n\t): void => {\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[]): void => {\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[]): void => {\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): void => {\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): void => {\n\t\tthis.reconnectOnError(this.defaultReconnectionMode, error);\n\t};\n}\n"]}
1
+ {"version":3,"file":"connectionManager.js","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGjF,OAAO,EAGN,QAAQ,GACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAIN,gBAAgB,EAShB,WAAW,EACX,SAAS,GAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,GAGjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,cAAc,GACd,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAKN,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qCAAqC,EAAE,MAAM,YAAY,CAAC;AAEnE,8GAA8G;AAC9G,MAAM,yBAAyB,GAAG,GAAG,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,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACjB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC5E,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC;CA8CD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter, performanceNow } from \"@fluid-internal/client-utils\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { IDeltaQueue, ReadOnlyInfo } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tIDisposable,\n\tITelemetryBaseProperties,\n\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ConnectionMode, IClient, IClientDetails } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentService,\n\tDriverErrorTypes,\n\tIAnyDriverError,\n\tIClientConfiguration,\n\tIDocumentMessage,\n\tINack,\n\tINackContent,\n\tISequencedDocumentSystemMessage,\n\tISignalClient,\n\tITokenClaims,\n\tMessageType,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tcalculateMaxWaitTime,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tgetRetryDelayFromError,\n\tisRuntimeMessage,\n\tlogNetworkFailure,\n\ttype GenericNetworkError,\n\ttype ThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tGenericError,\n\tUsageError,\n\tformatTick,\n\tgenerateStack,\n\tisFluidError,\n\tnormalizeError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tIConnectionDetailsInternal,\n\tIConnectionManager,\n\tIConnectionManagerFactoryArgs,\n\tIConnectionStateChangeReason,\n\tReconnectMode,\n} from \"./contracts.js\";\nimport { DeltaQueue } from \"./deltaQueue.js\";\nimport { SignalType } from \"./protocol.js\";\nimport { isDeltaStreamConnectionForbiddenError } from \"./utils.js\";\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(\n\tnackContent: INackContent,\n): ThrottlingError | GenericNetworkError {\n\tconst message = `Nack (${nackContent.type}): ${nackContent.message}`;\n\tconst canRetry = nackContent.code !== 403;\n\tconst retryAfterMs =\n\t\tnackContent.retryAfter === undefined ? undefined : nackContent.retryAfter * 1000;\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\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tclaims = {\n\t\tscopes: [ScopeType.DocRead],\n\t} as ITokenClaims;\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: unknown): 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(): boolean {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n}\n\nfunction isNoDeltaStreamConnection(connection: unknown): 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 = (): void => {\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/**\n\t * Connection mode used when reconnecting on error or disconnect.\n\t */\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/**\n\t * Details about connection. undefined if there is no active connection.\n\t */\n\tprivate _connectionDetails?: IConnectionDetailsInternal;\n\n\t/**\n\t * file ACL - whether user has only read-only access to a file\n\t */\n\tprivate _readonlyPermissions: boolean | undefined;\n\n\t/**\n\t * tracks host requiring read-only mode.\n\t */\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/**\n\t * True if there is pending (async) reconnection from \"read\" to \"write\"\n\t */\n\tprivate pendingReconnect = false;\n\n\tprivate clientSequenceNumber = 0;\n\tprivate clientSequenceNumberObserved = 0;\n\t/**\n\t * Counts the number of non-runtime ops sent by the client which may not be acked.\n\t */\n\tprivate localOpsToIgnore = 0;\n\n\t/**\n\t * track clientId used last time when we sent any ops\n\t */\n\tprivate lastSubmittedClientId: string | undefined;\n\n\tprivate connectFirstConnection = true;\n\n\tprivate _connectionVerboseProps: Record<string, string | number> = {};\n\n\tprivate _connectionProps: ITelemetryBaseProperties = {};\n\n\tprivate _disposed = false;\n\n\tprivate readonly _outbound: DeltaQueue<IDocumentMessage[]>;\n\n\tpublic get connectionVerboseProps(): Record<string, string | number> {\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(): boolean {\n\t\treturn this.connection !== undefined;\n\t}\n\n\tpublic get clientId(): string | undefined {\n\t\treturn this.connection?.clientId;\n\t}\n\n\t/**\n\t * Details about connection. Returns undefined if there is no active connection.\n\t */\n\tpublic get connectionDetails(): IConnectionDetailsInternal | undefined {\n\t\treturn this._connectionDetails;\n\t}\n\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(): ITelemetryBaseProperties {\n\t\treturn this.connection === undefined\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\t}\n\t\t\t: this._connectionProps;\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(): ISignalClient[] {\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): void {\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): void {\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): void {\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): void {\n\t\tthis.connectCore(reason, connectionMode).catch((error) => {\n\t\t\tconst normalizedError = normalizeError(error, { 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\tlet requestedMode = connectionMode ?? 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\tif (this.connection !== undefined || this.pendingConnection !== undefined) {\n\t\t\t// Connection attempt already completed successfully or is in progress\n\t\t\t// In general, there should be no issues if the modes do not match:\n\t\t\t// If at some point it was Ok to connect as \"read\" (i.e. there were no pending ops we had to track),\n\t\t\t// then it should be Ok to use \"read\" connection even if for some reason request came in to connect as \"write\"\n\t\t\t// (though that should never happen)\n\t\t\t// The opposite should be fine as well: we may have had idle \"write\" connection, and request to reconnect came in,\n\t\t\t// using default \"read\" mode.\n\t\t\t// That all said, let's understand better where such mismatches are coming from.\n\t\t\tconst mode = this.connection?.mode ?? this.pendingConnection?.connectionMode;\n\t\t\tif (mode !== requestedMode) {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"ConnectionModeMismatch\",\n\t\t\t\t\tconnected: this.connection !== undefined,\n\t\t\t\t\tmode,\n\t\t\t\t\trequestedMode,\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst docService = this.serviceProvider();\n\t\tassert(docService !== undefined, 0x2a7 /* \"Container is not attached\" */);\n\n\t\tthis.props.establishConnectionHandler(reason);\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 = performanceNow();\n\t\tlet lastError: unknown;\n\n\t\tconst abortController = new AbortController();\n\t\tconst abortSignal = abortController.signal;\n\t\tthis.pendingConnection = {\n\t\t\tabort: (): void => {\n\t\t\t\tabortController.abort();\n\t\t\t},\n\t\t\tconnectionMode: requestedMode,\n\t\t};\n\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(performanceNow() - 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: unknown) {\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\torigError.errorType === DriverErrorTypes.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(performanceNow() - 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\t// We will not perform retries if the container disconnected and the ReconnectMode is set to Disabled or Never\n\t\t\t\t// so break out of the re-connecting while-loop after first attempt\n\t\t\t\tif (this.reconnectMode !== ReconnectMode.Enabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst waitStartTime = performanceNow();\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\n\t\t\t\t// Raise event in case the delay was there from the error.\n\t\t\t\tif (retryDelayFromError !== undefined) {\n\t\t\t\t\tthis.props.reconnectionDelayHandler(delayMs, origError);\n\t\t\t\t}\n\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: performanceNow() - 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(performanceNow() - 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(performanceNow() - 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(\n\t\treason: IConnectionStateChangeReason,\n\t\tconnectionMode: ConnectionMode,\n\t): void {\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\t\tthis._connectionDetails = 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): void {\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({\n\t\t\teventName: \"ConnectionCancelReceived\",\n\t\t\treason: reason.text,\n\t\t});\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): void {\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 readonlyPermission = !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\n\t\tassert(\n\t\t\t!readonlyPermission || this.connectionMode === \"read\",\n\t\t\t0x0e8 /* \"readonly perf with write connection\" */,\n\t\t);\n\n\t\tthis.set_readonlyPermissions(\n\t\t\treadonlyPermission,\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\tthis._connectionDetails = ConnectionManager.detailsFromConnection(connection, reason);\n\t\tthis._connectionDetails.checkpointSequenceNumber = checkpointSequenceNumber;\n\t\tthis.props.connectHandler(this._connectionDetails);\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\t// API uses null\n\t\t\t// eslint-disable-next-line unicorn/no-null\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\t// API uses null\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\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, ...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, ...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): void {\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): Promise<void> {\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: ${reason.text}`\n\t\t\t\t\t\t: \"Reconnecting due to Error\",\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 = 0;\n\t\t} else {\n\t\t\tthis.localOpsToIgnore++;\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: string, targetClientId?: string): void {\n\t\tif (this.connection === undefined) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"submitSignalDisconnected\" });\n\t\t} else {\n\t\t\tthis.connection.submitSignal(content, targetClientId);\n\t\t}\n\t}\n\n\tpublic sendMessages(messages: IDocumentMessage[]): void {\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): void {\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 = (\n\t\tdocumentId: string,\n\t\tmessagesArg: ISequencedDocumentMessage[],\n\t): void => {\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[]): void => {\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[]): void => {\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): void => {\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): void => {\n\t\tthis.reconnectOnError(this.defaultReconnectionMode, error);\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAGN,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EAQjB,aAAa,EACb,YAAY,EAEZ,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,WAAW,EAEX,QAAQ,EACR,wBAAwB,EAExB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEN,cAAc,EACd,cAAc,EAId,MAAM,oCAAoC,CAAC;AAC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C,WAAW;IAgBnB,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,aAAa;IAwBrB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA+C5B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;YAUP,kBAAkB;IAsFhC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAMxC;IAEF;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,wBAAwB;CAuChC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACzD;;;;;OAKG;IACH,oBAAoB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC;;;OAGG;IACH,4BAA4B,CAAC,CAAC,uBAAuB,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtF"}
package/lib/container.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  /* eslint-disable unicorn/consistent-function-scoping */
6
- import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
6
+ import { TypedEventEmitter, performanceNow, } from "@fluid-internal/client-utils";
7
7
  import { AttachState, } from "@fluidframework/container-definitions";
8
8
  import { isFluidCodeDetails, } from "@fluidframework/container-definitions/internal";
9
9
  import { LogLevel, } from "@fluidframework/core-interfaces";
@@ -23,6 +23,7 @@ import { ContainerContext } from "./containerContext.js";
23
23
  import { ContainerStorageAdapter } from "./containerStorageAdapter.js";
24
24
  import { ReconnectMode, getPackageName, } from "./contracts.js";
25
25
  import { DeltaManager } from "./deltaManager.js";
26
+ import { validateRuntimeCompatibility } from "./layerCompatState.js";
26
27
  // eslint-disable-next-line import/no-deprecated
27
28
  import { RelativeLoader } from "./loader.js";
28
29
  import { serializeMemoryDetachedBlobStorage, createMemoryDetachedBlobStorage, tryInitializeMemoryDetachedBlobStorage, } from "./memoryBlobStorage.js";
@@ -407,7 +408,7 @@ export class Container extends EventEmitterWithErrorHandling {
407
408
  this.attachmentData = { state: AttachState.Detached };
408
409
  this.clientsWhoShouldHaveLeft = new Set();
409
410
  this._containerMetadata = {};
410
- this.setAutoReconnectTime = performance.now();
411
+ this.setAutoReconnectTime = performanceNow();
411
412
  this._lifecycleEvents = new TypedEventEmitter();
412
413
  this.verifyClosedAfterCalls = 0;
413
414
  this._disposed = false;
@@ -507,7 +508,7 @@ export class Container extends EventEmitterWithErrorHandling {
507
508
  this.emit(dirty ? dirtyContainerEvent : savedContainerEvent);
508
509
  };
509
510
  const { canReconnect, clientDetailsOverride, urlResolver, documentServiceFactory, codeLoader, options, scope, subLogger, detachedBlobStorage, protocolHandlerBuilder, } = createProps;
510
- this.connectionTransitionTimes[ConnectionState.Disconnected] = performance.now();
511
+ this.connectionTransitionTimes[ConnectionState.Disconnected] = performanceNow();
511
512
  const pendingLocalState = loadProps?.pendingLocalState;
512
513
  this._canReconnect = canReconnect ?? true;
513
514
  this.clientDetailsOverride = clientDetailsOverride;
@@ -567,7 +568,7 @@ export class Container extends EventEmitterWithErrorHandling {
567
568
  ? "null"
568
569
  : this.deltaManager?.lastMessage?.clientId,
569
570
  dmLastMsgClientSeq: () => this.deltaManager?.lastMessage?.clientSequenceNumber,
570
- connectionStateDuration: () => performance.now() - this.connectionTransitionTimes[this.connectionState],
571
+ connectionStateDuration: () => performanceNow() - this.connectionTransitionTimes[this.connectionState],
571
572
  },
572
573
  },
573
574
  });
@@ -600,7 +601,7 @@ export class Container extends EventEmitterWithErrorHandling {
600
601
  eventName,
601
602
  mode,
602
603
  category: this._lifecycleState === "loading" ? "generic" : category,
603
- duration: performance.now() - this.connectionTransitionTimes[ConnectionState.CatchingUp],
604
+ duration: performanceNow() - this.connectionTransitionTimes[ConnectionState.CatchingUp],
604
605
  ...(details === undefined ? {} : { details: JSON.stringify(details) }),
605
606
  });
606
607
  // This assert is important for many reasons:
@@ -659,10 +660,10 @@ export class Container extends EventEmitterWithErrorHandling {
659
660
  document.addEventListener !== null;
660
661
  // keep track of last time page was visible for telemetry (on interactive clients only)
661
662
  if (isDomAvailable && interactive) {
662
- this.lastVisible = document.hidden ? performance.now() : undefined;
663
+ this.lastVisible = document.hidden ? performanceNow() : undefined;
663
664
  this.visibilityEventHandler = () => {
664
665
  if (document.hidden) {
665
- this.lastVisible = performance.now();
666
+ this.lastVisible = performanceNow();
666
667
  }
667
668
  else {
668
669
  // settimeout so this will hopefully fire after disconnect event if being hidden caused it
@@ -844,7 +845,7 @@ export class Container extends EventEmitterWithErrorHandling {
844
845
  if (currentMode === mode) {
845
846
  return;
846
847
  }
847
- const now = performance.now();
848
+ const now = performanceNow();
848
849
  const duration = now - this.setAutoReconnectTime;
849
850
  this.setAutoReconnectTime = now;
850
851
  this.mc.logger.sendTelemetryEvent({
@@ -993,7 +994,7 @@ export class Container extends EventEmitterWithErrorHandling {
993
994
  * @param specifiedVersion - Version SHA to load snapshot. If not specified, will fetch the latest snapshot.
994
995
  */
995
996
  async load(specifiedVersion, loadMode, resolvedUrl, pendingLocalState) {
996
- const timings = { phase1: performance.now() };
997
+ const timings = { phase1: performanceNow() };
997
998
  this.service = await this.createDocumentService(async () => this.serviceFactory.createDocumentService(resolvedUrl, this.subLogger, this.client.details.type === summarizerClientType));
998
999
  // Except in cases where it has stashed ops or requested by feature gate, the container will connect in "read" mode
999
1000
  const mode = this.mc.config.getBoolean("Fluid.Container.ForceWriteConnection") === true ||
@@ -1014,7 +1015,7 @@ export class Container extends EventEmitterWithErrorHandling {
1014
1015
  this.attachmentData = {
1015
1016
  state: AttachState.Attached,
1016
1017
  };
1017
- timings.phase2 = performance.now();
1018
+ timings.phase2 = performanceNow();
1018
1019
  // Fetch specified snapshot.
1019
1020
  const { baseSnapshot, version } = await this.serializedStateManager.fetchSnapshot(specifiedVersion);
1020
1021
  const baseSnapshotTree = getSnapshotTree(baseSnapshot);
@@ -1051,7 +1052,7 @@ export class Container extends EventEmitterWithErrorHandling {
1051
1052
  if (pendingLocalState?.clientId !== undefined) {
1052
1053
  this.protocolHandler.audience.setCurrentClientId(pendingLocalState?.clientId);
1053
1054
  }
1054
- timings.phase3 = performance.now();
1055
+ timings.phase3 = performanceNow();
1055
1056
  const codeDetails = this.getCodeDetailsFromQuorum();
1056
1057
  await this.instantiateRuntime(codeDetails, baseSnapshotTree,
1057
1058
  // give runtime a dummy value so it knows we're loading from a stash blob
@@ -1093,7 +1094,7 @@ export class Container extends EventEmitterWithErrorHandling {
1093
1094
  if (this.closed) {
1094
1095
  throw new Error("Container was closed while load()");
1095
1096
  }
1096
- timings.end = performance.now();
1097
+ timings.end = performanceNow();
1097
1098
  this.subLogger.sendTelemetryEvent({
1098
1099
  eventName: "LoadStagesTimings",
1099
1100
  details: JSON.stringify(timings),
@@ -1342,7 +1343,7 @@ export class Container extends EventEmitterWithErrorHandling {
1342
1343
  }
1343
1344
  logConnectionStateChangeTelemetry(value, oldState, reason) {
1344
1345
  // Log actual event
1345
- const time = performance.now();
1346
+ const time = performanceNow();
1346
1347
  this.connectionTransitionTimes[value] = time;
1347
1348
  const duration = time - this.connectionTransitionTimes[oldState];
1348
1349
  let durationFromDisconnected;
@@ -1379,7 +1380,7 @@ export class Container extends EventEmitterWithErrorHandling {
1379
1380
  autoReconnect,
1380
1381
  opsBehind,
1381
1382
  online: OnlineStatus[isOnline()],
1382
- lastVisible: this.lastVisible === undefined ? undefined : performance.now() - this.lastVisible,
1383
+ lastVisible: this.lastVisible === undefined ? undefined : performanceNow() - this.lastVisible,
1383
1384
  checkpointSequenceNumber,
1384
1385
  quorumSize: this._protocolHandler?.quorum.getMembers().size,
1385
1386
  audienceSize: this._protocolHandler?.audience.getMembers().size,
@@ -1527,7 +1528,10 @@ export class Container extends EventEmitterWithErrorHandling {
1527
1528
  }
1528
1529
  const existing = snapshotTree !== undefined;
1529
1530
  const context = new ContainerContext(this.options, this.scope, snapshotTree, this._loadedFromVersion, this._deltaManager, this.storageAdapter, this.protocolHandler.quorum, this.protocolHandler.audience, loader, (type, contents, batch, metadata) => this.submitContainerMessage(type, contents, batch, metadata), (summaryOp, referenceSequenceNumber) => this.submitSummaryMessage(summaryOp, referenceSequenceNumber), (batch, referenceSequenceNumber) => this.submitBatch(batch, referenceSequenceNumber), (content, targetClientId) => this.submitSignal(content, targetClientId), (error) => this.dispose(error), (error) => this.close(error), this.updateDirtyContainerState, this.getAbsoluteUrl, () => this.resolvedUrl?.id, () => this.clientId, () => this.attachState, () => this.connected, this._deltaManager.clientDetails, existing, this.subLogger, pendingLocalState, snapshot);
1530
- this._runtime = await PerformanceEvent.timedExecAsync(this.subLogger, { eventName: "InstantiateRuntime" }, async () => runtimeFactory.instantiateRuntime(context, existing));
1531
+ const runtime = await PerformanceEvent.timedExecAsync(this.subLogger, { eventName: "InstantiateRuntime" }, async () => runtimeFactory.instantiateRuntime(context, existing));
1532
+ const maybeRuntimeCompatDetails = runtime;
1533
+ validateRuntimeCompatibility(maybeRuntimeCompatDetails.ILayerCompatDetails, (error) => this.dispose(error));
1534
+ this._runtime = runtime;
1531
1535
  this._lifecycleEvents.emit("runtimeInstantiated");
1532
1536
  this._loadedCodeDetails = codeDetails;
1533
1537
  }