@fluidframework/container-loader 1.3.0 → 2.0.0-dev.1.4.5.105745

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 (148) hide show
  1. package/.eslintrc.js +8 -21
  2. package/.mocharc.js +12 -0
  3. package/dist/audience.d.ts +2 -2
  4. package/dist/audience.d.ts.map +1 -1
  5. package/dist/audience.js.map +1 -1
  6. package/dist/catchUpMonitor.d.ts +29 -0
  7. package/dist/catchUpMonitor.d.ts.map +1 -0
  8. package/dist/catchUpMonitor.js +43 -0
  9. package/dist/catchUpMonitor.js.map +1 -0
  10. package/dist/collabWindowTracker.d.ts +1 -1
  11. package/dist/collabWindowTracker.d.ts.map +1 -1
  12. package/dist/collabWindowTracker.js +12 -4
  13. package/dist/collabWindowTracker.js.map +1 -1
  14. package/dist/connectionManager.d.ts +5 -5
  15. package/dist/connectionManager.d.ts.map +1 -1
  16. package/dist/connectionManager.js +13 -18
  17. package/dist/connectionManager.js.map +1 -1
  18. package/dist/connectionState.d.ts +0 -5
  19. package/dist/connectionState.d.ts.map +1 -1
  20. package/dist/connectionState.js +0 -5
  21. package/dist/connectionState.js.map +1 -1
  22. package/dist/connectionStateHandler.d.ts +84 -22
  23. package/dist/connectionStateHandler.d.ts.map +1 -1
  24. package/dist/connectionStateHandler.js +172 -59
  25. package/dist/connectionStateHandler.js.map +1 -1
  26. package/dist/container.d.ts +30 -17
  27. package/dist/container.d.ts.map +1 -1
  28. package/dist/container.js +173 -165
  29. package/dist/container.js.map +1 -1
  30. package/dist/containerContext.d.ts +18 -7
  31. package/dist/containerContext.d.ts.map +1 -1
  32. package/dist/containerContext.js +18 -8
  33. package/dist/containerContext.js.map +1 -1
  34. package/dist/containerStorageAdapter.d.ts +11 -25
  35. package/dist/containerStorageAdapter.d.ts.map +1 -1
  36. package/dist/containerStorageAdapter.js +51 -17
  37. package/dist/containerStorageAdapter.js.map +1 -1
  38. package/dist/contracts.d.ts +5 -5
  39. package/dist/contracts.js.map +1 -1
  40. package/dist/deltaManager.d.ts +4 -1
  41. package/dist/deltaManager.d.ts.map +1 -1
  42. package/dist/deltaManager.js +33 -6
  43. package/dist/deltaManager.js.map +1 -1
  44. package/dist/deltaQueue.js +3 -3
  45. package/dist/deltaQueue.js.map +1 -1
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js.map +1 -1
  49. package/dist/loader.d.ts +8 -1
  50. package/dist/loader.d.ts.map +1 -1
  51. package/dist/loader.js +4 -3
  52. package/dist/loader.js.map +1 -1
  53. package/dist/packageVersion.d.ts +1 -1
  54. package/dist/packageVersion.d.ts.map +1 -1
  55. package/dist/packageVersion.js +1 -1
  56. package/dist/packageVersion.js.map +1 -1
  57. package/dist/protocol.d.ts +22 -0
  58. package/dist/protocol.d.ts.map +1 -0
  59. package/dist/protocol.js +53 -0
  60. package/dist/protocol.js.map +1 -0
  61. package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
  62. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  63. package/dist/retriableDocumentStorageService.d.ts +2 -2
  64. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  65. package/dist/retriableDocumentStorageService.js +2 -2
  66. package/dist/retriableDocumentStorageService.js.map +1 -1
  67. package/lib/audience.d.ts +2 -2
  68. package/lib/audience.d.ts.map +1 -1
  69. package/lib/audience.js.map +1 -1
  70. package/lib/catchUpMonitor.d.ts +29 -0
  71. package/lib/catchUpMonitor.d.ts.map +1 -0
  72. package/lib/catchUpMonitor.js +39 -0
  73. package/lib/catchUpMonitor.js.map +1 -0
  74. package/lib/collabWindowTracker.d.ts +1 -1
  75. package/lib/collabWindowTracker.d.ts.map +1 -1
  76. package/lib/collabWindowTracker.js +13 -5
  77. package/lib/collabWindowTracker.js.map +1 -1
  78. package/lib/connectionManager.d.ts +5 -5
  79. package/lib/connectionManager.d.ts.map +1 -1
  80. package/lib/connectionManager.js +14 -21
  81. package/lib/connectionManager.js.map +1 -1
  82. package/lib/connectionState.d.ts +0 -5
  83. package/lib/connectionState.d.ts.map +1 -1
  84. package/lib/connectionState.js +0 -5
  85. package/lib/connectionState.js.map +1 -1
  86. package/lib/connectionStateHandler.d.ts +84 -22
  87. package/lib/connectionStateHandler.d.ts.map +1 -1
  88. package/lib/connectionStateHandler.js +171 -59
  89. package/lib/connectionStateHandler.js.map +1 -1
  90. package/lib/container.d.ts +30 -17
  91. package/lib/container.d.ts.map +1 -1
  92. package/lib/container.js +176 -168
  93. package/lib/container.js.map +1 -1
  94. package/lib/containerContext.d.ts +18 -7
  95. package/lib/containerContext.d.ts.map +1 -1
  96. package/lib/containerContext.js +19 -9
  97. package/lib/containerContext.js.map +1 -1
  98. package/lib/containerStorageAdapter.d.ts +11 -25
  99. package/lib/containerStorageAdapter.d.ts.map +1 -1
  100. package/lib/containerStorageAdapter.js +51 -16
  101. package/lib/containerStorageAdapter.js.map +1 -1
  102. package/lib/contracts.d.ts +5 -5
  103. package/lib/contracts.js.map +1 -1
  104. package/lib/deltaManager.d.ts +4 -1
  105. package/lib/deltaManager.d.ts.map +1 -1
  106. package/lib/deltaManager.js +35 -8
  107. package/lib/deltaManager.js.map +1 -1
  108. package/lib/deltaQueue.js +3 -3
  109. package/lib/deltaQueue.js.map +1 -1
  110. package/lib/index.d.ts +1 -0
  111. package/lib/index.d.ts.map +1 -1
  112. package/lib/index.js.map +1 -1
  113. package/lib/loader.d.ts +8 -1
  114. package/lib/loader.d.ts.map +1 -1
  115. package/lib/loader.js +4 -3
  116. package/lib/loader.js.map +1 -1
  117. package/lib/packageVersion.d.ts +1 -1
  118. package/lib/packageVersion.d.ts.map +1 -1
  119. package/lib/packageVersion.js +1 -1
  120. package/lib/packageVersion.js.map +1 -1
  121. package/lib/protocol.d.ts +22 -0
  122. package/lib/protocol.d.ts.map +1 -0
  123. package/lib/protocol.js +49 -0
  124. package/lib/protocol.js.map +1 -0
  125. package/lib/protocolTreeDocumentStorageService.d.ts +1 -1
  126. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  127. package/lib/retriableDocumentStorageService.d.ts +2 -2
  128. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  129. package/lib/retriableDocumentStorageService.js +2 -2
  130. package/lib/retriableDocumentStorageService.js.map +1 -1
  131. package/package.json +26 -20
  132. package/src/audience.ts +2 -2
  133. package/src/catchUpMonitor.ts +59 -0
  134. package/src/collabWindowTracker.ts +15 -6
  135. package/src/connectionManager.ts +23 -27
  136. package/src/connectionState.ts +0 -6
  137. package/src/connectionStateHandler.ts +235 -70
  138. package/src/container.ts +223 -209
  139. package/src/containerContext.ts +22 -8
  140. package/src/containerStorageAdapter.ts +71 -16
  141. package/src/contracts.ts +7 -7
  142. package/src/deltaManager.ts +42 -11
  143. package/src/deltaQueue.ts +3 -3
  144. package/src/index.ts +4 -0
  145. package/src/loader.ts +14 -3
  146. package/src/packageVersion.ts +1 -1
  147. package/src/protocol.ts +97 -0
  148. package/src/retriableDocumentStorageService.ts +8 -2
@@ -28,6 +28,11 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
28
28
  this.logger = logger;
29
29
  this._active = _active;
30
30
  this.pending = [];
31
+ // A boolean used to assert that ops are not being sent while processing another op.
32
+ this.currentlyProcessingOps = false;
33
+ // Feature gate that closes a container when sending an op if the container is
34
+ // concurrently processing another op
35
+ this.preventConcurrentOpSend = true;
31
36
  // The minimum sequence number and last sequence number received from the server
32
37
  this.minSequenceNumber = 0;
33
38
  // There are three numbers we track
@@ -46,6 +51,8 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
46
51
  */
47
52
  this.opsSize = 0;
48
53
  // The sequence number we initially loaded from
54
+ // In case of reading from a snapshot or pending state, its value will be equal to
55
+ // the last message that got serialized.
49
56
  this.initSequenceNumber = 0;
50
57
  this.closed = false;
51
58
  this.throttlingIdSet = new Set();
@@ -73,6 +80,8 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
73
80
  readonlyChangeHandler: (readonly) => (0, telemetry_utils_1.safeRaiseEvent)(this, this.logger, "readonly", readonly),
74
81
  };
75
82
  this.connectionManager = createConnectionManager(props);
83
+ this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(logger);
84
+ this.preventConcurrentOpSend = this.mc.config.getBoolean("Fluid.Container.ConcurrentOpSend") === true;
76
85
  this._inbound = new deltaQueue_1.DeltaQueue((op) => {
77
86
  this.processInboundMessage(op);
78
87
  });
@@ -140,8 +149,11 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
140
149
  get readOnlyInfo() { return this.connectionManager.readOnlyInfo; }
141
150
  get clientDetails() { return this.connectionManager.clientDetails; }
142
151
  submit(type, contents, batch = false, metadata) {
152
+ if (this.currentlyProcessingOps && this.preventConcurrentOpSend) {
153
+ this.close(new container_utils_1.UsageError("Making changes to data model is disallowed while processing ops."));
154
+ }
143
155
  const messagePartial = {
144
- contents: JSON.stringify(contents),
156
+ contents,
145
157
  metadata,
146
158
  referenceSequenceNumber: this.lastProcessedSequenceNumber,
147
159
  type,
@@ -153,7 +165,9 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
153
165
  if (message === undefined) {
154
166
  return -1;
155
167
  }
156
- this.opsSize += message.contents.length;
168
+ if (contents !== undefined) {
169
+ this.opsSize += contents.length;
170
+ }
157
171
  this.messageBuffer.push(message);
158
172
  this.emit("submitOp", message);
159
173
  if (!batch) {
@@ -163,13 +177,23 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
163
177
  }
164
178
  submitSignal(content) { return this.connectionManager.submitSignal(content); }
165
179
  flush() {
166
- if (this.messageBuffer.length === 0) {
180
+ var _a, _b, _c;
181
+ const batch = this.messageBuffer;
182
+ if (batch.length === 0) {
167
183
  return;
168
184
  }
169
- // The prepareFlush event allows listeners to append metadata to the batch prior to submission.
170
- this.emit("prepareSend", this.messageBuffer);
171
- this.connectionManager.sendMessages(this.messageBuffer);
172
185
  this.messageBuffer = [];
186
+ // The prepareFlush event allows listeners to append metadata to the batch prior to submission.
187
+ this.emit("prepareSend", batch);
188
+ if (batch.length === 1) {
189
+ (0, common_utils_1.assert)(((_a = batch[0].metadata) === null || _a === void 0 ? void 0 : _a.batch) === undefined, 0x3c9 /* no batch markup on single message */);
190
+ }
191
+ else {
192
+ (0, common_utils_1.assert)(((_b = batch[0].metadata) === null || _b === void 0 ? void 0 : _b.batch) === true, 0x3ca /* no start batch markup */);
193
+ (0, common_utils_1.assert)(((_c = batch[batch.length - 1].metadata) === null || _c === void 0 ? void 0 : _c.batch) === false, 0x3cb /* no end batch markup */);
194
+ }
195
+ this.connectionManager.sendMessages(batch);
196
+ (0, common_utils_1.assert)(this.messageBuffer.length === 0, 0x3cc /* reentrancy */);
173
197
  }
174
198
  get connectionProps() {
175
199
  return Object.assign({ sequenceNumber: this.lastSequenceNumber, opsSize: this.opsSize > 0 ? this.opsSize : undefined }, this.connectionManager.connectionProps);
@@ -534,6 +558,8 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
534
558
  }
535
559
  processInboundMessage(message) {
536
560
  const startTime = Date.now();
561
+ (0, common_utils_1.assert)(!this.currentlyProcessingOps, 0x3af /* Already processing ops. */);
562
+ this.currentlyProcessingOps = true;
537
563
  this.lastProcessedMessage = message;
538
564
  // All non-system messages are coming from some client, and should have clientId
539
565
  // System messages may have no clientId (but some do, like propose, noop, summarize)
@@ -568,6 +594,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
568
594
  throw new Error("Attempted to process an inbound message without a handler attached");
569
595
  }
570
596
  this.handler.process(message);
597
+ this.currentlyProcessingOps = false;
571
598
  const endTime = Date.now();
572
599
  // Should be last, after changing this.lastProcessedSequenceNumber above, as many callers
573
600
  // test this.lastProcessedSequenceNumber instead of using op.sequenceNumber itself.
@@ -1 +1 @@
1
- {"version":3,"file":"deltaManager.js","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAgBlC,+DAAyE;AACzE,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AClB,+EAA+E;QAC/E,2CAA2C;QAC3C,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,GAAG,MAAM,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAE/E,wFAAwF;QACxF,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;YAChC,mCAAmC;YACnC,yFAAyF;YACzF,2EAA2E;YAC3E,gGAAgG;YAChG,iGAAiG;YACjG,qGAAqG;YACrG,wFAAwF;YACxF,uGAAuG;YACvG,kGAAkG;YAClG,iGAAiG;YACjG,YAAY;YACZ,IAAI,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE;gBAC5D,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;aACxC;SACJ;IACL,CAAC;IAEO,4BAA4B,CAAC,GAAW;QAC5C,IAAI,IAAI,CAAC,qBAAqB,GAAG,GAAG,EAAE;YAClC,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC;SACpC;IACL,CAAC;CACJ;AA51BD,oCA41BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n ITelemetryLogger,\n IEventProvider,\n ITelemetryProperties,\n ITelemetryErrorEvent,\n} from \"@fluidframework/common-definitions\";\nimport {\n IDeltaHandlerStrategy,\n IDeltaManager,\n IDeltaManagerEvents,\n IDeltaQueue,\n ICriticalContainerError,\n IThrottlingWarning,\n IConnectionDetails,\n} from \"@fluidframework/container-definitions\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n normalizeError,\n logIfFalse,\n safeRaiseEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISignalMessage,\n MessageType,\n ConnectionMode,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n NonRetryableError,\n isClientMessage,\n} from \"@fluidframework/driver-utils\";\nimport {\n ThrottlingWarning,\n DataCorruptionError,\n extractSafePropertiesFromMessage,\n DataProcessingError,\n} from \"@fluidframework/container-utils\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport {\n IConnectionManagerFactoryArgs,\n IConnectionManager,\n } from \"./contracts\";\n\nexport interface IConnectionArgs {\n mode?: ConnectionMode;\n fetchOpsFromStorage?: boolean;\n reason: string;\n}\n\n/**\n * Includes events emitted by the concrete implementation DeltaManager\n * but not exposed on the public interface IDeltaManager\n */\nexport interface IDeltaManagerInternalEvents extends IDeltaManagerEvents {\n (event: \"throttled\", listener: (error: IThrottlingWarning) => void);\n (event: \"closed\", listener: (error?: ICriticalContainerError) => void);\n}\n\n/**\n * Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta\n * messages in order regardless of possible network conditions or timings causing out of order delivery.\n */\nexport class DeltaManager<TConnectionManager extends IConnectionManager>\n extends TypedEventEmitter<IDeltaManagerInternalEvents>\n implements\n IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n IEventProvider<IDeltaManagerInternalEvents> {\n public readonly connectionManager: TConnectionManager;\n\n public get active(): boolean { return this._active(); }\n\n public get disposed() { return this.closed; }\n\n public get IDeltaSender() { return this; }\n\n private pending: ISequencedDocumentMessage[] = [];\n private fetchReason: string | undefined;\n\n // The minimum sequence number and last sequence number received from the server\n private minSequenceNumber: number = 0;\n\n // There are three numbers we track\n // * lastQueuedSequenceNumber is the last queued sequence number. If there are gaps in seq numbers, then this number\n // is not updated until we cover that gap, so it increases each time by 1.\n // * lastObservedSeqNumber is an estimation of last known sequence number for container in storage. It's initially\n // populated at web socket connection time (if storage provides that info) and is updated once ops shows up.\n // It's never less than lastQueuedSequenceNumber\n // * lastProcessedSequenceNumber - last processed sequence number\n private lastQueuedSequenceNumber: number = 0;\n private lastObservedSeqNumber: number = 0;\n private lastProcessedSequenceNumber: number = 0;\n private lastProcessedMessage: ISequencedDocumentMessage | undefined;\n private baseTerm: number = 0;\n\n /**\n * Track down the ops size.\n */\n private opsSize: number = 0;\n private prevEnqueueMessagesReason: string | undefined;\n private previouslyProcessedMessage: ISequencedDocumentMessage | undefined;\n\n // The sequence number we initially loaded from\n private initSequenceNumber: number = 0;\n\n private readonly _inbound: DeltaQueue<ISequencedDocumentMessage>;\n private readonly _inboundSignal: DeltaQueue<ISignalMessage>;\n\n private closed = false;\n\n private handler: IDeltaHandlerStrategy | undefined;\n private deltaStorage: IDocumentDeltaStorageService | undefined;\n\n private readonly throttlingIdSet = new Set<string>();\n private timeTillThrottling: number = 0;\n\n public readonly closeAbortController = new AbortController();\n\n private readonly deltaStorageDelayId = uuid();\n private readonly deltaStreamDelayId = uuid();\n\n private messageBuffer: IDocumentMessage[] = [];\n\n private _checkpointSequenceNumber: number | undefined;\n\n public get inbound(): IDeltaQueue<ISequencedDocumentMessage> {\n return this._inbound;\n }\n\n public get inboundSignal(): IDeltaQueue<ISignalMessage> {\n return this._inboundSignal;\n }\n\n public get initialSequenceNumber(): number {\n return this.initSequenceNumber;\n }\n\n public get lastSequenceNumber(): number {\n return this.lastProcessedSequenceNumber;\n }\n\n public get lastMessage() {\n return this.lastProcessedMessage;\n }\n\n public get lastKnownSeqNumber() {\n return this.lastObservedSeqNumber;\n }\n\n public get referenceTerm(): number {\n return this.baseTerm;\n }\n\n public get minimumSequenceNumber(): number {\n return this.minSequenceNumber;\n }\n\n /**\n * Tells if current connection has checkpoint information.\n * I.e. we know how far behind the client was at the time of establishing connection\n */\n public get hasCheckpointSequenceNumber() {\n // Valid to be called only if we have active connection.\n assert(this.connectionManager.connected, 0x0df /* \"Missing active connection\" */);\n return this._checkpointSequenceNumber !== undefined;\n }\n\n // Forwarding connection manager properties / IDeltaManager implementation\n public get maxMessageSize(): number { return this.connectionManager.maxMessageSize; }\n public get version() { return this.connectionManager.version; }\n public get serviceConfiguration() { return this.connectionManager.serviceConfiguration; }\n public get outbound() { return this.connectionManager.outbound; }\n public get readOnlyInfo() { return this.connectionManager.readOnlyInfo; }\n public get clientDetails() { return this.connectionManager.clientDetails; }\n\n public submit(type: MessageType, contents: any, batch = false, metadata?: any) {\n const messagePartial: Omit<IDocumentMessage, \"clientSequenceNumber\"> = {\n contents: JSON.stringify(contents),\n metadata,\n referenceSequenceNumber: this.lastProcessedSequenceNumber,\n type,\n };\n\n if (!batch) {\n this.flush();\n }\n\n const message = this.connectionManager.prepareMessageToSend(messagePartial);\n if (message === undefined) {\n return -1;\n }\n\n this.opsSize += message.contents.length;\n\n this.messageBuffer.push(message);\n\n this.emit(\"submitOp\", message);\n\n if (!batch) {\n this.flush();\n }\n\n return message.clientSequenceNumber;\n }\n\n public submitSignal(content: any) { return this.connectionManager.submitSignal(content); }\n\n public flush() {\n if (this.messageBuffer.length === 0) {\n return;\n }\n\n // The prepareFlush event allows listeners to append metadata to the batch prior to submission.\n this.emit(\"prepareSend\", this.messageBuffer);\n\n this.connectionManager.sendMessages(this.messageBuffer);\n this.messageBuffer = [];\n }\n\n public get connectionProps(): ITelemetryProperties {\n return {\n sequenceNumber: this.lastSequenceNumber,\n opsSize: this.opsSize > 0 ? this.opsSize : undefined,\n ...this.connectionManager.connectionProps,\n };\n }\n\n /**\n * Log error event with a bunch of internal to DeltaManager information about state of op processing\n * Used to diagnose connectivity issues related to op processing (i.e. cases where for some reason\n * we stop processing ops that results in no processing join op and thus moving to connected state)\n * @param event - Event to log.\n */\n public logConnectionIssue(event: ITelemetryErrorEvent) {\n assert(this.connectionManager.connected, 0x238 /* \"called only in connected state\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.logger.sendErrorEvent({\n ...event,\n // This directly tells us if fetching ops is in flight, and thus likely the reason of\n // stalled op processing\n fetchReason: this.fetchReason,\n // A bunch of useful sequence numbers to understand if we are holding some ops from processing\n lastQueuedSequenceNumber: this.lastQueuedSequenceNumber, // last sequential op\n lastProcessedSequenceNumber: this.lastProcessedSequenceNumber, // same as above, but after processing\n lastObserved: this.lastObservedSeqNumber, // last sequence we ever saw; may have gaps with above.\n // connection info\n ...this.connectionManager.connectionVerboseProps,\n pendingOps: this.pending.length, // Do we have any pending ops?\n pendingFirst: pendingSorted[0]?.sequenceNumber, // is the first pending op the one that we are missing?\n haveHandler: this.handler !== undefined, // do we have handler installed?\n inboundLength: this.inbound.length,\n inboundPaused: this.inbound.paused,\n });\n }\n\n constructor(\n private readonly serviceProvider: () => IDocumentService | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly _active: () => boolean,\n createConnectionManager: (props: IConnectionManagerFactoryArgs) => TConnectionManager,\n ) {\n super();\n const props: IConnectionManagerFactoryArgs = {\n incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => {\n try {\n this.enqueueMessages(messages, reason);\n } catch (error) {\n this.logger.sendErrorEvent({ eventName: \"EnqueueMessages_Exception\" }, error);\n this.close(normalizeError(error));\n }\n },\n signalHandler: (message: ISignalMessage) => this._inboundSignal.push(message),\n reconnectionDelayHandler: (delayMs: number, error: unknown) =>\n this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),\n closeHandler: (error: any) => this.close(error),\n disconnectHandler: (reason: string) => this.disconnectHandler(reason),\n connectHandler: (connection: IConnectionDetails) => this.connectHandler(connection),\n pongHandler: (latency: number) => this.emit(\"pong\", latency),\n readonlyChangeHandler: (readonly?: boolean) => safeRaiseEvent(this, this.logger, \"readonly\", readonly),\n };\n\n this.connectionManager = createConnectionManager(props);\n\n this._inbound = new DeltaQueue<ISequencedDocumentMessage>(\n (op) => {\n this.processInboundMessage(op);\n });\n\n this._inbound.on(\"error\", (error) => {\n this.close(\n DataProcessingError.wrapIfUnrecognized(error, \"deltaManagerInboundErrorHandler\", this.lastMessage));\n });\n\n // Inbound signal queue\n this._inboundSignal = new DeltaQueue<ISignalMessage>((message) => {\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound signal without a handler attached\");\n }\n this.handler.processSignal({\n clientId: message.clientId,\n content: JSON.parse(message.content as string),\n });\n });\n\n this._inboundSignal.on(\"error\", (error) => {\n this.close(normalizeError(error));\n });\n\n // Initially, all queues are created paused.\n // - outbound is flipped back and forth in setupNewSuccessfulConnection / disconnectFromDeltaStream\n // - inbound & inboundSignal are resumed in attachOpHandler() when we have handler setup\n }\n\n private connectHandler(connection: IConnectionDetails) {\n this.refreshDelayInfo(this.deltaStreamDelayId);\n\n const props = this.connectionManager.connectionVerboseProps;\n props.connectionLastQueuedSequenceNumber = this.lastQueuedSequenceNumber;\n props.connectionLastObservedSeqNumber = this.lastObservedSeqNumber;\n\n const checkpointSequenceNumber = connection.checkpointSequenceNumber;\n this._checkpointSequenceNumber = checkpointSequenceNumber;\n if (checkpointSequenceNumber !== undefined) {\n this.updateLatestKnownOpSeqNumber(checkpointSequenceNumber);\n }\n\n // We cancel all ops on lost of connectivity, and rely on DDSes to resubmit them.\n // Semantics are not well defined for batches (and they are broken right now on disconnects anyway),\n // but it's safe to assume (until better design is put into place) that batches should not exist\n // across multiple connections. Right now we assume runtime will not submit any ops in disconnected\n // state. As requirements change, so should these checks.\n assert(this.messageBuffer.length === 0, 0x0e9 /* \"messageBuffer is not empty on new connection\" */);\n\n this.opsSize = 0;\n\n this.emit(\n \"connect\",\n connection,\n checkpointSequenceNumber !== undefined ?\n this.lastObservedSeqNumber - this.lastSequenceNumber : undefined);\n\n // If we got some initial ops, then we know the gap and call above fetched ops to fill it.\n // Same is true for \"write\" mode even if we have no ops - we will get \"join\" own op very very soon.\n // However if we are connecting as view-only, then there is no good signal to realize if client is behind.\n // Thus we have to hit storage to see if any ops are there.\n if (checkpointSequenceNumber !== undefined) {\n // We know how far we are behind (roughly). If it's non-zero gap, fetch ops right away.\n if (checkpointSequenceNumber > this.lastQueuedSequenceNumber) {\n this.fetchMissingDeltas(\"AfterConnection\");\n }\n // we do not know the gap, and we will not learn about it if socket is quite - have to ask.\n } else if (connection.mode === \"read\") {\n this.fetchMissingDeltas(\"AfterReadConnection\");\n }\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Sets the sequence number from which inbound messages should be returned\n */\n public async attachOpHandler(\n minSequenceNumber: number,\n sequenceNumber: number,\n term: number,\n handler: IDeltaHandlerStrategy,\n prefetchType: \"cached\" | \"all\" | \"none\" = \"none\",\n ) {\n this.initSequenceNumber = sequenceNumber;\n this.lastProcessedSequenceNumber = sequenceNumber;\n this.baseTerm = term;\n this.minSequenceNumber = minSequenceNumber;\n this.lastQueuedSequenceNumber = sequenceNumber;\n this.lastObservedSeqNumber = sequenceNumber;\n\n // We will use same check in other places to make sure all the seq number above are set properly.\n assert(this.handler === undefined, 0x0e2 /* \"DeltaManager already has attached op handler!\" */);\n this.handler = handler;\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n assert(!!(this.handler as any), 0x0e3 /* \"Newly set op handler is null/undefined!\" */);\n\n // There should be no pending fetch!\n // This API is called right after attachOpHandler by Container.load().\n // We might have connection already and it might have called fetchMissingDeltas() from\n // setupNewSuccessfulConnection. But it should do nothing, because there is no way to fetch ops before\n // we know snapshot sequence number that is set in attachOpHandler. So all such calls should be noop.\n assert(this.fetchReason === undefined, 0x268 /* \"There can't be pending fetch that early in boot sequence!\" */);\n\n if (this.closed) {\n return;\n }\n\n this._inbound.resume();\n this._inboundSignal.resume();\n\n if (prefetchType !== \"none\") {\n const cacheOnly = prefetchType === \"cached\";\n await this.fetchMissingDeltasCore(`DocumentOpen_${prefetchType}`, cacheOnly);\n\n // Keep going with fetching ops from storage once we have all cached ops in.\n // But do not block load and make this request async / not blocking this api.\n // Ops processing will start once cached ops are in and and will stop when queue is empty\n // (which in most cases will happen when we are done processing cached ops)\n if (cacheOnly) {\n // fire and forget\n this.fetchMissingDeltas(\"PostDocumentOpen\");\n }\n }\n\n // Ensure there is no need to call this.processPendingOps() at the end of boot sequence\n assert(this.fetchReason !== undefined || this.pending.length === 0, 0x269 /* \"pending ops are not dropped\" */);\n }\n\n public connect(args: IConnectionArgs) {\n const fetchOpsFromStorage = args.fetchOpsFromStorage ?? true;\n logIfFalse(\n this.handler !== undefined || !fetchOpsFromStorage,\n this.logger,\n \"CantFetchWithoutBaseline\"); // can't fetch if no baseline\n\n // Note: There is race condition here.\n // We want to issue request to storage as soon as possible, to\n // reduce latency of becoming current, thus this code here.\n // But there is no ordering between fetching OPs and connection to delta stream\n // As result, we might be behind by the time we connect to delta stream\n // In case of r/w connection, that's not an issue, because we will hear our\n // own \"join\" message and realize any gap client has in ops.\n // But for view-only connection, we have no such signal, and with no traffic\n // on the wire, we might be always behind.\n // See comment at the end of \"connect\" handler\n if (fetchOpsFromStorage) {\n this.fetchMissingDeltas(args.reason);\n }\n\n this.connectionManager.connect(args.mode);\n }\n\n private async getDeltas(\n from: number, // inclusive\n to: number | undefined, // exclusive\n fetchReason: string,\n callback: (messages: ISequencedDocumentMessage[]) => void,\n cacheOnly: boolean) {\n const docService = this.serviceProvider();\n if (docService === undefined) {\n throw new Error(\"Delta manager is not attached\");\n }\n\n if (this.deltaStorage === undefined) {\n this.deltaStorage = await docService.connectToDeltaStorage();\n }\n\n let cancelFetch: (op: ISequencedDocumentMessage) => boolean;\n\n if (to !== undefined) {\n const lastExpectedOp = to - 1; // make it inclusive!\n\n // It is possible that due to asynchrony (including await above), required ops were already\n // received through delta stream. Validate that before moving forward.\n if (this.lastQueuedSequenceNumber >= lastExpectedOp) {\n this.logger.sendPerformanceEvent({\n reason: fetchReason,\n eventName: \"ExtraStorageCall\",\n early: true,\n from,\n to,\n ...this.connectionManager.connectionVerboseProps,\n });\n return;\n }\n\n // Be prepared for the case where webSocket would receive the ops that we are trying to fill through\n // storage. Ideally it should never happen (i.e. ops on socket are always ordered, and thus once we\n // detected gap, this gap can't be filled in later on through websocket).\n // And in practice that does look like the case. The place where this code gets hit is if we lost\n // connection and reconnected (likely to another box), and new socket's initial ops contains these ops.\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= lastExpectedOp;\n } else {\n // Unbound requests are made to proactively fetch ops, but also get up to date in cases where socket\n // is silent (and connection is \"read\", thus we might not have any data on how far client is behind).\n // Once we have any op coming in from socket, we can cancel it as it's not needed any more.\n // That said, if we have socket connection, make sure we got ops up to checkpointSequenceNumber!\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= this.lastObservedSeqNumber;\n }\n\n const controller = new AbortController();\n let opsFromFetch = false;\n\n const opListener = (op: ISequencedDocumentMessage) => {\n assert(op.sequenceNumber === this.lastQueuedSequenceNumber, 0x23a /* \"seq#'s\" */);\n // Ops that are coming from this request should not cancel itself.\n // This is useless for known ranges (to is defined) as it means request is over either way.\n // And it will cancel unbound request too early, not allowing us to learn where the end of the file is.\n if (!opsFromFetch && cancelFetch(op)) {\n controller.abort();\n this._inbound.off(\"push\", opListener);\n }\n };\n\n try {\n this._inbound.on(\"push\", opListener);\n assert(this.closeAbortController.signal.onabort === null, 0x1e8 /* \"reentrancy\" */);\n this.closeAbortController.signal.onabort = () => controller.abort();\n\n const stream = this.deltaStorage.fetchMessages(\n from, // inclusive\n to, // exclusive\n controller.signal,\n cacheOnly,\n fetchReason);\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await stream.read();\n if (result.done) {\n break;\n }\n try {\n opsFromFetch = true;\n callback(result.value);\n } finally {\n opsFromFetch = false;\n }\n }\n } finally {\n this.closeAbortController.signal.onabort = null;\n this._inbound.off(\"push\", opListener);\n assert(!opsFromFetch, 0x289 /* \"logic error\" */);\n }\n }\n\n /**\n * Closes the connection and clears inbound & outbound queues.\n */\n public close(error?: ICriticalContainerError): void {\n if (this.closed) {\n return;\n }\n this.closed = true;\n\n this.connectionManager.dispose(error);\n\n this.closeAbortController.abort();\n\n this._inbound.clear();\n this._inboundSignal.clear();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inbound.pause();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inboundSignal.pause();\n\n // Drop pending messages - this will ensure catchUp() does not go into infinite loop\n this.pending = [];\n\n // This needs to be the last thing we do (before removing listeners), as it causes\n // Container to dispose context and break ability of data stores / runtime to \"hear\"\n // from delta manager, including notification (above) about readonly state.\n this.emit(\"closed\", error);\n\n this.removeAllListeners();\n }\n\n public refreshDelayInfo(id: string) {\n this.throttlingIdSet.delete(id);\n if (this.throttlingIdSet.size === 0) {\n this.timeTillThrottling = 0;\n }\n }\n\n private disconnectHandler(reason: string) {\n this.messageBuffer.length = 0;\n this.emit(\"disconnect\", reason);\n }\n\n /**\n * Emit info about a delay in service communication on account of throttling.\n * @param id - Id of the connection that is delayed\n * @param delayMs - Duration of the delay\n * @param error - error object indicating the throttling\n */\n public emitDelayInfo(id: string, delayMs: number, error: unknown) {\n const timeNow = Date.now();\n this.throttlingIdSet.add(id);\n if (delayMs > 0 && (timeNow + delayMs > this.timeTillThrottling)) {\n this.timeTillThrottling = timeNow + delayMs;\n\n const throttlingWarning: IThrottlingWarning = ThrottlingWarning.wrap(\n error,\n delayMs / 1000 /* retryAfterSeconds */,\n this.logger,\n );\n this.emit(\"throttled\", throttlingWarning);\n }\n }\n\n // returns parts of message (in string format) that should never change for a given message.\n // Used for message comparison. It attempts to avoid comparing fields that potentially may differ.\n // for example, it's not clear if serverMetadata or timestamp property is a property of message or server state.\n // We only extract the most obvious fields that are sufficient (with high probability) to detect sequence number\n // reuse.\n // Also payload goes to telemetry, so no PII, including content!!\n // Note: It's possible for a duplicate op to be broadcasted and have everything the same except the timestamp.\n private comparableMessagePayload(m: ISequencedDocumentMessage) {\n return `${m.clientId}-${m.type}-${m.minimumSequenceNumber}-${m.referenceSequenceNumber}-${m.timestamp}`;\n }\n\n private enqueueMessages(\n messages: ISequencedDocumentMessage[],\n reason: string,\n allowGaps = false,\n ): void {\n if (this.handler === undefined) {\n // We did not setup handler yet.\n // This happens when we connect to web socket faster than we get attributes for container\n // and thus faster than attachOpHandler() is called\n // this.lastProcessedSequenceNumber is still zero, so we can't rely on this.fetchMissingDeltas()\n // to do the right thing.\n this.pending = this.pending.concat(messages);\n return;\n }\n\n // Pending ops should never just hang around for nothing.\n // This invariant will stay true through this function execution,\n // so there is no need to process pending ops here.\n // It's responsibility of\n // - attachOpHandler()\n // - fetchMissingDeltas() after it's done with querying storage\n assert(this.pending.length === 0 || this.fetchReason !== undefined, 0x1e9 /* \"Pending ops\" */);\n\n if (messages.length === 0) {\n return;\n }\n\n const from = messages[0].sequenceNumber;\n const last = messages[messages.length - 1].sequenceNumber;\n\n // Report stats about missing and duplicate ops\n // This helps better understand why we fetch ops from storage, and thus may delay\n // getting current / sending ops\n // It's possible that this batch is already too late - do not bother\n if (last > this.lastQueuedSequenceNumber) {\n let prev = from - 1;\n const initialGap = prev - this.lastQueuedSequenceNumber;\n let firstMissing: number | undefined;\n let duplicate = 0;\n let gap = 0;\n\n // Count all gaps and duplicates\n for (const message of messages) {\n if (message.sequenceNumber === prev) {\n duplicate++;\n } else if (message.sequenceNumber !== prev + 1) {\n gap++;\n if (firstMissing === undefined) {\n firstMissing = prev + 1;\n }\n }\n prev = message.sequenceNumber;\n }\n\n let eventName: string | undefined;\n\n // Report if we found some issues\n if (duplicate !== 0 || gap !== 0 && !allowGaps || initialGap > 0 && this.fetchReason === undefined) {\n eventName = \"enqueueMessages\";\n // Also report if we are fetching ops, and same range comes in, thus making this fetch obsolete.\n } else if (this.fetchReason !== undefined && this.fetchReason !== reason &&\n (from <= this.lastQueuedSequenceNumber + 1 && last > this.lastQueuedSequenceNumber)) {\n eventName = \"enqueueMessagesExtraFetch\";\n }\n\n // Report if there is something to report\n // Do not report when pending fetch is in progress, as such reporting will not\n // correctly take into account pending ops.\n if (eventName !== undefined) {\n this.logger.sendPerformanceEvent({\n eventName,\n reason,\n previousReason: this.prevEnqueueMessagesReason,\n from,\n to: last + 1, // exclusive, being consistent with the other telemetry / APIs\n length: messages.length,\n fetchReason: this.fetchReason,\n duplicate: duplicate > 0 ? duplicate : undefined,\n initialGap: initialGap !== 0 ? initialGap : undefined,\n gap: gap > 0 ? gap : undefined,\n firstMissing,\n dmInitialSeqNumber: this.initialSequenceNumber,\n ...this.connectionManager.connectionVerboseProps,\n });\n }\n }\n\n this.updateLatestKnownOpSeqNumber(messages[messages.length - 1].sequenceNumber);\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n assert(n === undefined || n === this.lastQueuedSequenceNumber,\n 0x0ec /* \"Unexpected value for previously processed message's sequence number\" */);\n\n for (const message of messages) {\n // Check that the messages are arriving in the expected order\n if (message.sequenceNumber <= this.lastQueuedSequenceNumber) {\n // Validate that we do not have data loss, i.e. sequencing is reset and started again\n // with numbers that this client already observed before.\n if (this.previouslyProcessedMessage?.sequenceNumber === message.sequenceNumber) {\n const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);\n const message2 = this.comparableMessagePayload(message);\n if (message1 !== message2) {\n const error = new NonRetryableError(\n // This looks like a data corruption but the culprit was that the file was overwritten\n // in storage. See PR #5882.\n // Likely to be an issue with Fluid Services. Content does not match previous client\n // knowledge about this file. If the file is overwritten for any reason, this error can be\n // hit. One example is that some clients could be submitting ops to two different service\n // instances such that the same sequence number is reused for two different ops.\n // pre-0.58 error message: twoMessagesWithSameSeqNumAndDifferentPayload\n \"Found two messages with the same sequenceNumber but different payloads. Likely to be a \"\n + \"service issue\",\n DriverErrorType.fileOverwrittenInStorage,\n {\n clientId: this.connectionManager.clientId,\n sequenceNumber: message.sequenceNumber,\n message1,\n message2,\n driverVersion: undefined,\n },\n );\n this.close(error);\n }\n }\n } else if (message.sequenceNumber !== this.lastQueuedSequenceNumber + 1) {\n this.pending.push(message);\n this.fetchMissingDeltas(reason, message.sequenceNumber);\n } else {\n this.lastQueuedSequenceNumber = message.sequenceNumber;\n this.previouslyProcessedMessage = message;\n this._inbound.push(message);\n }\n }\n\n // When / if we report a gap in ops in the future, we want telemetry to correctly reflect source\n // of prior ops. But if we have some out of order ops (this.pending), then reporting current reason\n // becomes not accurate, as the gap existed before current batch, so we should just report \"unknown\".\n this.prevEnqueueMessagesReason = this.pending.length > 0 ? \"unknown\" : reason;\n }\n\n private processInboundMessage(message: ISequencedDocumentMessage): void {\n const startTime = Date.now();\n this.lastProcessedMessage = message;\n\n // All non-system messages are coming from some client, and should have clientId\n // System messages may have no clientId (but some do, like propose, noop, summarize)\n assert(\n message.clientId !== undefined\n || !(isClientMessage(message)),\n 0x0ed /* \"non-system message have to have clientId\" */,\n );\n\n // TODO Remove after SPO picks up the latest build.\n if (\n typeof message.contents === \"string\"\n && message.contents !== \"\"\n && message.type !== MessageType.ClientLeave\n ) {\n message.contents = JSON.parse(message.contents);\n }\n\n this.connectionManager.beforeProcessingIncomingOp(message);\n\n // Watch the minimum sequence number and be ready to update as needed\n if (this.minSequenceNumber > message.minimumSequenceNumber) {\n // pre-0.58 error message: msnMovesBackwards\n throw new DataCorruptionError(\"Found a lower minimumSequenceNumber (msn) than previously recorded\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.minSequenceNumber = message.minimumSequenceNumber;\n\n if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {\n // pre-0.58 error message: nonSequentialSequenceNumber\n throw new DataCorruptionError(\"Found a non-Sequential sequenceNumber\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.lastProcessedSequenceNumber = message.sequenceNumber;\n\n // a bunch of code assumes that this is true\n assert(this.lastProcessedSequenceNumber <= this.lastObservedSeqNumber,\n 0x267 /* \"lastObservedSeqNumber should be updated first\" */);\n\n // Back-compat for older server with no term\n if (message.term === undefined) {\n message.term = 1;\n }\n this.baseTerm = message.term;\n\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound message without a handler attached\");\n }\n this.handler.process(message);\n\n const endTime = Date.now();\n\n // Should be last, after changing this.lastProcessedSequenceNumber above, as many callers\n // test this.lastProcessedSequenceNumber instead of using op.sequenceNumber itself.\n this.emit(\"op\", message, endTime - startTime);\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private fetchMissingDeltas(reasonArg: string, to?: number) {\n this.fetchMissingDeltasCore(reasonArg, false /* cacheOnly */, to).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"fetchMissingDeltasException\" }, error);\n });\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private async fetchMissingDeltasCore(\n reason: string,\n cacheOnly: boolean,\n to?: number) {\n // Exit out early if we're already fetching deltas\n if (this.fetchReason !== undefined) {\n return;\n }\n\n if (this.closed) {\n this.logger.sendTelemetryEvent({ eventName: \"fetchMissingDeltasClosedConnection\", reason });\n return;\n }\n\n if (this.handler === undefined) {\n // We do not poses yet any information\n assert(this.lastQueuedSequenceNumber === 0, 0x26b /* \"initial state\" */);\n return;\n }\n\n try {\n let from = this.lastQueuedSequenceNumber + 1;\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n if (n !== undefined) {\n // If we already processed at least one op, then we have this.previouslyProcessedMessage populated\n // and can use it to validate that we are operating on same file, i.e. it was not overwritten.\n // Knowing about this mechanism, we could ask for op we already observed to increase validation.\n // This is especially useful when coming out of offline mode or loading from\n // very old cached (by client / driver) snapshot.\n assert(n === this.lastQueuedSequenceNumber, 0x0f2 /* \"previouslyProcessedMessage\" */);\n assert(from > 1, 0x0f3 /* \"not positive\" */);\n from--;\n }\n\n const fetchReason = `${reason}_fetch`;\n this.fetchReason = fetchReason;\n\n await this.getDeltas(\n from,\n to,\n fetchReason,\n (messages) => {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.enqueueMessages(messages, fetchReason);\n },\n cacheOnly);\n } catch (error) {\n this.logger.sendErrorEvent({ eventName: \"GetDeltas_Exception\" }, error);\n this.close(normalizeError(error));\n } finally {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.fetchReason = undefined;\n this.processPendingOps(reason);\n }\n }\n\n /**\n * Sorts pending ops and attempts to apply them\n */\n private processPendingOps(reason?: string): void {\n if (this.closed) {\n return;\n }\n\n assert(this.handler !== undefined, 0x26c /* \"handler should be installed\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.pending = [];\n // Given that we do not track where these ops came from any more, it's not very\n // actionably to report gaps in this range.\n this.enqueueMessages(pendingSorted, `${reason}_pending`, true /* allowGaps */);\n\n // Re-entrancy is ignored by fetchMissingDeltas, execution will come here when it's over\n if (this.fetchReason === undefined) {\n // See issue #7312 for more details\n // We observe cases where client gets into situation where it is not aware of missing ops\n // (i.e. client being behind), and as such, does not attempt to fetch them.\n // In some cases client may not have enough signal (example - \"read\" connection that is silent -\n // there is no easy way for client to realize it's behind, see a bit of commentary / logic at the\n // end of setupNewSuccessfulConnection). In other cases it should be able to learn that info (\"write\"\n // connection, learn by receiving its own join op), but data suggest it does not happen.\n // In 50% of these cases we do know we are behind through checkpointSequenceNumber on connection object\n // and thus can leverage that to trigger recovery. But this is not going to solve all the problems\n // (the other 50%), and thus these errors below should be looked at even if code below results in\n // recovery.\n if (this.lastQueuedSequenceNumber < this.lastObservedSeqNumber) {\n this.fetchMissingDeltas(\"OpsBehind\");\n }\n }\n }\n\n private updateLatestKnownOpSeqNumber(seq: number) {\n if (this.lastObservedSeqNumber < seq) {\n this.lastObservedSeqNumber = seq;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"deltaManager.js","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAgBlC,+DAAyE;AACzE,qEAMyC;AACzC,2EAI4C;AAC5C,+EAM8C;AAC9C,+DAGsC;AACtC,qEAMyC;AACzC,6CAA0C;AAqB1C;;;GAGG;AACH,MAAa,YACT,SAAQ,gCAA8C;IAyNtD,YACqB,eAAmD,EACnD,MAAwB,EACxB,OAAsB,EACvC,uBAAqF;QAErF,KAAK,EAAE,CAAC;QALS,oBAAe,GAAf,eAAe,CAAoC;QACnD,WAAM,GAAN,MAAM,CAAkB;QACxB,YA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iGAAiG;YACjG,qGAAqG;YACrG,wFAAwF;YACxF,uGAAuG;YACvG,kGAAkG;YAClG,iGAAiG;YACjG,YAAY;YACZ,IAAI,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE;gBAC5D,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;aACxC;SACJ;IACL,CAAC;IAEO,4BAA4B,CAAC,GAAW;QAC5C,IAAI,IAAI,CAAC,qBAAqB,GAAG,GAAG,EAAE;YAClC,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC;SACpC;IACL,CAAC;CACJ;AAx3BD,oCAw3BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n ITelemetryLogger,\n IEventProvider,\n ITelemetryProperties,\n ITelemetryErrorEvent,\n} from \"@fluidframework/common-definitions\";\nimport {\n IDeltaHandlerStrategy,\n IDeltaManager,\n IDeltaManagerEvents,\n IDeltaQueue,\n ICriticalContainerError,\n IThrottlingWarning,\n IConnectionDetails,\n} from \"@fluidframework/container-definitions\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n normalizeError,\n logIfFalse,\n safeRaiseEvent,\n MonitoringContext,\n loggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISignalMessage,\n MessageType,\n ConnectionMode,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n NonRetryableError,\n isClientMessage,\n} from \"@fluidframework/driver-utils\";\nimport {\n ThrottlingWarning,\n DataCorruptionError,\n extractSafePropertiesFromMessage,\n DataProcessingError,\n UsageError,\n} from \"@fluidframework/container-utils\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport {\n IConnectionManagerFactoryArgs,\n IConnectionManager,\n } from \"./contracts\";\n\nexport interface IConnectionArgs {\n mode?: ConnectionMode;\n fetchOpsFromStorage?: boolean;\n reason: string;\n}\n\n/**\n * Includes events emitted by the concrete implementation DeltaManager\n * but not exposed on the public interface IDeltaManager\n */\nexport interface IDeltaManagerInternalEvents extends IDeltaManagerEvents {\n (event: \"throttled\", listener: (error: IThrottlingWarning) => void);\n (event: \"closed\", listener: (error?: ICriticalContainerError) => void);\n}\n\n/**\n * Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta\n * messages in order regardless of possible network conditions or timings causing out of order delivery.\n */\nexport class DeltaManager<TConnectionManager extends IConnectionManager>\n extends TypedEventEmitter<IDeltaManagerInternalEvents>\n implements\n IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n IEventProvider<IDeltaManagerInternalEvents> {\n public readonly connectionManager: TConnectionManager;\n\n public get active(): boolean { return this._active(); }\n\n public get disposed() { return this.closed; }\n\n public get IDeltaSender() { return this; }\n\n private pending: ISequencedDocumentMessage[] = [];\n private fetchReason: string | undefined;\n\n private readonly mc: MonitoringContext;\n\n // A boolean used to assert that ops are not being sent while processing another op.\n private currentlyProcessingOps: boolean = false;\n\n // Feature gate that closes a container when sending an op if the container is\n // concurrently processing another op\n private readonly preventConcurrentOpSend: boolean = true;\n\n // The minimum sequence number and last sequence number received from the server\n private minSequenceNumber: number = 0;\n\n // There are three numbers we track\n // * lastQueuedSequenceNumber is the last queued sequence number. If there are gaps in seq numbers, then this number\n // is not updated until we cover that gap, so it increases each time by 1.\n // * lastObservedSeqNumber is an estimation of last known sequence number for container in storage. It's initially\n // populated at web socket connection time (if storage provides that info) and is updated once ops shows up.\n // It's never less than lastQueuedSequenceNumber\n // * lastProcessedSequenceNumber - last processed sequence number\n private lastQueuedSequenceNumber: number = 0;\n private lastObservedSeqNumber: number = 0;\n private lastProcessedSequenceNumber: number = 0;\n private lastProcessedMessage: ISequencedDocumentMessage | undefined;\n private baseTerm: number = 0;\n\n /**\n * Track down the ops size.\n */\n private opsSize: number = 0;\n private prevEnqueueMessagesReason: string | undefined;\n private previouslyProcessedMessage: ISequencedDocumentMessage | undefined;\n\n // The sequence number we initially loaded from\n // In case of reading from a snapshot or pending state, its value will be equal to\n // the last message that got serialized.\n private initSequenceNumber: number = 0;\n\n private readonly _inbound: DeltaQueue<ISequencedDocumentMessage>;\n private readonly _inboundSignal: DeltaQueue<ISignalMessage>;\n\n private closed = false;\n\n private handler: IDeltaHandlerStrategy | undefined;\n private deltaStorage: IDocumentDeltaStorageService | undefined;\n\n private readonly throttlingIdSet = new Set<string>();\n private timeTillThrottling: number = 0;\n\n public readonly closeAbortController = new AbortController();\n\n private readonly deltaStorageDelayId = uuid();\n private readonly deltaStreamDelayId = uuid();\n\n private messageBuffer: IDocumentMessage[] = [];\n\n private _checkpointSequenceNumber: number | undefined;\n\n public get inbound(): IDeltaQueue<ISequencedDocumentMessage> {\n return this._inbound;\n }\n\n public get inboundSignal(): IDeltaQueue<ISignalMessage> {\n return this._inboundSignal;\n }\n\n public get initialSequenceNumber(): number {\n return this.initSequenceNumber;\n }\n\n public get lastSequenceNumber(): number {\n return this.lastProcessedSequenceNumber;\n }\n\n public get lastMessage() {\n return this.lastProcessedMessage;\n }\n\n public get lastKnownSeqNumber() {\n return this.lastObservedSeqNumber;\n }\n\n public get referenceTerm(): number {\n return this.baseTerm;\n }\n\n public get minimumSequenceNumber(): number {\n return this.minSequenceNumber;\n }\n\n /**\n * Tells if current connection has checkpoint information.\n * I.e. we know how far behind the client was at the time of establishing connection\n */\n public get hasCheckpointSequenceNumber() {\n // Valid to be called only if we have active connection.\n assert(this.connectionManager.connected, 0x0df /* \"Missing active connection\" */);\n return this._checkpointSequenceNumber !== undefined;\n }\n\n // Forwarding connection manager properties / IDeltaManager implementation\n public get maxMessageSize(): number { return this.connectionManager.maxMessageSize; }\n public get version() { return this.connectionManager.version; }\n public get serviceConfiguration() { return this.connectionManager.serviceConfiguration; }\n public get outbound() { return this.connectionManager.outbound; }\n public get readOnlyInfo() { return this.connectionManager.readOnlyInfo; }\n public get clientDetails() { return this.connectionManager.clientDetails; }\n\n public submit(type: MessageType, contents?: string, batch = false, metadata?: any) {\n if (this.currentlyProcessingOps && this.preventConcurrentOpSend) {\n this.close(new UsageError(\"Making changes to data model is disallowed while processing ops.\"));\n }\n const messagePartial: Omit<IDocumentMessage, \"clientSequenceNumber\"> = {\n contents,\n metadata,\n referenceSequenceNumber: this.lastProcessedSequenceNumber,\n type,\n };\n\n if (!batch) {\n this.flush();\n }\n const message = this.connectionManager.prepareMessageToSend(messagePartial);\n if (message === undefined) {\n return -1;\n }\n\n if (contents !== undefined) {\n this.opsSize += contents.length;\n }\n\n this.messageBuffer.push(message);\n\n this.emit(\"submitOp\", message);\n\n if (!batch) {\n this.flush();\n }\n return message.clientSequenceNumber;\n }\n\n public submitSignal(content: any) { return this.connectionManager.submitSignal(content); }\n\n public flush() {\n const batch = this.messageBuffer;\n if (batch.length === 0) {\n return;\n }\n\n this.messageBuffer = [];\n\n // The prepareFlush event allows listeners to append metadata to the batch prior to submission.\n this.emit(\"prepareSend\", batch);\n\n if (batch.length === 1) {\n assert(batch[0].metadata?.batch === undefined, 0x3c9 /* no batch markup on single message */);\n } else {\n assert(batch[0].metadata?.batch === true, 0x3ca /* no start batch markup */);\n assert(batch[batch.length - 1].metadata?.batch === false, 0x3cb /* no end batch markup */);\n }\n\n this.connectionManager.sendMessages(batch);\n\n assert(this.messageBuffer.length === 0, 0x3cc /* reentrancy */);\n }\n\n public get connectionProps(): ITelemetryProperties {\n return {\n sequenceNumber: this.lastSequenceNumber,\n opsSize: this.opsSize > 0 ? this.opsSize : undefined,\n ...this.connectionManager.connectionProps,\n };\n }\n\n /**\n * Log error event with a bunch of internal to DeltaManager information about state of op processing\n * Used to diagnose connectivity issues related to op processing (i.e. cases where for some reason\n * we stop processing ops that results in no processing join op and thus moving to connected state)\n * @param event - Event to log.\n */\n public logConnectionIssue(event: ITelemetryErrorEvent) {\n assert(this.connectionManager.connected, 0x238 /* \"called only in connected state\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.logger.sendErrorEvent({\n ...event,\n // This directly tells us if fetching ops is in flight, and thus likely the reason of\n // stalled op processing\n fetchReason: this.fetchReason,\n // A bunch of useful sequence numbers to understand if we are holding some ops from processing\n lastQueuedSequenceNumber: this.lastQueuedSequenceNumber, // last sequential op\n lastProcessedSequenceNumber: this.lastProcessedSequenceNumber, // same as above, but after processing\n lastObserved: this.lastObservedSeqNumber, // last sequence we ever saw; may have gaps with above.\n // connection info\n ...this.connectionManager.connectionVerboseProps,\n pendingOps: this.pending.length, // Do we have any pending ops?\n pendingFirst: pendingSorted[0]?.sequenceNumber, // is the first pending op the one that we are missing?\n haveHandler: this.handler !== undefined, // do we have handler installed?\n inboundLength: this.inbound.length,\n inboundPaused: this.inbound.paused,\n });\n }\n\n constructor(\n private readonly serviceProvider: () => IDocumentService | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly _active: () => boolean,\n createConnectionManager: (props: IConnectionManagerFactoryArgs) => TConnectionManager,\n ) {\n super();\n const props: IConnectionManagerFactoryArgs = {\n incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => {\n try {\n this.enqueueMessages(messages, reason);\n } catch (error) {\n this.logger.sendErrorEvent({ eventName: \"EnqueueMessages_Exception\" }, error);\n this.close(normalizeError(error));\n }\n },\n signalHandler: (message: ISignalMessage) => this._inboundSignal.push(message),\n reconnectionDelayHandler: (delayMs: number, error: unknown) =>\n this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),\n closeHandler: (error: any) => this.close(error),\n disconnectHandler: (reason: string) => this.disconnectHandler(reason),\n connectHandler: (connection: IConnectionDetails) => this.connectHandler(connection),\n pongHandler: (latency: number) => this.emit(\"pong\", latency),\n readonlyChangeHandler: (readonly?: boolean) => safeRaiseEvent(this, this.logger, \"readonly\", readonly),\n };\n\n this.connectionManager = createConnectionManager(props);\n this.mc = loggerToMonitoringContext(logger);\n this.preventConcurrentOpSend = this.mc.config.getBoolean(\"Fluid.Container.ConcurrentOpSend\") === true;\n this._inbound = new DeltaQueue<ISequencedDocumentMessage>(\n (op) => {\n this.processInboundMessage(op);\n });\n\n this._inbound.on(\"error\", (error) => {\n this.close(\n DataProcessingError.wrapIfUnrecognized(error, \"deltaManagerInboundErrorHandler\", this.lastMessage));\n });\n\n // Inbound signal queue\n this._inboundSignal = new DeltaQueue<ISignalMessage>((message) => {\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound signal without a handler attached\");\n }\n this.handler.processSignal({\n clientId: message.clientId,\n content: JSON.parse(message.content as string),\n });\n });\n\n this._inboundSignal.on(\"error\", (error) => {\n this.close(normalizeError(error));\n });\n\n // Initially, all queues are created paused.\n // - outbound is flipped back and forth in setupNewSuccessfulConnection / disconnectFromDeltaStream\n // - inbound & inboundSignal are resumed in attachOpHandler() when we have handler setup\n }\n\n private connectHandler(connection: IConnectionDetails) {\n this.refreshDelayInfo(this.deltaStreamDelayId);\n\n const props = this.connectionManager.connectionVerboseProps;\n props.connectionLastQueuedSequenceNumber = this.lastQueuedSequenceNumber;\n props.connectionLastObservedSeqNumber = this.lastObservedSeqNumber;\n\n const checkpointSequenceNumber = connection.checkpointSequenceNumber;\n this._checkpointSequenceNumber = checkpointSequenceNumber;\n if (checkpointSequenceNumber !== undefined) {\n this.updateLatestKnownOpSeqNumber(checkpointSequenceNumber);\n }\n\n // We cancel all ops on lost of connectivity, and rely on DDSes to resubmit them.\n // Semantics are not well defined for batches (and they are broken right now on disconnects anyway),\n // but it's safe to assume (until better design is put into place) that batches should not exist\n // across multiple connections. Right now we assume runtime will not submit any ops in disconnected\n // state. As requirements change, so should these checks.\n assert(this.messageBuffer.length === 0, 0x0e9 /* \"messageBuffer is not empty on new connection\" */);\n\n this.opsSize = 0;\n\n this.emit(\n \"connect\",\n connection,\n checkpointSequenceNumber !== undefined ?\n this.lastObservedSeqNumber - this.lastSequenceNumber : undefined);\n\n // If we got some initial ops, then we know the gap and call above fetched ops to fill it.\n // Same is true for \"write\" mode even if we have no ops - we will get \"join\" own op very very soon.\n // However if we are connecting as view-only, then there is no good signal to realize if client is behind.\n // Thus we have to hit storage to see if any ops are there.\n if (checkpointSequenceNumber !== undefined) {\n // We know how far we are behind (roughly). If it's non-zero gap, fetch ops right away.\n if (checkpointSequenceNumber > this.lastQueuedSequenceNumber) {\n this.fetchMissingDeltas(\"AfterConnection\");\n }\n // we do not know the gap, and we will not learn about it if socket is quite - have to ask.\n } else if (connection.mode === \"read\") {\n this.fetchMissingDeltas(\"AfterReadConnection\");\n }\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Sets the sequence number from which inbound messages should be returned\n */\n public async attachOpHandler(\n minSequenceNumber: number,\n sequenceNumber: number,\n term: number,\n handler: IDeltaHandlerStrategy,\n prefetchType: \"cached\" | \"all\" | \"none\" = \"none\",\n ) {\n this.initSequenceNumber = sequenceNumber;\n this.lastProcessedSequenceNumber = sequenceNumber;\n this.baseTerm = term;\n this.minSequenceNumber = minSequenceNumber;\n this.lastQueuedSequenceNumber = sequenceNumber;\n this.lastObservedSeqNumber = sequenceNumber;\n\n // We will use same check in other places to make sure all the seq number above are set properly.\n assert(this.handler === undefined, 0x0e2 /* \"DeltaManager already has attached op handler!\" */);\n this.handler = handler;\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n assert(!!(this.handler as any), 0x0e3 /* \"Newly set op handler is null/undefined!\" */);\n\n // There should be no pending fetch!\n // This API is called right after attachOpHandler by Container.load().\n // We might have connection already and it might have called fetchMissingDeltas() from\n // setupNewSuccessfulConnection. But it should do nothing, because there is no way to fetch ops before\n // we know snapshot sequence number that is set in attachOpHandler. So all such calls should be noop.\n assert(this.fetchReason === undefined, 0x268 /* \"There can't be pending fetch that early in boot sequence!\" */);\n\n if (this.closed) {\n return;\n }\n\n this._inbound.resume();\n this._inboundSignal.resume();\n\n if (prefetchType !== \"none\") {\n const cacheOnly = prefetchType === \"cached\";\n await this.fetchMissingDeltasCore(`DocumentOpen_${prefetchType}`, cacheOnly);\n\n // Keep going with fetching ops from storage once we have all cached ops in.\n // But do not block load and make this request async / not blocking this api.\n // Ops processing will start once cached ops are in and and will stop when queue is empty\n // (which in most cases will happen when we are done processing cached ops)\n if (cacheOnly) {\n // fire and forget\n this.fetchMissingDeltas(\"PostDocumentOpen\");\n }\n }\n\n // Ensure there is no need to call this.processPendingOps() at the end of boot sequence\n assert(this.fetchReason !== undefined || this.pending.length === 0, 0x269 /* \"pending ops are not dropped\" */);\n }\n\n public connect(args: IConnectionArgs) {\n const fetchOpsFromStorage = args.fetchOpsFromStorage ?? true;\n logIfFalse(\n this.handler !== undefined || !fetchOpsFromStorage,\n this.logger,\n \"CantFetchWithoutBaseline\"); // can't fetch if no baseline\n\n // Note: There is race condition here.\n // We want to issue request to storage as soon as possible, to\n // reduce latency of becoming current, thus this code here.\n // But there is no ordering between fetching OPs and connection to delta stream\n // As result, we might be behind by the time we connect to delta stream\n // In case of r/w connection, that's not an issue, because we will hear our\n // own \"join\" message and realize any gap client has in ops.\n // But for view-only connection, we have no such signal, and with no traffic\n // on the wire, we might be always behind.\n // See comment at the end of \"connect\" handler\n if (fetchOpsFromStorage) {\n this.fetchMissingDeltas(args.reason);\n }\n\n this.connectionManager.connect(args.mode);\n }\n\n private async getDeltas(\n from: number, // inclusive\n to: number | undefined, // exclusive\n fetchReason: string,\n callback: (messages: ISequencedDocumentMessage[]) => void,\n cacheOnly: boolean) {\n const docService = this.serviceProvider();\n if (docService === undefined) {\n throw new Error(\"Delta manager is not attached\");\n }\n\n if (this.deltaStorage === undefined) {\n this.deltaStorage = await docService.connectToDeltaStorage();\n }\n\n let cancelFetch: (op: ISequencedDocumentMessage) => boolean;\n\n if (to !== undefined) {\n const lastExpectedOp = to - 1; // make it inclusive!\n\n // It is possible that due to asynchrony (including await above), required ops were already\n // received through delta stream. Validate that before moving forward.\n if (this.lastQueuedSequenceNumber >= lastExpectedOp) {\n this.logger.sendPerformanceEvent({\n reason: fetchReason,\n eventName: \"ExtraStorageCall\",\n early: true,\n from,\n to,\n ...this.connectionManager.connectionVerboseProps,\n });\n return;\n }\n\n // Be prepared for the case where webSocket would receive the ops that we are trying to fill through\n // storage. Ideally it should never happen (i.e. ops on socket are always ordered, and thus once we\n // detected gap, this gap can't be filled in later on through websocket).\n // And in practice that does look like the case. The place where this code gets hit is if we lost\n // connection and reconnected (likely to another box), and new socket's initial ops contains these ops.\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= lastExpectedOp;\n } else {\n // Unbound requests are made to proactively fetch ops, but also get up to date in cases where socket\n // is silent (and connection is \"read\", thus we might not have any data on how far client is behind).\n // Once we have any op coming in from socket, we can cancel it as it's not needed any more.\n // That said, if we have socket connection, make sure we got ops up to checkpointSequenceNumber!\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= this.lastObservedSeqNumber;\n }\n\n const controller = new AbortController();\n let opsFromFetch = false;\n\n const opListener = (op: ISequencedDocumentMessage) => {\n assert(op.sequenceNumber === this.lastQueuedSequenceNumber, 0x23a /* \"seq#'s\" */);\n // Ops that are coming from this request should not cancel itself.\n // This is useless for known ranges (to is defined) as it means request is over either way.\n // And it will cancel unbound request too early, not allowing us to learn where the end of the file is.\n if (!opsFromFetch && cancelFetch(op)) {\n controller.abort();\n this._inbound.off(\"push\", opListener);\n }\n };\n\n try {\n this._inbound.on(\"push\", opListener);\n assert(this.closeAbortController.signal.onabort === null, 0x1e8 /* \"reentrancy\" */);\n this.closeAbortController.signal.onabort = () => controller.abort();\n\n const stream = this.deltaStorage.fetchMessages(\n from, // inclusive\n to, // exclusive\n controller.signal,\n cacheOnly,\n fetchReason);\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await stream.read();\n if (result.done) {\n break;\n }\n try {\n opsFromFetch = true;\n callback(result.value);\n } finally {\n opsFromFetch = false;\n }\n }\n } finally {\n this.closeAbortController.signal.onabort = null;\n this._inbound.off(\"push\", opListener);\n assert(!opsFromFetch, 0x289 /* \"logic error\" */);\n }\n }\n\n /**\n * Closes the connection and clears inbound & outbound queues.\n */\n public close(error?: ICriticalContainerError): void {\n if (this.closed) {\n return;\n }\n this.closed = true;\n\n this.connectionManager.dispose(error);\n\n this.closeAbortController.abort();\n\n this._inbound.clear();\n this._inboundSignal.clear();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inbound.pause();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inboundSignal.pause();\n\n // Drop pending messages - this will ensure catchUp() does not go into infinite loop\n this.pending = [];\n\n // This needs to be the last thing we do (before removing listeners), as it causes\n // Container to dispose context and break ability of data stores / runtime to \"hear\"\n // from delta manager, including notification (above) about readonly state.\n this.emit(\"closed\", error);\n\n this.removeAllListeners();\n }\n\n public refreshDelayInfo(id: string) {\n this.throttlingIdSet.delete(id);\n if (this.throttlingIdSet.size === 0) {\n this.timeTillThrottling = 0;\n }\n }\n\n private disconnectHandler(reason: string) {\n this.messageBuffer.length = 0;\n this.emit(\"disconnect\", reason);\n }\n\n /**\n * Emit info about a delay in service communication on account of throttling.\n * @param id - Id of the connection that is delayed\n * @param delayMs - Duration of the delay\n * @param error - error object indicating the throttling\n */\n public emitDelayInfo(id: string, delayMs: number, error: unknown) {\n const timeNow = Date.now();\n this.throttlingIdSet.add(id);\n if (delayMs > 0 && (timeNow + delayMs > this.timeTillThrottling)) {\n this.timeTillThrottling = timeNow + delayMs;\n\n const throttlingWarning: IThrottlingWarning = ThrottlingWarning.wrap(\n error,\n delayMs / 1000 /* retryAfterSeconds */,\n this.logger,\n );\n this.emit(\"throttled\", throttlingWarning);\n }\n }\n\n // returns parts of message (in string format) that should never change for a given message.\n // Used for message comparison. It attempts to avoid comparing fields that potentially may differ.\n // for example, it's not clear if serverMetadata or timestamp property is a property of message or server state.\n // We only extract the most obvious fields that are sufficient (with high probability) to detect sequence number\n // reuse.\n // Also payload goes to telemetry, so no PII, including content!!\n // Note: It's possible for a duplicate op to be broadcasted and have everything the same except the timestamp.\n private comparableMessagePayload(m: ISequencedDocumentMessage) {\n return `${m.clientId}-${m.type}-${m.minimumSequenceNumber}-${m.referenceSequenceNumber}-${m.timestamp}`;\n }\n\n private enqueueMessages(\n messages: ISequencedDocumentMessage[],\n reason: string,\n allowGaps = false,\n ): void {\n if (this.handler === undefined) {\n // We did not setup handler yet.\n // This happens when we connect to web socket faster than we get attributes for container\n // and thus faster than attachOpHandler() is called\n // this.lastProcessedSequenceNumber is still zero, so we can't rely on this.fetchMissingDeltas()\n // to do the right thing.\n this.pending = this.pending.concat(messages);\n return;\n }\n\n // Pending ops should never just hang around for nothing.\n // This invariant will stay true through this function execution,\n // so there is no need to process pending ops here.\n // It's responsibility of\n // - attachOpHandler()\n // - fetchMissingDeltas() after it's done with querying storage\n assert(this.pending.length === 0 || this.fetchReason !== undefined, 0x1e9 /* \"Pending ops\" */);\n\n if (messages.length === 0) {\n return;\n }\n\n const from = messages[0].sequenceNumber;\n const last = messages[messages.length - 1].sequenceNumber;\n\n // Report stats about missing and duplicate ops\n // This helps better understand why we fetch ops from storage, and thus may delay\n // getting current / sending ops\n // It's possible that this batch is already too late - do not bother\n if (last > this.lastQueuedSequenceNumber) {\n let prev = from - 1;\n const initialGap = prev - this.lastQueuedSequenceNumber;\n let firstMissing: number | undefined;\n let duplicate = 0;\n let gap = 0;\n\n // Count all gaps and duplicates\n for (const message of messages) {\n if (message.sequenceNumber === prev) {\n duplicate++;\n } else if (message.sequenceNumber !== prev + 1) {\n gap++;\n if (firstMissing === undefined) {\n firstMissing = prev + 1;\n }\n }\n prev = message.sequenceNumber;\n }\n\n let eventName: string | undefined;\n\n // Report if we found some issues\n if (duplicate !== 0 || gap !== 0 && !allowGaps || initialGap > 0 && this.fetchReason === undefined) {\n eventName = \"enqueueMessages\";\n // Also report if we are fetching ops, and same range comes in, thus making this fetch obsolete.\n } else if (this.fetchReason !== undefined && this.fetchReason !== reason &&\n (from <= this.lastQueuedSequenceNumber + 1 && last > this.lastQueuedSequenceNumber)) {\n eventName = \"enqueueMessagesExtraFetch\";\n }\n\n // Report if there is something to report\n // Do not report when pending fetch is in progress, as such reporting will not\n // correctly take into account pending ops.\n if (eventName !== undefined) {\n this.logger.sendPerformanceEvent({\n eventName,\n reason,\n previousReason: this.prevEnqueueMessagesReason,\n from,\n to: last + 1, // exclusive, being consistent with the other telemetry / APIs\n length: messages.length,\n fetchReason: this.fetchReason,\n duplicate: duplicate > 0 ? duplicate : undefined,\n initialGap: initialGap !== 0 ? initialGap : undefined,\n gap: gap > 0 ? gap : undefined,\n firstMissing,\n dmInitialSeqNumber: this.initialSequenceNumber,\n ...this.connectionManager.connectionVerboseProps,\n });\n }\n }\n\n this.updateLatestKnownOpSeqNumber(messages[messages.length - 1].sequenceNumber);\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n assert(n === undefined || n === this.lastQueuedSequenceNumber,\n 0x0ec /* \"Unexpected value for previously processed message's sequence number\" */);\n\n for (const message of messages) {\n // Check that the messages are arriving in the expected order\n if (message.sequenceNumber <= this.lastQueuedSequenceNumber) {\n // Validate that we do not have data loss, i.e. sequencing is reset and started again\n // with numbers that this client already observed before.\n if (this.previouslyProcessedMessage?.sequenceNumber === message.sequenceNumber) {\n const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);\n const message2 = this.comparableMessagePayload(message);\n if (message1 !== message2) {\n const error = new NonRetryableError(\n // This looks like a data corruption but the culprit was that the file was overwritten\n // in storage. See PR #5882.\n // Likely to be an issue with Fluid Services. Content does not match previous client\n // knowledge about this file. If the file is overwritten for any reason, this error can be\n // hit. One example is that some clients could be submitting ops to two different service\n // instances such that the same sequence number is reused for two different ops.\n // pre-0.58 error message: twoMessagesWithSameSeqNumAndDifferentPayload\n \"Found two messages with the same sequenceNumber but different payloads. Likely to be a \"\n + \"service issue\",\n DriverErrorType.fileOverwrittenInStorage,\n {\n clientId: this.connectionManager.clientId,\n sequenceNumber: message.sequenceNumber,\n message1,\n message2,\n driverVersion: undefined,\n },\n );\n this.close(error);\n }\n }\n } else if (message.sequenceNumber !== this.lastQueuedSequenceNumber + 1) {\n this.pending.push(message);\n this.fetchMissingDeltas(reason, message.sequenceNumber);\n } else {\n this.lastQueuedSequenceNumber = message.sequenceNumber;\n this.previouslyProcessedMessage = message;\n this._inbound.push(message);\n }\n }\n\n // When / if we report a gap in ops in the future, we want telemetry to correctly reflect source\n // of prior ops. But if we have some out of order ops (this.pending), then reporting current reason\n // becomes not accurate, as the gap existed before current batch, so we should just report \"unknown\".\n this.prevEnqueueMessagesReason = this.pending.length > 0 ? \"unknown\" : reason;\n }\n\n private processInboundMessage(message: ISequencedDocumentMessage): void {\n const startTime = Date.now();\n assert(!this.currentlyProcessingOps, 0x3af /* Already processing ops. */);\n this.currentlyProcessingOps = true;\n this.lastProcessedMessage = message;\n\n // All non-system messages are coming from some client, and should have clientId\n // System messages may have no clientId (but some do, like propose, noop, summarize)\n assert(\n message.clientId !== undefined\n || !(isClientMessage(message)),\n 0x0ed /* \"non-system message have to have clientId\" */,\n );\n\n // TODO Remove after SPO picks up the latest build.\n if (\n typeof message.contents === \"string\"\n && message.contents !== \"\"\n && message.type !== MessageType.ClientLeave\n ) {\n message.contents = JSON.parse(message.contents);\n }\n\n this.connectionManager.beforeProcessingIncomingOp(message);\n\n // Watch the minimum sequence number and be ready to update as needed\n if (this.minSequenceNumber > message.minimumSequenceNumber) {\n // pre-0.58 error message: msnMovesBackwards\n throw new DataCorruptionError(\"Found a lower minimumSequenceNumber (msn) than previously recorded\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.minSequenceNumber = message.minimumSequenceNumber;\n\n if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {\n // pre-0.58 error message: nonSequentialSequenceNumber\n throw new DataCorruptionError(\"Found a non-Sequential sequenceNumber\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.lastProcessedSequenceNumber = message.sequenceNumber;\n\n // a bunch of code assumes that this is true\n assert(this.lastProcessedSequenceNumber <= this.lastObservedSeqNumber,\n 0x267 /* \"lastObservedSeqNumber should be updated first\" */);\n\n // Back-compat for older server with no term\n if (message.term === undefined) {\n message.term = 1;\n }\n this.baseTerm = message.term;\n\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound message without a handler attached\");\n }\n this.handler.process(message);\n this.currentlyProcessingOps = false;\n const endTime = Date.now();\n\n // Should be last, after changing this.lastProcessedSequenceNumber above, as many callers\n // test this.lastProcessedSequenceNumber instead of using op.sequenceNumber itself.\n this.emit(\"op\", message, endTime - startTime);\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private fetchMissingDeltas(reasonArg: string, to?: number) {\n this.fetchMissingDeltasCore(reasonArg, false /* cacheOnly */, to).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"fetchMissingDeltasException\" }, error);\n });\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private async fetchMissingDeltasCore(\n reason: string,\n cacheOnly: boolean,\n to?: number) {\n // Exit out early if we're already fetching deltas\n if (this.fetchReason !== undefined) {\n return;\n }\n\n if (this.closed) {\n this.logger.sendTelemetryEvent({ eventName: \"fetchMissingDeltasClosedConnection\", reason });\n return;\n }\n\n if (this.handler === undefined) {\n // We do not poses yet any information\n assert(this.lastQueuedSequenceNumber === 0, 0x26b /* \"initial state\" */);\n return;\n }\n\n try {\n let from = this.lastQueuedSequenceNumber + 1;\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n if (n !== undefined) {\n // If we already processed at least one op, then we have this.previouslyProcessedMessage populated\n // and can use it to validate that we are operating on same file, i.e. it was not overwritten.\n // Knowing about this mechanism, we could ask for op we already observed to increase validation.\n // This is especially useful when coming out of offline mode or loading from\n // very old cached (by client / driver) snapshot.\n assert(n === this.lastQueuedSequenceNumber, 0x0f2 /* \"previouslyProcessedMessage\" */);\n assert(from > 1, 0x0f3 /* \"not positive\" */);\n from--;\n }\n\n const fetchReason = `${reason}_fetch`;\n this.fetchReason = fetchReason;\n\n await this.getDeltas(\n from,\n to,\n fetchReason,\n (messages) => {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.enqueueMessages(messages, fetchReason);\n },\n cacheOnly);\n } catch (error) {\n this.logger.sendErrorEvent({ eventName: \"GetDeltas_Exception\" }, error);\n this.close(normalizeError(error));\n } finally {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.fetchReason = undefined;\n this.processPendingOps(reason);\n }\n }\n\n /**\n * Sorts pending ops and attempts to apply them\n */\n private processPendingOps(reason?: string): void {\n if (this.closed) {\n return;\n }\n\n assert(this.handler !== undefined, 0x26c /* \"handler should be installed\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.pending = [];\n // Given that we do not track where these ops came from any more, it's not very\n // actionably to report gaps in this range.\n this.enqueueMessages(pendingSorted, `${reason}_pending`, true /* allowGaps */);\n\n // Re-entrancy is ignored by fetchMissingDeltas, execution will come here when it's over\n if (this.fetchReason === undefined) {\n // See issue #7312 for more details\n // We observe cases where client gets into situation where it is not aware of missing ops\n // (i.e. client being behind), and as such, does not attempt to fetch them.\n // In some cases client may not have enough signal (example - \"read\" connection that is silent -\n // there is no easy way for client to realize it's behind, see a bit of commentary / logic at the\n // end of setupNewSuccessfulConnection). In other cases it should be able to learn that info (\"write\"\n // connection, learn by receiving its own join op), but data suggest it does not happen.\n // In 50% of these cases we do know we are behind through checkpointSequenceNumber on connection object\n // and thus can leverage that to trigger recovery. But this is not going to solve all the problems\n // (the other 50%), and thus these errors below should be looked at even if code below results in\n // recovery.\n if (this.lastQueuedSequenceNumber < this.lastObservedSeqNumber) {\n this.fetchMissingDeltas(\"OpsBehind\");\n }\n }\n }\n\n private updateLatestKnownOpSeqNumber(seq: number) {\n if (this.lastObservedSeqNumber < seq) {\n this.lastObservedSeqNumber = seq;\n }\n }\n}\n"]}
@@ -88,9 +88,9 @@ class DeltaQueue extends common_utils_1.TypedEventEmitter {
88
88
  if (this.anythingToProcess() && this.processingPromise === undefined) {
89
89
  // Use a resolved promise to start the processing on a separate stack.
90
90
  this.processingPromise = Promise.resolve().then(() => {
91
- (0, common_utils_1.assert)(this.processingPromise !== undefined, "reentrancy?");
91
+ (0, common_utils_1.assert)(this.processingPromise !== undefined, 0x37f /* reentrancy? */);
92
92
  const result = this.processDeltas();
93
- (0, common_utils_1.assert)(this.processingPromise !== undefined, "reentrancy?");
93
+ (0, common_utils_1.assert)(this.processingPromise !== undefined, 0x380 /* reentrancy? */);
94
94
  // WARNING: Do not move next line to .finally() clause!
95
95
  // It runs async and creates a race condition where incoming ensureProcessing() call observes
96
96
  // from previous run while previous run is over (but finally clause was not scheduled yet)
@@ -102,7 +102,7 @@ class DeltaQueue extends common_utils_1.TypedEventEmitter {
102
102
  this.emit("error", error);
103
103
  return { count: 0, duration: 0 };
104
104
  });
105
- (0, common_utils_1.assert)(this.processingPromise !== undefined, "processDeltas() should run async");
105
+ (0, common_utils_1.assert)(this.processingPromise !== undefined, 0x381 /* processDeltas() should run async */);
106
106
  }
107
107
  }
108
108
  anythingToProcess() {
@@ -1 +1 @@
1
- {"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,+DAAsF;AACtF,4EAAuC;AAOvC,MAAa,UACT,SAAQ,gCAAuC;IA0C/C;;;OAGG;IACH,YACqB,MAA0B;QAE3C,KAAK,EAAE,CAAC;QAFS,WAAM,GAAN,MAAM,CAAoB;QA7CvC,eAAU,GAAY,KAAK,CAAC;QACnB,MAAC,GAAG,IAAI,4BAAK,EAAK,CAAC;QAEpC;;;WAGG;QACK,eAAU,GAAG,CAAC,CAAC;IAyCvB,CAAC;IA/BD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG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,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;IAC3E,CAAC;IAED;;OAEG;IACK,aAAa;QACjB,MAAM,KAAK,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,8FAA8F;QAC9F,0FAA0F;QAC1F,OAAO,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAC7B,oCAAoC;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAC5B,KAAK,EAAE,CAAC;YACR,uBAAuB;YACvB,8EAA8E;YAC9E,oEAAoE;YACpE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACzB;QAED,MAAM,QAAQ,GAAG,0BAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAC3C,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;SACtC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACJ;AAtJD,gCAsJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaQueue, IDeltaQueueEvents } from \"@fluidframework/container-definitions\";\nimport { assert, performance, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport Deque from \"double-ended-queue\";\n\nexport interface IDeltaQueueWriter<T> {\n push(task: T): void;\n clear(): void;\n}\n\nexport class DeltaQueue<T>\n extends TypedEventEmitter<IDeltaQueueEvents<T>>\n implements IDeltaQueue<T>, IDeltaQueueWriter<T> {\n private isDisposed: boolean = false;\n private readonly q = new Deque<T>();\n\n /**\n * Tracks the number of pause requests for the queue\n * The DeltaQueue is create initially paused.\n */\n private pauseCount = 1;\n\n private error: any | undefined;\n\n /**\n * When processing is ongoing, holds a deferred that will resolve once processing stops.\n * Undefined when not processing.\n */\n private processingPromise: Promise<{ count: number; duration: number; }> | undefined;\n\n public get disposed(): boolean {\n return this.isDisposed;\n }\n\n /**\n * @returns True if the queue is paused, false if not.\n */\n public get paused(): boolean {\n return this.pauseCount !== 0;\n }\n\n public get length(): number {\n return this.q.length;\n }\n\n public get idle(): boolean {\n return this.processingPromise === undefined && this.q.length === 0;\n }\n\n public async waitTillProcessingDone() {\n return this.processingPromise ?? { count: 0, duration: 0 };\n }\n\n /**\n * @param worker - A callback to process a delta.\n * @param logger - For logging telemetry.\n */\n constructor(\n private readonly worker: (delta: T) => void,\n ) {\n super();\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n this.isDisposed = true;\n }\n\n public clear(): void {\n this.q.clear();\n }\n\n public peek(): T | undefined {\n return this.q.peekFront();\n }\n\n public toArray(): T[] {\n return this.q.toArray();\n }\n\n public push(task: T) {\n try {\n this.q.push(task);\n this.emit(\"push\", task);\n this.ensureProcessing();\n } catch (error) {\n this.emit(\"error\", error);\n }\n }\n\n public async pause(): Promise<void> {\n this.pauseCount++;\n // If called from within the processing loop, we are in the middle of processing an op. Return a promise\n // that will resolve when processing has actually stopped.\n await this.waitTillProcessingDone();\n }\n\n public resume(): void {\n assert(this.pauseCount > 0, 0x0f4 /* \"Nonzero pause-count on resume()\" */);\n this.pauseCount--;\n this.ensureProcessing();\n }\n\n /**\n * There are several actions that may need to kick off delta processing, so we want to guard against\n * accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is\n * not already started.\n */\n private ensureProcessing() {\n if (this.anythingToProcess() && this.processingPromise === undefined) {\n // Use a resolved promise to start the processing on a separate stack.\n this.processingPromise = Promise.resolve().then(() => {\n assert(this.processingPromise !== undefined, \"reentrancy?\");\n const result = this.processDeltas();\n assert(this.processingPromise !== undefined, \"reentrancy?\");\n // WARNING: Do not move next line to .finally() clause!\n // It runs async and creates a race condition where incoming ensureProcessing() call observes\n // from previous run while previous run is over (but finally clause was not scheduled yet)\n this.processingPromise = undefined;\n return result;\n }).catch((error) => {\n this.error = error;\n this.processingPromise = undefined;\n this.emit(\"error\", error);\n return { count: 0, duration: 0 };\n });\n assert(this.processingPromise !== undefined, \"processDeltas() should run async\");\n }\n }\n\n private anythingToProcess() {\n return this.q.length !== 0 && !this.paused && this.error === undefined;\n }\n\n /**\n * Executes the delta processing loop until a stop condition is reached.\n */\n private processDeltas() {\n const start = performance.now();\n let count = 0;\n\n // For grouping to work we must process all local messages immediately and in the single turn.\n // So loop over them until no messages to process, we have become paused, or hit an error.\n while (this.anythingToProcess()) {\n // Get the next message in the queue\n const next = this.q.shift();\n count++;\n // Process the message.\n // We know next is defined since we did a length check just prior to shifting.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.worker(next!);\n this.emit(\"op\", next);\n }\n\n const duration = performance.now() - start;\n if (this.q.length === 0) {\n this.emit(\"idle\", count, duration);\n }\n return { count, duration };\n }\n}\n"]}
1
+ {"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,+DAAsF;AACtF,4EAAuC;AAOvC,MAAa,UACT,SAAQ,gCAAuC;IA0C/C;;;OAGG;IACH,YACqB,MAA0B;QAE3C,KAAK,EAAE,CAAC;QAFS,WAAM,GAAN,MAAM,CAAoB;QA7CvC,eAAU,GAAY,KAAK,CAAC;QACnB,MAAC,GAAG,IAAI,4BAAK,EAAK,CAAC;QAEpC;;;WAGG;QACK,eAAU,GAAG,CAAC,CAAC;IAyCvB,CAAC;IA/BD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAW,MAAM;QACb,OAAO,IAAI,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ED;;OAEG;IACK,aAAa;QACjB,MAAM,KAAK,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,8FAA8F;QAC9F,0FAA0F;QAC1F,OAAO,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAC7B,oCAAoC;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAC5B,KAAK,EAAE,CAAC;YACR,uBAAuB;YACvB,8EAA8E;YAC9E,oEAAoE;YACpE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACzB;QAED,MAAM,QAAQ,GAAG,0BAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAC3C,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;SACtC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACJ;AAtJD,gCAsJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaQueue, IDeltaQueueEvents } from \"@fluidframework/container-definitions\";\nimport { assert, performance, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport Deque from \"double-ended-queue\";\n\nexport interface IDeltaQueueWriter<T> {\n push(task: T): void;\n clear(): void;\n}\n\nexport class DeltaQueue<T>\n extends TypedEventEmitter<IDeltaQueueEvents<T>>\n implements IDeltaQueue<T>, IDeltaQueueWriter<T> {\n private isDisposed: boolean = false;\n private readonly q = new Deque<T>();\n\n /**\n * Tracks the number of pause requests for the queue\n * The DeltaQueue is create initially paused.\n */\n private pauseCount = 1;\n\n private error: any | undefined;\n\n /**\n * When processing is ongoing, holds a deferred that will resolve once processing stops.\n * Undefined when not processing.\n */\n private processingPromise: Promise<{ count: number; duration: number; }> | undefined;\n\n public get disposed(): boolean {\n return this.isDisposed;\n }\n\n /**\n * @returns True if the queue is paused, false if not.\n */\n public get paused(): boolean {\n return this.pauseCount !== 0;\n }\n\n public get length(): number {\n return this.q.length;\n }\n\n public get idle(): boolean {\n return this.processingPromise === undefined && this.q.length === 0;\n }\n\n public async waitTillProcessingDone() {\n return this.processingPromise ?? { count: 0, duration: 0 };\n }\n\n /**\n * @param worker - A callback to process a delta.\n * @param logger - For logging telemetry.\n */\n constructor(\n private readonly worker: (delta: T) => void,\n ) {\n super();\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n this.isDisposed = true;\n }\n\n public clear(): void {\n this.q.clear();\n }\n\n public peek(): T | undefined {\n return this.q.peekFront();\n }\n\n public toArray(): T[] {\n return this.q.toArray();\n }\n\n public push(task: T) {\n try {\n this.q.push(task);\n this.emit(\"push\", task);\n this.ensureProcessing();\n } catch (error) {\n this.emit(\"error\", error);\n }\n }\n\n public async pause(): Promise<void> {\n this.pauseCount++;\n // If called from within the processing loop, we are in the middle of processing an op. Return a promise\n // that will resolve when processing has actually stopped.\n await this.waitTillProcessingDone();\n }\n\n public resume(): void {\n assert(this.pauseCount > 0, 0x0f4 /* \"Nonzero pause-count on resume()\" */);\n this.pauseCount--;\n this.ensureProcessing();\n }\n\n /**\n * There are several actions that may need to kick off delta processing, so we want to guard against\n * accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is\n * not already started.\n */\n private ensureProcessing() {\n if (this.anythingToProcess() && this.processingPromise === undefined) {\n // Use a resolved promise to start the processing on a separate stack.\n this.processingPromise = Promise.resolve().then(() => {\n assert(this.processingPromise !== undefined, 0x37f /* reentrancy? */);\n const result = this.processDeltas();\n assert(this.processingPromise !== undefined, 0x380 /* reentrancy? */);\n // WARNING: Do not move next line to .finally() clause!\n // It runs async and creates a race condition where incoming ensureProcessing() call observes\n // from previous run while previous run is over (but finally clause was not scheduled yet)\n this.processingPromise = undefined;\n return result;\n }).catch((error) => {\n this.error = error;\n this.processingPromise = undefined;\n this.emit(\"error\", error);\n return { count: 0, duration: 0 };\n });\n assert(this.processingPromise !== undefined, 0x381 /* processDeltas() should run async */);\n }\n }\n\n private anythingToProcess() {\n return this.q.length !== 0 && !this.paused && this.error === undefined;\n }\n\n /**\n * Executes the delta processing loop until a stop condition is reached.\n */\n private processDeltas() {\n const start = performance.now();\n let count = 0;\n\n // For grouping to work we must process all local messages immediately and in the single turn.\n // So loop over them until no messages to process, we have become paused, or hit an error.\n while (this.anythingToProcess()) {\n // Get the next message in the queue\n const next = this.q.shift();\n count++;\n // Process the message.\n // We know next is defined since we did a length check just prior to shifting.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.worker(next!);\n this.emit(\"op\", next);\n }\n\n const duration = performance.now() - start;\n if (this.q.length === 0) {\n this.emit(\"idle\", count, duration);\n }\n return { count, duration };\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  export { ConnectionState } from "./connectionState";
6
6
  export { Container, IContainerLoadOptions, IContainerConfig, IPendingContainerState, waitContainerToCatchUp, } from "./container";
7
7
  export { ICodeDetailsLoader, IDetachedBlobStorage, IFluidModuleWithDetails, ILoaderOptions, ILoaderProps, ILoaderServices, Loader, RelativeLoader, } from "./loader";
8
+ export { IProtocolHandler, ProtocolHandlerBuilder, } from "./protocol";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,gBAAgB,EAChB,sBAAsB,GACzB,MAAM,YAAY,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yCAMqB;AALjB,sGAAA,SAAS,OAAA;AAIT,mHAAA,sBAAsB,OAAA;AAE1B,mCASkB;AAFd,gGAAA,MAAM,OAAA;AACN,wGAAA,cAAc,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState\";\nexport {\n Container,\n IContainerLoadOptions,\n IContainerConfig,\n IPendingContainerState,\n waitContainerToCatchUp,\n} from \"./container\";\nexport {\n ICodeDetailsLoader,\n IDetachedBlobStorage,\n IFluidModuleWithDetails,\n ILoaderOptions,\n ILoaderProps,\n ILoaderServices,\n Loader,\n RelativeLoader,\n} from \"./loader\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yCAMqB;AALjB,sGAAA,SAAS,OAAA;AAIT,mHAAA,sBAAsB,OAAA;AAE1B,mCASkB;AAFd,gGAAA,MAAM,OAAA;AACN,wGAAA,cAAc,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState\";\nexport {\n Container,\n IContainerLoadOptions,\n IContainerConfig,\n IPendingContainerState,\n waitContainerToCatchUp,\n} from \"./container\";\nexport {\n ICodeDetailsLoader,\n IDetachedBlobStorage,\n IFluidModuleWithDetails,\n ILoaderOptions,\n ILoaderProps,\n ILoaderServices,\n Loader,\n RelativeLoader,\n} from \"./loader\";\nexport {\n IProtocolHandler,\n ProtocolHandlerBuilder,\n} from \"./protocol\";\n"]}
package/dist/loader.d.ts CHANGED
@@ -8,6 +8,7 @@ import { IContainer, IFluidModule, IHostLoader, ILoader, ILoaderOptions as ILoad
8
8
  import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
9
9
  import { IDocumentServiceFactory, IDocumentStorageService, IUrlResolver } from "@fluidframework/driver-definitions";
10
10
  import { Container } from "./container";
11
+ import { ProtocolHandlerBuilder } from "./protocol";
11
12
  export declare class RelativeLoader implements ILoader {
12
13
  private readonly container;
13
14
  private readonly loader;
@@ -21,7 +22,7 @@ export interface ILoaderOptions extends ILoaderOptions1 {
21
22
  }
22
23
  /**
23
24
  * @deprecated IFluidModuleWithDetails interface is moved to
24
- * {@link @fluidframework/container-definition#IFluidModuleWithDetails}
25
+ * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}
25
26
  * to have all the code loading modules in one package. #8193
26
27
  * Encapsulates a module entry point with corresponding code details.
27
28
  */
@@ -93,6 +94,11 @@ export interface ILoaderProps {
93
94
  * The configuration provider which may be used to control features.
94
95
  */
95
96
  readonly configProvider?: IConfigProviderBase;
97
+ /**
98
+ * Optional property for allowing the container to use a custom
99
+ * protocol implementation for handling the quorum and/or the audience.
100
+ */
101
+ readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;
96
102
  }
97
103
  /**
98
104
  * Services and properties used by and exposed by the loader
@@ -152,6 +158,7 @@ export declare class Loader implements IHostLoader {
152
158
  private readonly containers;
153
159
  readonly services: ILoaderServices;
154
160
  private readonly mc;
161
+ private readonly protocolHandlerBuilder;
155
162
  constructor(loaderProps: ILoaderProps);
156
163
  get IFluidRouter(): IFluidRouter;
157
164
  createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EACH,WAAW,EACX,YAAY,EACZ,QAAQ,EAER,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,cAAc,IAAI,eAAe,EAEjC,gCAAgC,EAChC,iBAAiB,EACpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAGH,mBAAmB,EAMtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EAGvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAYhE,qBAAa,cAAe,YAAW,OAAO;IAEtC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,OAAO,GAAG,SAAS;IAIhD,IAAW,YAAY,IAAI,YAAY,CAAiB;IAE3C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA2B/C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CAe9D;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AEH;;GAEG;AACH,qBAAa,MAAO,YAAW,WAAW;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyC;IACpE,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAqC;gBAEhE,WAAW,EAAE,YAAY;IA8BrC,IAAW,YAAY,IAAI,YAAY,CAAiB;IAE3C,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAoB5E,sCAAsC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7E,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAW3E,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAU3D,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,mBAAmB;YAcb,WAAW;IA+DzB,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,WAAW;YAqBL,aAAa;CAkB9B"}
package/dist/loader.js CHANGED
@@ -104,10 +104,11 @@ class Loader {
104
104
  detachedBlobStorage: loaderProps.detachedBlobStorage,
105
105
  };
106
106
  this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.services.subLogger, "Loader"));
107
+ this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;
107
108
  }
108
109
  get IFluidRouter() { return this; }
109
110
  async createDetachedContainer(codeDetails) {
110
- const container = await container_1.Container.createDetached(this, codeDetails);
111
+ const container = await container_1.Container.createDetached(this, codeDetails, this.protocolHandlerBuilder);
111
112
  if (this.cachingEnabled) {
112
113
  container.once("attached", () => {
113
114
  (0, driver_utils_1.ensureFluidResolvedUrl)(container.resolvedUrl);
@@ -120,7 +121,7 @@ class Loader {
120
121
  return container;
121
122
  }
122
123
  async rehydrateDetachedContainerFromSnapshot(snapshot) {
123
- return container_1.Container.rehydrateDetachedFromSnapshot(this, snapshot);
124
+ return container_1.Container.rehydrateDetachedFromSnapshot(this, snapshot, this.protocolHandlerBuilder);
124
125
  }
125
126
  async resolve(request, pendingLocalState) {
126
127
  const eventName = pendingLocalState === undefined ? "Resolve" : "ResolveWithPendingState";
@@ -234,7 +235,7 @@ class Loader {
234
235
  resolvedUrl: resolved,
235
236
  version: (_d = (_c = request.headers) === null || _c === void 0 ? void 0 : _c[container_definitions_1.LoaderHeader.version]) !== null && _d !== void 0 ? _d : undefined,
236
237
  loadMode: (_e = request.headers) === null || _e === void 0 ? void 0 : _e[container_definitions_1.LoaderHeader.loadMode],
237
- }, pendingLocalState);
238
+ }, pendingLocalState, this.protocolHandlerBuilder);
238
239
  }
239
240
  }
240
241
  exports.Loader = Loader;