@fluidframework/container-runtime 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/api-report/container-runtime.legacy.alpha.api.md +17 -15
  3. package/container-runtime.test-files.tar +0 -0
  4. package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
  5. package/dist/channelCollection.js.map +1 -1
  6. package/dist/containerRuntime.d.ts +38 -5
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +28 -7
  9. package/dist/containerRuntime.js.map +1 -1
  10. package/dist/gc/garbageCollection.d.ts.map +1 -1
  11. package/dist/gc/garbageCollection.js.map +1 -1
  12. package/dist/gc/gcConfigs.js +1 -1
  13. package/dist/gc/gcConfigs.js.map +1 -1
  14. package/dist/gc/gcHelpers.js.map +1 -1
  15. package/dist/gc/gcReferenceGraphAlgorithm.js.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/opLifecycle/opDecompressor.js +0 -1
  20. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  21. package/dist/opLifecycle/opSplitter.js +0 -1
  22. package/dist/opLifecycle/opSplitter.js.map +1 -1
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/packageVersion.js +1 -1
  25. package/dist/packageVersion.js.map +1 -1
  26. package/dist/pendingStateManager.d.ts +4 -0
  27. package/dist/pendingStateManager.d.ts.map +1 -1
  28. package/dist/pendingStateManager.js +31 -1
  29. package/dist/pendingStateManager.js.map +1 -1
  30. package/dist/scheduleManager.js +0 -2
  31. package/dist/scheduleManager.js.map +1 -1
  32. package/dist/summary/runWhileConnectedCoordinator.d.ts +2 -1
  33. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  34. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  35. package/dist/summary/runningSummarizer.d.ts +8 -1
  36. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  37. package/dist/summary/runningSummarizer.js +70 -8
  38. package/dist/summary/runningSummarizer.js.map +1 -1
  39. package/dist/summary/summarizer.d.ts +5 -2
  40. package/dist/summary/summarizer.d.ts.map +1 -1
  41. package/dist/summary/summarizer.js +39 -6
  42. package/dist/summary/summarizer.js.map +1 -1
  43. package/dist/summary/summarizerTypes.d.ts +8 -4
  44. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  45. package/dist/summary/summarizerTypes.js.map +1 -1
  46. package/dist/summary/summaryCollection.js +0 -2
  47. package/dist/summary/summaryCollection.js.map +1 -1
  48. package/dist/summary/summaryManager.d.ts +5 -2
  49. package/dist/summary/summaryManager.d.ts.map +1 -1
  50. package/dist/summary/summaryManager.js +23 -6
  51. package/dist/summary/summaryManager.js.map +1 -1
  52. package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
  53. package/lib/channelCollection.js.map +1 -1
  54. package/lib/containerRuntime.d.ts +38 -5
  55. package/lib/containerRuntime.d.ts.map +1 -1
  56. package/lib/containerRuntime.js +28 -7
  57. package/lib/containerRuntime.js.map +1 -1
  58. package/lib/gc/garbageCollection.d.ts.map +1 -1
  59. package/lib/gc/garbageCollection.js.map +1 -1
  60. package/lib/gc/gcConfigs.js +1 -1
  61. package/lib/gc/gcConfigs.js.map +1 -1
  62. package/lib/gc/gcHelpers.js.map +1 -1
  63. package/lib/gc/gcReferenceGraphAlgorithm.js.map +1 -1
  64. package/lib/index.d.ts +1 -1
  65. package/lib/index.d.ts.map +1 -1
  66. package/lib/index.js.map +1 -1
  67. package/lib/opLifecycle/opDecompressor.js +0 -1
  68. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  69. package/lib/opLifecycle/opSplitter.js +0 -1
  70. package/lib/opLifecycle/opSplitter.js.map +1 -1
  71. package/lib/packageVersion.d.ts +1 -1
  72. package/lib/packageVersion.js +1 -1
  73. package/lib/packageVersion.js.map +1 -1
  74. package/lib/pendingStateManager.d.ts +4 -0
  75. package/lib/pendingStateManager.d.ts.map +1 -1
  76. package/lib/pendingStateManager.js +29 -0
  77. package/lib/pendingStateManager.js.map +1 -1
  78. package/lib/scheduleManager.js +0 -2
  79. package/lib/scheduleManager.js.map +1 -1
  80. package/lib/summary/runWhileConnectedCoordinator.d.ts +2 -1
  81. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  82. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  83. package/lib/summary/runningSummarizer.d.ts +8 -1
  84. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  85. package/lib/summary/runningSummarizer.js +70 -8
  86. package/lib/summary/runningSummarizer.js.map +1 -1
  87. package/lib/summary/summarizer.d.ts +5 -2
  88. package/lib/summary/summarizer.d.ts.map +1 -1
  89. package/lib/summary/summarizer.js +39 -6
  90. package/lib/summary/summarizer.js.map +1 -1
  91. package/lib/summary/summarizerTypes.d.ts +8 -4
  92. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  93. package/lib/summary/summarizerTypes.js.map +1 -1
  94. package/lib/summary/summaryCollection.js +0 -2
  95. package/lib/summary/summaryCollection.js.map +1 -1
  96. package/lib/summary/summaryManager.d.ts +5 -2
  97. package/lib/summary/summaryManager.d.ts.map +1 -1
  98. package/lib/summary/summaryManager.js +23 -6
  99. package/lib/summary/summaryManager.js.map +1 -1
  100. package/package.json +20 -20
  101. package/src/blobManager/blobManagerSnapSum.ts +1 -1
  102. package/src/channelCollection.ts +1 -1
  103. package/src/containerRuntime.ts +84 -24
  104. package/src/gc/garbageCollection.ts +2 -1
  105. package/src/gc/gcConfigs.ts +1 -1
  106. package/src/gc/gcHelpers.ts +2 -2
  107. package/src/gc/gcReferenceGraphAlgorithm.ts +1 -1
  108. package/src/index.ts +1 -0
  109. package/src/opLifecycle/opDecompressor.ts +1 -1
  110. package/src/opLifecycle/opSplitter.ts +1 -1
  111. package/src/packageVersion.ts +1 -1
  112. package/src/pendingStateManager.ts +38 -0
  113. package/src/scheduleManager.ts +2 -2
  114. package/src/summary/runWhileConnectedCoordinator.ts +2 -5
  115. package/src/summary/runningSummarizer.ts +82 -11
  116. package/src/summary/summarizer.ts +49 -10
  117. package/src/summary/summarizerTypes.ts +11 -4
  118. package/src/summary/summaryCollection.ts +2 -2
  119. package/src/summary/summaryManager.ts +30 -10
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleManager.js","sourceRoot":"","sources":["../src/scheduleManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAEN,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,gCAAgC,GAChC,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQjD;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAG3B,YACkB,YAA+B,EAC/B,OAAqB,EAC7B,WAAqC,EAC7B,MAA2B;QAH3B,iBAAY,GAAZ,YAAY,CAAmB;QAC/B,YAAO,GAAP,OAAO,CAAc;QAC7B,gBAAW,GAAX,WAAW,CAA0B;QAC7B,WAAM,GAAN,MAAM,CAAqB;QAE5C,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CACvC,IAAI,CAAC,YAAY,EACjB,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,CACvE,CAAC;QACF,KAAK,IAAI,mBAAmB,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAEM,UAAU,CAAC,OAAkC;QACnD,IAAI,CAAC,OAAO,CAAC,IAA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EAAqE;QAErE,IAAI,aAAa,EAAE,CAAC;YACnB,MAAM,CACL,IAAI,CAAC,oBAAoB,KAAK,SAAS,EACvC,KAAK,CAAC,mCAAmC,CACzC,CAAC;YACF,MAAM,CACL,CAAC,IAAI,CAAC,WAAW,EACjB,KAAK,CAAC,iEAAiE,CACvE,CAAC;YACF,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;YAClD,+FAA+F;YAC/F,4EAA4E;YAC5E,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,QAAkB,CAAC;YACvD,qBAAqB;YACrB,mDAAmD;YACnD,+FAA+F;YAC/F,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5C,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,CAAC;QACF,CAAC;aAAM,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;YACpC,MAAM,CACL,IAAI,CAAC,mBAAmB,KAAK,SAAS,EACtC,KAAK,CAAC,0CAA0C,CAChD,CAAC;YACF,wCAAwC;YACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,4CAA4C;YAC5C,MAAM,CAAC,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC5E,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { IDeltaManagerFull } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tDataCorruptionError,\n\tDataProcessingError,\n\tcreateChildLogger,\n\textractSafePropertiesFromMessage,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DeltaScheduler } from \"./deltaScheduler.js\";\nimport { IBatchMetadata } from \"./metadata.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\ntype IRuntimeMessageMetadata =\n\t| undefined\n\t| {\n\t\t\tbatch?: boolean;\n\t };\n\n/**\n * This class has the following responsibilities:\n *\n * 1. It tracks batches as we process ops and raises \"batchBegin\" and \"batchEnd\" events.\n * As part of it, it validates batch correctness (i.e. no system ops in the middle of batch)\n *\n * 2. It creates instance of ScheduleManagerCore that ensures we never start processing ops from batch\n * unless all ops of the batch are in.\n */\nexport class ScheduleManager {\n\tprivate readonly deltaScheduler: DeltaScheduler;\n\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManagerFull,\n\t\tprivate readonly emitter: EventEmitter,\n\t\treadonly getClientId: () => string | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.deltaScheduler = new DeltaScheduler(\n\t\t\tthis.deltaManager,\n\t\t\tcreateChildLogger({ logger: this.logger, namespace: \"DeltaScheduler\" }),\n\t\t);\n\t\tvoid new ScheduleManagerCore(deltaManager, getClientId, logger);\n\t}\n\n\tpublic batchBegin(message: ISequencedDocumentMessage) {\n\t\tthis.emitter.emit(\"batchBegin\", message);\n\t\tthis.deltaScheduler.batchBegin(message);\n\t}\n\n\tpublic batchEnd(error: any | undefined, message: ISequencedDocumentMessage) {\n\t\tthis.emitter.emit(\"batchEnd\", error, message);\n\t\tthis.deltaScheduler.batchEnd(message);\n\t}\n}\n\n/**\n * This class controls pausing and resuming of inbound queue to ensure that we never\n * start processing ops in a batch IF we do not have all ops in the batch.\n */\nclass ScheduleManagerCore {\n\tprivate pauseSequenceNumber: number | undefined;\n\tprivate currentBatchClientId: string | undefined;\n\tprivate localPaused = false;\n\tprivate timePaused = 0;\n\tprivate batchCount = 0;\n\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManagerFull,\n\t\tprivate readonly getClientId: () => string | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\t// Listen for delta manager sends and add batch metadata to messages\n\t\tthis.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n\t\t\tif (messages.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// First message will have the batch flag set to true if doing a batched send\n\t\t\tconst firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n\t\t\tif (!firstMessageMetadata?.batch) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the batch contains only a single op, clear the batch flag.\n\t\t\tif (messages.length === 1) {\n\t\t\t\tdelete firstMessageMetadata.batch;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set the batch flag to false on the last message to indicate the end of the send batch\n\t\t\tconst lastMessage = messages[messages.length - 1];\n\t\t\t// TODO: It's not clear if this shallow clone is required, as opposed to just setting \"batch\" to false.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\t\tlastMessage.metadata = { ...(lastMessage.metadata as any), batch: false };\n\t\t});\n\n\t\t// Listen for updates and peek at the inbound\n\t\tthis.deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n\t\t\tthis.trackPending(message);\n\t\t});\n\n\t\t// Start with baseline - empty inbound queue.\n\t\tassert(!this.localPaused, 0x293 /* \"initial state\" */);\n\n\t\tconst allPending = this.deltaManager.inbound.toArray();\n\t\tfor (const pending of allPending) {\n\t\t\tthis.trackPending(pending);\n\t\t}\n\n\t\t// We are intentionally directly listening to the \"op\" to inspect system ops as well.\n\t\t// If we do not observe system ops, we are likely to hit 0x296 assert when system ops\n\t\t// precedes start of incomplete batch.\n\t\tthis.deltaManager.on(\"op\", (message) => this.afterOpProcessing(message));\n\t}\n\n\t/**\n\t * The only public function in this class - called when we processed an op,\n\t * to make decision if op processing should be paused or not after that.\n\t */\n\tpublic afterOpProcessing(message: ISequencedDocumentMessage) {\n\t\tassert(\n\t\t\t!this.localPaused,\n\t\t\t0x294 /* \"can't have op processing paused if we are processing an op\" */,\n\t\t);\n\n\t\t// If the inbound queue is ever empty, nothing to do!\n\t\tif (this.deltaManager.inbound.length === 0) {\n\t\t\tassert(\n\t\t\t\tthis.pauseSequenceNumber === undefined,\n\t\t\t\t0x295 /* \"there should be no pending batch if we have no ops\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// The queue is\n\t\t// 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n\t\t// - here (processing ops until reaching start of incomplete batch)\n\t\t// - in trackPending(), when queue was empty and start of batch showed up.\n\t\t// 2. resumed when batch end comes in (in trackPending())\n\n\t\t// do we have incomplete batch to worry about?\n\t\tif (this.pauseSequenceNumber !== undefined) {\n\t\t\tif (message.sequenceNumber >= this.pauseSequenceNumber) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t// Former assert 0x296\n\t\t\t\t\t\"Incomplete batch\",\n\t\t\t\t\t\"ScheduleManager\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: message.type,\n\t\t\t\t\t\tcontentType: typeof message.contents,\n\t\t\t\t\t\tbatch: (message.metadata as IBatchMetadata | undefined)?.batch,\n\t\t\t\t\t\tcompression: message.compression,\n\t\t\t\t\t\tpauseSeqNum: this.pauseSequenceNumber,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!\n\t\t\tif (message.sequenceNumber + 1 === this.pauseSequenceNumber) {\n\t\t\t\tthis.pauseQueue();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pauseQueue() {\n\t\tassert(!this.localPaused, 0x297 /* \"always called from resumed state\" */);\n\t\tthis.localPaused = true;\n\t\tthis.timePaused = performance.now();\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.deltaManager.inbound.pause();\n\t}\n\n\tprivate resumeQueue(startBatch: number, messageEndBatch: ISequencedDocumentMessage) {\n\t\tconst endBatch = messageEndBatch.sequenceNumber;\n\t\tconst duration = this.localPaused ? performance.now() - this.timePaused : undefined;\n\n\t\tthis.batchCount++;\n\t\tif (this.batchCount % 1000 === 1) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"BatchStats\",\n\t\t\t\tsequenceNumber: endBatch,\n\t\t\t\tlength: endBatch - startBatch + 1,\n\t\t\t\tmsnDistance: endBatch - messageEndBatch.minimumSequenceNumber,\n\t\t\t\tduration,\n\t\t\t\tbatchCount: this.batchCount,\n\t\t\t\tinterrupted: this.localPaused,\n\t\t\t});\n\t\t}\n\n\t\t// Return early if no change in value\n\t\tif (!this.localPaused) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.localPaused = false;\n\n\t\tthis.deltaManager.inbound.resume();\n\t}\n\n\t/**\n\t * Called for each incoming op (i.e. inbound \"push\" notification)\n\t */\n\tprivate trackPending(message: ISequencedDocumentMessage) {\n\t\tassert(\n\t\t\tthis.deltaManager.inbound.length !== 0,\n\t\t\t0x298 /* \"we have something in the queue that generates this event\" */,\n\t\t);\n\n\t\tassert(\n\t\t\t(this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined),\n\t\t\t0x299 /* \"non-synchronized state\" */,\n\t\t);\n\n\t\tconst metadata = message.metadata as IRuntimeMessageMetadata;\n\t\t// batchMetadata will be true for the message that starts a batch, false for the one that ends it, and\n\t\t// undefined for all other messages.\n\t\tconst batchMetadata = metadata?.batch;\n\n\t\t// Protocol messages are never part of a runtime batch of messages\n\t\tif (!isRuntimeMessage(message)) {\n\t\t\t// Protocol messages should never show up in the middle of the batch!\n\t\t\tif (this.currentBatchClientId !== undefined) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t\"Received a system message during batch processing\", // Formerly known as assert 0x29a\n\t\t\t\t\t\"trackPending\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\t\t\tbatchClientId:\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\t\t\t\tthis.currentBatchClientId === null ? \"null\" : this.currentBatchClientId,\n\t\t\t\t\t\tpauseSequenceNumber: this.pauseSequenceNumber,\n\t\t\t\t\t\tlocalBatch: this.currentBatchClientId === this.getClientId(),\n\t\t\t\t\t\tmessageType: message.type,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tassert(batchMetadata === undefined, 0x29b /* \"system op in a batch?\" */);\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29c /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.currentBatchClientId === undefined && batchMetadata === undefined) {\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29d /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If we got here, the message is part of a batch. Either starting, in progress, or ending.\n\n\t\t// If this is not the start of the batch, error out if the message was sent by a client other than the one that\n\t\t// started the current batch (it should not be possible for ops from other clients to get interleaved with a batch).\n\t\tif (\n\t\t\tthis.currentBatchClientId !== undefined &&\n\t\t\tthis.currentBatchClientId !== message.clientId\n\t\t) {\n\t\t\tthrow new DataCorruptionError(\"OpBatchIncomplete\", {\n\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\tbatchClientId:\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\t\tthis.currentBatchClientId === null ? \"null\" : this.currentBatchClientId,\n\t\t\t\tpauseSequenceNumber: this.pauseSequenceNumber,\n\t\t\t\tlocalBatch: this.currentBatchClientId === this.getClientId(),\n\t\t\t\tlocalMessage: message.clientId === this.getClientId(),\n\t\t\t\t...extractSafePropertiesFromMessage(message),\n\t\t\t});\n\t\t}\n\n\t\t// The queue is\n\t\t// 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n\t\t// - in afterOpProcessing() - processing ops until reaching start of incomplete batch\n\t\t// - here, when queue was empty and start of batch showed up (batchMetadata === true below).\n\t\t// 2. resumed when batch end comes in (batchMetadata === false below)\n\n\t\tif (batchMetadata) {\n\t\t\tassert(\n\t\t\t\tthis.currentBatchClientId === undefined,\n\t\t\t\t0x29e /* \"there can't be active batch\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29f /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\tthis.pauseSequenceNumber = message.sequenceNumber;\n\t\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\t\tthis.currentBatchClientId = message.clientId as string;\n\t\t\t// Start of the batch\n\t\t\t// Only pause processing if queue has no other ops!\n\t\t\t// If there are any other ops in the queue, processing will be stopped when they are processed!\n\t\t\tif (this.deltaManager.inbound.length === 1) {\n\t\t\t\tthis.pauseQueue();\n\t\t\t}\n\t\t} else if (batchMetadata === false) {\n\t\t\tassert(\n\t\t\t\tthis.pauseSequenceNumber !== undefined,\n\t\t\t\t0x2a0 /* \"batch presence was validated above\" */,\n\t\t\t);\n\t\t\t// Batch is complete, we can process it!\n\t\t\tthis.resumeQueue(this.pauseSequenceNumber, message);\n\t\t\tthis.pauseSequenceNumber = undefined;\n\t\t\tthis.currentBatchClientId = undefined;\n\t\t} else {\n\t\t\t// Continuation of current batch. Do nothing\n\t\t\tassert(this.currentBatchClientId !== undefined, 0x2a1 /* \"logic error\" */);\n\t\t}\n\t}\n}\n"]}
1
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AAc,CAAC;YAClD,+FAA+F;YAE/F,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,QAAkB,CAAC;YACvD,qBAAqB;YACrB,mDAAmD;YACnD,+FAA+F;YAC/F,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5C,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,CAAC;QACF,CAAC;aAAM,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;YACpC,MAAM,CACL,IAAI,CAAC,mBAAmB,KAAK,SAAS,EACtC,KAAK,CAAC,0CAA0C,CAChD,CAAC;YACF,wCAAwC;YACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,4CAA4C;YAC5C,MAAM,CAAC,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC5E,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { IDeltaManagerFull } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tDataCorruptionError,\n\tDataProcessingError,\n\tcreateChildLogger,\n\textractSafePropertiesFromMessage,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DeltaScheduler } from \"./deltaScheduler.js\";\nimport { IBatchMetadata } from \"./metadata.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\ntype IRuntimeMessageMetadata =\n\t| undefined\n\t| {\n\t\t\tbatch?: boolean;\n\t };\n\n/**\n * This class has the following responsibilities:\n *\n * 1. It tracks batches as we process ops and raises \"batchBegin\" and \"batchEnd\" events.\n * As part of it, it validates batch correctness (i.e. no system ops in the middle of batch)\n *\n * 2. It creates instance of ScheduleManagerCore that ensures we never start processing ops from batch\n * unless all ops of the batch are in.\n */\nexport class ScheduleManager {\n\tprivate readonly deltaScheduler: DeltaScheduler;\n\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManagerFull,\n\t\tprivate readonly emitter: EventEmitter,\n\t\treadonly getClientId: () => string | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.deltaScheduler = new DeltaScheduler(\n\t\t\tthis.deltaManager,\n\t\t\tcreateChildLogger({ logger: this.logger, namespace: \"DeltaScheduler\" }),\n\t\t);\n\t\tvoid new ScheduleManagerCore(deltaManager, getClientId, logger);\n\t}\n\n\tpublic batchBegin(message: ISequencedDocumentMessage) {\n\t\tthis.emitter.emit(\"batchBegin\", message);\n\t\tthis.deltaScheduler.batchBegin(message);\n\t}\n\n\tpublic batchEnd(error: any | undefined, message: ISequencedDocumentMessage) {\n\t\tthis.emitter.emit(\"batchEnd\", error, message);\n\t\tthis.deltaScheduler.batchEnd(message);\n\t}\n}\n\n/**\n * This class controls pausing and resuming of inbound queue to ensure that we never\n * start processing ops in a batch IF we do not have all ops in the batch.\n */\nclass ScheduleManagerCore {\n\tprivate pauseSequenceNumber: number | undefined;\n\tprivate currentBatchClientId: string | undefined;\n\tprivate localPaused = false;\n\tprivate timePaused = 0;\n\tprivate batchCount = 0;\n\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManagerFull,\n\t\tprivate readonly getClientId: () => string | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\t// Listen for delta manager sends and add batch metadata to messages\n\t\tthis.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n\t\t\tif (messages.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// First message will have the batch flag set to true if doing a batched send\n\t\t\tconst firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n\t\t\tif (!firstMessageMetadata?.batch) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the batch contains only a single op, clear the batch flag.\n\t\t\tif (messages.length === 1) {\n\t\t\t\tdelete firstMessageMetadata.batch;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set the batch flag to false on the last message to indicate the end of the send batch\n\t\t\tconst lastMessage = messages[messages.length - 1];\n\t\t\t// TODO: It's not clear if this shallow clone is required, as opposed to just setting \"batch\" to false.\n\n\t\t\tlastMessage.metadata = { ...(lastMessage.metadata as any), batch: false };\n\t\t});\n\n\t\t// Listen for updates and peek at the inbound\n\t\tthis.deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n\t\t\tthis.trackPending(message);\n\t\t});\n\n\t\t// Start with baseline - empty inbound queue.\n\t\tassert(!this.localPaused, 0x293 /* \"initial state\" */);\n\n\t\tconst allPending = this.deltaManager.inbound.toArray();\n\t\tfor (const pending of allPending) {\n\t\t\tthis.trackPending(pending);\n\t\t}\n\n\t\t// We are intentionally directly listening to the \"op\" to inspect system ops as well.\n\t\t// If we do not observe system ops, we are likely to hit 0x296 assert when system ops\n\t\t// precedes start of incomplete batch.\n\t\tthis.deltaManager.on(\"op\", (message) => this.afterOpProcessing(message));\n\t}\n\n\t/**\n\t * The only public function in this class - called when we processed an op,\n\t * to make decision if op processing should be paused or not after that.\n\t */\n\tpublic afterOpProcessing(message: ISequencedDocumentMessage) {\n\t\tassert(\n\t\t\t!this.localPaused,\n\t\t\t0x294 /* \"can't have op processing paused if we are processing an op\" */,\n\t\t);\n\n\t\t// If the inbound queue is ever empty, nothing to do!\n\t\tif (this.deltaManager.inbound.length === 0) {\n\t\t\tassert(\n\t\t\t\tthis.pauseSequenceNumber === undefined,\n\t\t\t\t0x295 /* \"there should be no pending batch if we have no ops\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// The queue is\n\t\t// 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n\t\t// - here (processing ops until reaching start of incomplete batch)\n\t\t// - in trackPending(), when queue was empty and start of batch showed up.\n\t\t// 2. resumed when batch end comes in (in trackPending())\n\n\t\t// do we have incomplete batch to worry about?\n\t\tif (this.pauseSequenceNumber !== undefined) {\n\t\t\tif (message.sequenceNumber >= this.pauseSequenceNumber) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t// Former assert 0x296\n\t\t\t\t\t\"Incomplete batch\",\n\t\t\t\t\t\"ScheduleManager\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: message.type,\n\t\t\t\t\t\tcontentType: typeof message.contents,\n\t\t\t\t\t\tbatch: (message.metadata as IBatchMetadata | undefined)?.batch,\n\t\t\t\t\t\tcompression: message.compression,\n\t\t\t\t\t\tpauseSeqNum: this.pauseSequenceNumber,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!\n\t\t\tif (message.sequenceNumber + 1 === this.pauseSequenceNumber) {\n\t\t\t\tthis.pauseQueue();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pauseQueue() {\n\t\tassert(!this.localPaused, 0x297 /* \"always called from resumed state\" */);\n\t\tthis.localPaused = true;\n\t\tthis.timePaused = performance.now();\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.deltaManager.inbound.pause();\n\t}\n\n\tprivate resumeQueue(startBatch: number, messageEndBatch: ISequencedDocumentMessage) {\n\t\tconst endBatch = messageEndBatch.sequenceNumber;\n\t\tconst duration = this.localPaused ? performance.now() - this.timePaused : undefined;\n\n\t\tthis.batchCount++;\n\t\tif (this.batchCount % 1000 === 1) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"BatchStats\",\n\t\t\t\tsequenceNumber: endBatch,\n\t\t\t\tlength: endBatch - startBatch + 1,\n\t\t\t\tmsnDistance: endBatch - messageEndBatch.minimumSequenceNumber,\n\t\t\t\tduration,\n\t\t\t\tbatchCount: this.batchCount,\n\t\t\t\tinterrupted: this.localPaused,\n\t\t\t});\n\t\t}\n\n\t\t// Return early if no change in value\n\t\tif (!this.localPaused) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.localPaused = false;\n\n\t\tthis.deltaManager.inbound.resume();\n\t}\n\n\t/**\n\t * Called for each incoming op (i.e. inbound \"push\" notification)\n\t */\n\tprivate trackPending(message: ISequencedDocumentMessage) {\n\t\tassert(\n\t\t\tthis.deltaManager.inbound.length !== 0,\n\t\t\t0x298 /* \"we have something in the queue that generates this event\" */,\n\t\t);\n\n\t\tassert(\n\t\t\t(this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined),\n\t\t\t0x299 /* \"non-synchronized state\" */,\n\t\t);\n\n\t\tconst metadata = message.metadata as IRuntimeMessageMetadata;\n\t\t// batchMetadata will be true for the message that starts a batch, false for the one that ends it, and\n\t\t// undefined for all other messages.\n\t\tconst batchMetadata = metadata?.batch;\n\n\t\t// Protocol messages are never part of a runtime batch of messages\n\t\tif (!isRuntimeMessage(message)) {\n\t\t\t// Protocol messages should never show up in the middle of the batch!\n\t\t\tif (this.currentBatchClientId !== undefined) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t\"Received a system message during batch processing\", // Formerly known as assert 0x29a\n\t\t\t\t\t\"trackPending\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\t\t\tbatchClientId:\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\t\t\t\tthis.currentBatchClientId === null ? \"null\" : this.currentBatchClientId,\n\t\t\t\t\t\tpauseSequenceNumber: this.pauseSequenceNumber,\n\t\t\t\t\t\tlocalBatch: this.currentBatchClientId === this.getClientId(),\n\t\t\t\t\t\tmessageType: message.type,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tassert(batchMetadata === undefined, 0x29b /* \"system op in a batch?\" */);\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29c /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.currentBatchClientId === undefined && batchMetadata === undefined) {\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29d /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If we got here, the message is part of a batch. Either starting, in progress, or ending.\n\n\t\t// If this is not the start of the batch, error out if the message was sent by a client other than the one that\n\t\t// started the current batch (it should not be possible for ops from other clients to get interleaved with a batch).\n\t\tif (\n\t\t\tthis.currentBatchClientId !== undefined &&\n\t\t\tthis.currentBatchClientId !== message.clientId\n\t\t) {\n\t\t\tthrow new DataCorruptionError(\"OpBatchIncomplete\", {\n\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\tbatchClientId:\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\t\tthis.currentBatchClientId === null ? \"null\" : this.currentBatchClientId,\n\t\t\t\tpauseSequenceNumber: this.pauseSequenceNumber,\n\t\t\t\tlocalBatch: this.currentBatchClientId === this.getClientId(),\n\t\t\t\tlocalMessage: message.clientId === this.getClientId(),\n\t\t\t\t...extractSafePropertiesFromMessage(message),\n\t\t\t});\n\t\t}\n\n\t\t// The queue is\n\t\t// 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n\t\t// - in afterOpProcessing() - processing ops until reaching start of incomplete batch\n\t\t// - here, when queue was empty and start of batch showed up (batchMetadata === true below).\n\t\t// 2. resumed when batch end comes in (batchMetadata === false below)\n\n\t\tif (batchMetadata) {\n\t\t\tassert(\n\t\t\t\tthis.currentBatchClientId === undefined,\n\t\t\t\t0x29e /* \"there can't be active batch\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29f /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\tthis.pauseSequenceNumber = message.sequenceNumber;\n\t\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\n\t\t\tthis.currentBatchClientId = message.clientId as string;\n\t\t\t// Start of the batch\n\t\t\t// Only pause processing if queue has no other ops!\n\t\t\t// If there are any other ops in the queue, processing will be stopped when they are processed!\n\t\t\tif (this.deltaManager.inbound.length === 1) {\n\t\t\t\tthis.pauseQueue();\n\t\t\t}\n\t\t} else if (batchMetadata === false) {\n\t\t\tassert(\n\t\t\t\tthis.pauseSequenceNumber !== undefined,\n\t\t\t\t0x2a0 /* \"batch presence was validated above\" */,\n\t\t\t);\n\t\t\t// Batch is complete, we can process it!\n\t\t\tthis.resumeQueue(this.pauseSequenceNumber, message);\n\t\t\tthis.pauseSequenceNumber = undefined;\n\t\t\tthis.currentBatchClientId = undefined;\n\t\t} else {\n\t\t\t// Continuation of current batch. Do nothing\n\t\t\tassert(this.currentBatchClientId !== undefined, 0x2a1 /* \"logic error\" */);\n\t\t}\n\t}\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IConnectableRuntime, ISummaryCancellationToken, SummarizerStopReason } from "./summarizerTypes.js";
5
+ import type { SummarizerStopReason } from "@fluidframework/container-runtime-definitions/internal";
6
+ import { IConnectableRuntime, ISummaryCancellationToken } from "./summarizerTypes.js";
6
7
  /**
7
8
  * Similar to AbortController, but using promise instead of events
8
9
  * @legacy
@@ -1 +1 @@
1
- {"version":3,"file":"runWhileConnectedCoordinator.d.ts","sourceRoot":"","sources":["../../src/summary/runWhileConnectedCoordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IAClF,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACzC;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,yBAGxC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,4BAA6B,YAAW,gCAAgC;IAsCnF,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAtCxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwC;IAErE,IAAW,SAAS,YAkBnB;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAExD;WAEmB,MAAM,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO;IAM9E,SAAS,aACS,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,MAAM,OAAO;IAGvC;;;;;;;;;;;;OAYG;cACa,SAAS;IAiBzB;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAM/C"}
1
+ {"version":3,"file":"runWhileConnectedCoordinator.d.ts","sourceRoot":"","sources":["../../src/summary/runWhileConnectedCoordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAGnG,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtF;;;;GAIG;AACH,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IAClF,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,C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;QACzD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACpF,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAA4B;QACvC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tIConnectableRuntime,\n\tISummaryCancellationToken,\n\tSummarizerStopReason,\n} from \"./summarizerTypes.js\";\n\n/**\n * Similar to AbortController, but using promise instead of events\n * @legacy\n * @alpha\n */\nexport interface ICancellableSummarizerController extends ISummaryCancellationToken {\n\tstop(reason: SummarizerStopReason): void;\n}\n\n/**\n * Can be useful in testing as well as in places where caller does not use cancellation.\n * This object implements ISummaryCancellationToken interface but cancellation is never leveraged.\n * @internal\n */\nexport const neverCancelledSummaryToken: ISummaryCancellationToken = {\n\tcancelled: false,\n\twaitCancelled: new Promise(() => {}),\n};\n\n/**\n * Helper class to coordinate something that needs to run only while connected.\n * This provides promises that resolve as it starts or stops. Stopping happens\n * when disconnected or if stop() is called.\n */\nexport class RunWhileConnectedCoordinator implements ICancellableSummarizerController {\n\tprivate _cancelled = false;\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tpublic get cancelled() {\n\t\tif (!this._cancelled) {\n\t\t\tassert(this.active(), 0x25d /* \"We should never connect as 'read'\" */);\n\n\t\t\t// This check can't be enabled in current design due to lastSummary flow, where\n\t\t\t// summarizer for closed container stays around and can produce one more summary.\n\t\t\t// Currently we solve the problem of overlapping summarizer by doing wait in\n\t\t\t// SummaryManager.createSummarizer()\n\t\t\t// Better solution would involve these steps:\n\t\t\t// 1. Summarizer selection logic should chose summarizing client (with clientType === \"summarizer\")\n\t\t\t// if such client exists.\n\t\t\t// 2. Summarizer should be updated about such changes (to update onBehalfOfClientId)\n\t\t\t//\n\t\t\t// assert(this.runtime.summarizerClientId === this.onBehalfOfClientId ||\n\t\t\t// this.runtime.summarizerClientId === this.runtime.clientId, \"onBehalfOfClientId\");\n\t\t}\n\n\t\treturn this._cancelled;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once stopped either externally or by disconnect.\n\t */\n\tpublic get waitCancelled(): Promise<SummarizerStopReason> {\n\t\treturn this.stopDeferred.promise;\n\t}\n\n\tpublic static async create(runtime: IConnectableRuntime, active: () => boolean) {\n\t\tconst obj = new RunWhileConnectedCoordinator(runtime, active);\n\t\tawait obj.waitStart();\n\t\treturn obj;\n\t}\n\n\tprotected constructor(\n\t\tprivate readonly runtime: IConnectableRuntime,\n\t\tprivate readonly active: () => boolean,\n\t) {}\n\n\t/**\n\t * Starts and waits for a promise which resolves when connected.\n\t * The promise will also resolve if stopped either externally or by disconnect.\n\t *\n\t * We only listen on disconnected event for clientType === \"summarizer\" container!\n\t * And only do it here - no other place should check it! That way we have only one place\n\t * that controls policy and it's easy to change policy in the future if we want to!\n\t * We do not listen for \"main\" (aka interactive) container disconnect here, as it's\n\t * responsibility of SummaryManager to decide if that's material or not. There are cases\n\t * like \"lastSummary\", or main client experiencing nacks / disconnects due to hitting limit\n\t * of non-summarized ops, where can make determination to continue with summary even if main\n\t * client is disconnected.\n\t */\n\tprotected async waitStart() {\n\t\tif (this.runtime.disposed) {\n\t\t\tthis.stop(\"summarizerClientDisconnected\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.runtime.once(\"dispose\", () => this.stop(\"summarizerClientDisconnected\"));\n\n\t\tif (!this.runtime.connected) {\n\t\t\tconst waitConnected = new Promise<void>((resolve) =>\n\t\t\t\tthis.runtime.once(\"connected\", resolve),\n\t\t\t);\n\t\t\tawait Promise.race([waitConnected, this.waitCancelled]);\n\t\t}\n\t\tthis.runtime.once(\"disconnected\", () => this.stop(\"summarizerClientDisconnected\"));\n\t}\n\n\t/**\n\t * Stops running.\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tif (!this._cancelled) {\n\t\t\tthis._cancelled = true;\n\t\t\tthis.stopDeferred.resolve(reason);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"runWhileConnectedCoordinator.js","sourceRoot":"","sources":["../../src/summary/runWhileConnectedCoordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAavE;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA8B;IACpE,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;IAIxC,IAAW,SAAS;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAEvE,+EAA+E;YAC/E,iFAAiF;YACjF,4EAA4E;YAC5E,oCAAoC;YACpC,6CAA6C;YAC7C,mGAAmG;YACnG,yBAAyB;YACzB,oFAAoF;YACpF,EAAE;YACF,wEAAwE;YACxE,uFAAuF;QACxF,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IAClC,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAA4B,EAAE,MAAqB;QAC7E,MAAM,GAAG,GAAG,IAAI,4BAA4B,CAAC,OAAO,EAAE,MAAM,CA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sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SummarizerStopReason } from \"@fluidframework/container-runtime-definitions/internal\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\n\nimport { IConnectableRuntime, ISummaryCancellationToken } from \"./summarizerTypes.js\";\n\n/**\n * Similar to AbortController, but using promise instead of events\n * @legacy\n * @alpha\n */\nexport interface ICancellableSummarizerController extends ISummaryCancellationToken {\n\tstop(reason: SummarizerStopReason): void;\n}\n\n/**\n * Can be useful in testing as well as in places where caller does not use cancellation.\n * This object implements ISummaryCancellationToken interface but cancellation is never leveraged.\n * @internal\n */\nexport const neverCancelledSummaryToken: ISummaryCancellationToken = {\n\tcancelled: false,\n\twaitCancelled: new Promise(() => {}),\n};\n\n/**\n * Helper class to coordinate something that needs to run only while connected.\n * This provides promises that resolve as it starts or stops. Stopping happens\n * when disconnected or if stop() is called.\n */\nexport class RunWhileConnectedCoordinator implements ICancellableSummarizerController {\n\tprivate _cancelled = false;\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tpublic get cancelled() {\n\t\tif (!this._cancelled) {\n\t\t\tassert(this.active(), 0x25d /* \"We should never connect as 'read'\" */);\n\n\t\t\t// This check can't be enabled in current design due to lastSummary flow, where\n\t\t\t// summarizer for closed container stays around and can produce one more summary.\n\t\t\t// Currently we solve the problem of overlapping summarizer by doing wait in\n\t\t\t// SummaryManager.createSummarizer()\n\t\t\t// Better solution would involve these steps:\n\t\t\t// 1. Summarizer selection logic should chose summarizing client (with clientType === \"summarizer\")\n\t\t\t// if such client exists.\n\t\t\t// 2. Summarizer should be updated about such changes (to update onBehalfOfClientId)\n\t\t\t//\n\t\t\t// assert(this.runtime.summarizerClientId === this.onBehalfOfClientId ||\n\t\t\t// this.runtime.summarizerClientId === this.runtime.clientId, \"onBehalfOfClientId\");\n\t\t}\n\n\t\treturn this._cancelled;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once stopped either externally or by disconnect.\n\t */\n\tpublic get waitCancelled(): Promise<SummarizerStopReason> {\n\t\treturn this.stopDeferred.promise;\n\t}\n\n\tpublic static async create(runtime: IConnectableRuntime, active: () => boolean) {\n\t\tconst obj = new RunWhileConnectedCoordinator(runtime, active);\n\t\tawait obj.waitStart();\n\t\treturn obj;\n\t}\n\n\tprotected constructor(\n\t\tprivate readonly runtime: IConnectableRuntime,\n\t\tprivate readonly active: () => boolean,\n\t) {}\n\n\t/**\n\t * Starts and waits for a promise which resolves when connected.\n\t * The promise will also resolve if stopped either externally or by disconnect.\n\t *\n\t * We only listen on disconnected event for clientType === \"summarizer\" container!\n\t * And only do it here - no other place should check it! That way we have only one place\n\t * that controls policy and it's easy to change policy in the future if we want to!\n\t * We do not listen for \"main\" (aka interactive) container disconnect here, as it's\n\t * responsibility of SummaryManager to decide if that's material or not. There are cases\n\t * like \"lastSummary\", or main client experiencing nacks / disconnects due to hitting limit\n\t * of non-summarized ops, where can make determination to continue with summary even if main\n\t * client is disconnected.\n\t */\n\tprotected async waitStart() {\n\t\tif (this.runtime.disposed) {\n\t\t\tthis.stop(\"summarizerClientDisconnected\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.runtime.once(\"dispose\", () => this.stop(\"summarizerClientDisconnected\"));\n\n\t\tif (!this.runtime.connected) {\n\t\t\tconst waitConnected = new Promise<void>((resolve) =>\n\t\t\t\tthis.runtime.once(\"connected\", resolve),\n\t\t\t);\n\t\t\tawait Promise.race([waitConnected, this.waitCancelled]);\n\t\t}\n\t\tthis.runtime.once(\"disconnected\", () => this.stop(\"summarizerClientDisconnected\"));\n\t}\n\n\t/**\n\t * Stops running.\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tif (!this._cancelled) {\n\t\t\tthis._cancelled = true;\n\t\t\tthis.stopDeferred.resolve(reason);\n\t\t}\n\t}\n}\n"]}
@@ -3,10 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
+ import type { ISummarizerEvents, SummarizerStopReason } from "@fluidframework/container-runtime-definitions/internal";
6
7
  import { IDisposable, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
7
8
  import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
8
9
  import { ISummaryConfiguration } from "../containerRuntime.js";
9
- import { EnqueueSummarizeResult, IEnqueueSummarizeOptions, IOnDemandSummarizeOptions, IRefreshSummaryAckOptions, ISubmitSummaryOptions, ISummarizeHeuristicData, ISummarizeResults, ISummarizerEvents, ISummarizerRuntime, ISummaryCancellationToken, SubmitSummaryResult, SummarizerStopReason } from "./summarizerTypes.js";
10
+ import { EnqueueSummarizeResult, IEnqueueSummarizeOptions, IOnDemandSummarizeOptions, IRefreshSummaryAckOptions, ISubmitSummaryOptions, ISummarizeHeuristicData, ISummarizeResults, ISummarizerRuntime, ISummaryCancellationToken, SubmitSummaryResult } from "./summarizerTypes.js";
10
11
  import { IClientSummaryWatcher, SummaryCollection } from "./summaryCollection.js";
11
12
  import { SummarizeResultBuilder } from "./summaryGenerator.js";
12
13
  /**
@@ -53,6 +54,11 @@ export declare class RunningSummarizer extends TypedEventEmitter<ISummarizerEven
53
54
  private readonly runtimeListener;
54
55
  /** The maximum number of summary attempts to do when submit summary fails. */
55
56
  private readonly maxAttemptsForSubmitFailures;
57
+ /**
58
+ * These are necessary to store outside of methods because of the logic around runnning a lastSummary.
59
+ * We want the lastSummary to also be captured as "all attempts failed".
60
+ */
61
+ private lastSummarizeFailureEventProps;
56
62
  private constructor();
57
63
  private handleSummaryAck;
58
64
  private readonly refreshLatestSummaryAckAndHandleError;
@@ -104,6 +110,7 @@ export declare class RunningSummarizer extends TypedEventEmitter<ISummarizerEven
104
110
  * @param options - summary options
105
111
  * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed
106
112
  * @param resultsBuilder - optional, result builder to use.
113
+ * @param isLastSummary - optional, is the call to this method for a last summary when shutting down the summarizer?
107
114
  * @returns ISummarizeResult - result of running a summary.
108
115
  */
109
116
  private trySummarizeOnce;
@@ -1 +1 @@
1
- {"version":3,"file":"runningSummarizer.d.ts","sourceRoot":"","sources":["../../src/summary/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,EAGN,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AASrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EAErB,uBAAuB,EAGvB,iBAAiB,EAGjB,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EAEpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGN,sBAAsB,EAGtB,MAAM,uBAAuB,CAAC;AAI/B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC;;;GAGG;AACH,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,iBACZ,SAAQ,iBAAiB,CAAC,iBAAiB,CAC3C,YAAW,WAAW;IAiHrB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAGtC,OAAO,CAAC,QAAQ,CAAC,+BAA+B;IAGhD,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,sB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YACW,uBAAuB;IAmKrC;;;OAGG;YACW,4BAA4B;IAqB1C,8DAA8D;IACvD,iBAAiB,CACvB,OAAO,EAAE,yBAAyB,EAClC,cAAc,GAAE,sBAAqD,GACnE,iBAAiB;IAgCpB,6DAA6D;IACtD,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,sBAAsB;IAmClF,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,sBAAsB;CAS9B"}
@@ -91,6 +91,11 @@ export class RunningSummarizer extends TypedEventEmitter {
91
91
  this.summarizeCount = 0;
92
92
  this.totalSuccessfulAttempts = 0;
93
93
  this.initialized = false;
94
+ /**
95
+ * These are necessary to store outside of methods because of the logic around runnning a lastSummary.
96
+ * We want the lastSummary to also be captured as "all attempts failed".
97
+ */
98
+ this.lastSummarizeFailureEventProps = undefined;
94
99
  this.refreshLatestSummaryAckAndHandleError = async (options) => {
95
100
  return this.refreshLatestSummaryAckCallback(options).catch(async (error) => {
96
101
  // If the error is 404, so maybe the fetched version no longer exists on server. We just
@@ -302,7 +307,7 @@ export class RunningSummarizer extends TypedEventEmitter {
302
307
  if (this.summarizingLock === undefined) {
303
308
  this.trySummarizeOnce(
304
309
  // summarizeProps
305
- { summarizeReason: "lastSummary" }, {});
310
+ { summarizeReason: "lastSummary" }, {}, undefined, true /* isLastSummary */);
306
311
  }
307
312
  }
308
313
  // Note that trySummarizeOnce() call above returns right away, without waiting.
@@ -311,6 +316,14 @@ export class RunningSummarizer extends TypedEventEmitter {
311
316
  // submit summary. We should reconsider this flow and make summarizer move to exit faster.
312
317
  // This resolves when the current pending summary gets an ack or fails.
313
318
  await this.summarizingLock;
319
+ if (this.lastSummarizeFailureEventProps !== undefined) {
320
+ this.emit("summarizeAllAttemptsFailed", {
321
+ ...this.lastSummarizeFailureEventProps,
322
+ numUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,
323
+ numUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,
324
+ });
325
+ }
326
+ this.lastSummarizeFailureEventProps = undefined;
314
327
  }
315
328
  async waitStart() {
316
329
  // Wait no longer than ack timeout for all pending
@@ -367,9 +380,10 @@ export class RunningSummarizer extends TypedEventEmitter {
367
380
  * @param options - summary options
368
381
  * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed
369
382
  * @param resultsBuilder - optional, result builder to use.
383
+ * @param isLastSummary - optional, is the call to this method for a last summary when shutting down the summarizer?
370
384
  * @returns ISummarizeResult - result of running a summary.
371
385
  */
372
- trySummarizeOnce(summarizeProps, options, resultsBuilder = new SummarizeResultBuilder()) {
386
+ trySummarizeOnce(summarizeProps, options, resultsBuilder = new SummarizeResultBuilder(), isLastSummary = false) {
373
387
  this.lockedSummaryAction(() => {
374
388
  this.beforeSummaryAction();
375
389
  }, async () => {
@@ -386,12 +400,41 @@ export class RunningSummarizer extends TypedEventEmitter {
386
400
  const summarizeResult = this.generator.summarize(summaryOptions, resultsBuilder);
387
401
  // ensure we wait till the end of the process
388
402
  const result = await summarizeResult.receivedSummaryAckOrNack;
389
- if (!result.success) {
403
+ if (result.success) {
404
+ this.emit("summarize", {
405
+ result: "success",
406
+ currentAttempt: 1,
407
+ maxAttempts: 1,
408
+ numUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,
409
+ numUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,
410
+ isLastSummary,
411
+ });
412
+ this.lastSummarizeFailureEventProps = undefined;
413
+ }
414
+ else {
415
+ this.emit("summarize", {
416
+ result: "failure",
417
+ currentAttempt: 1,
418
+ maxAttempts: 1,
419
+ error: result.error,
420
+ failureMessage: result.message,
421
+ numUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,
422
+ numUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,
423
+ isLastSummary,
424
+ });
390
425
  this.mc.logger.sendErrorEvent({
391
426
  eventName: "SummarizeFailed",
392
427
  maxAttempts: 1,
393
428
  summaryAttempts: 1,
394
429
  }, result.error);
430
+ if (isLastSummary) {
431
+ this.lastSummarizeFailureEventProps = {
432
+ currentAttempt: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,
433
+ maxAttempts: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,
434
+ error: result.error,
435
+ failureMessage: result.message,
436
+ };
437
+ }
395
438
  }
396
439
  }, () => {
397
440
  this.afterSummaryAction();
@@ -467,6 +510,7 @@ export class RunningSummarizer extends TypedEventEmitter {
467
510
  let status = "success";
468
511
  let results;
469
512
  let error;
513
+ let failureMessage;
470
514
  do {
471
515
  currentAttempt++;
472
516
  if (this.cancellationToken.cancelled) {
@@ -493,12 +537,16 @@ export class RunningSummarizer extends TypedEventEmitter {
493
537
  // Emit "summarize" event for this failed attempt.
494
538
  status = "failure";
495
539
  error = ackNackResult.error;
540
+ failureMessage = ackNackResult.message;
496
541
  retryAfterSeconds = error.retryAfterSeconds;
497
542
  const eventProps = {
498
543
  result: status,
499
544
  currentAttempt,
500
545
  maxAttempts,
501
546
  error,
547
+ failureMessage,
548
+ numUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,
549
+ numUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,
502
550
  };
503
551
  this.emit("summarize", eventProps);
504
552
  // Break if the failure doesn't have "retryAfterSeconds" or we are one less from max number of attempts.
@@ -520,7 +568,13 @@ export class RunningSummarizer extends TypedEventEmitter {
520
568
  } while (!done);
521
569
  // If the attempt was successful, emit "summarize" event and return. A failed attempt may be retried below.
522
570
  if (status !== "failure") {
523
- this.emit("summarize", { result: status, currentAttempt, maxAttempts });
571
+ this.emit("summarize", {
572
+ result: status,
573
+ currentAttempt,
574
+ maxAttempts,
575
+ numUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,
576
+ numUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,
577
+ });
524
578
  return results;
525
579
  }
526
580
  // If summarization wasn't successful above and the failure contains "retryAfterSeconds", perform one last
@@ -530,14 +584,16 @@ export class RunningSummarizer extends TypedEventEmitter {
530
584
  // Ack / nack is the final step, so if it succeeds we're done.
531
585
  const ackNackResult = await summarizeResult.receivedSummaryAckOrNack;
532
586
  status = ackNackResult.success ? "success" : "failure";
533
- if (!ackNackResult.success) {
534
- error = ackNackResult.error;
535
- }
587
+ error = ackNackResult.success ? undefined : ackNackResult.error;
588
+ failureMessage = ackNackResult.success ? undefined : ackNackResult.message;
536
589
  const eventProps = {
537
590
  result: status,
538
591
  currentAttempt,
539
592
  maxAttempts,
540
- error: ackNackResult.success ? undefined : ackNackResult.error,
593
+ error,
594
+ failureMessage,
595
+ numUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,
596
+ numUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,
541
597
  };
542
598
  this.emit("summarize", eventProps);
543
599
  results = summarizeResult;
@@ -549,6 +605,12 @@ export class RunningSummarizer extends TypedEventEmitter {
549
605
  maxAttempts,
550
606
  summaryAttempts: currentAttempt,
551
607
  }, error);
608
+ this.lastSummarizeFailureEventProps = {
609
+ currentAttempt,
610
+ maxAttempts,
611
+ error,
612
+ failureMessage,
613
+ };
552
614
  this.stopSummarizerCallback("failToSummarize");
553
615
  }
554
616
  return results;