@fluidframework/container-runtime 2.20.0 → 2.22.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 (337) hide show
  1. package/.eslintrc.cjs +36 -6
  2. package/.mocharc.cjs +3 -0
  3. package/CHANGELOG.md +42 -0
  4. package/README.md +1 -0
  5. package/api-report/container-runtime.legacy.alpha.api.md +31 -31
  6. package/dist/batchTracker.d.ts +1 -2
  7. package/dist/batchTracker.d.ts.map +1 -1
  8. package/dist/batchTracker.js +1 -1
  9. package/dist/batchTracker.js.map +1 -1
  10. package/dist/blobManager/blobManager.d.ts +0 -3
  11. package/dist/blobManager/blobManager.d.ts.map +1 -1
  12. package/dist/blobManager/blobManager.js +25 -19
  13. package/dist/blobManager/blobManager.js.map +1 -1
  14. package/dist/blobManager/blobManagerSnapSum.d.ts +1 -0
  15. package/dist/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  16. package/dist/blobManager/blobManagerSnapSum.js +7 -5
  17. package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
  18. package/dist/channelCollection.d.ts.map +1 -1
  19. package/dist/channelCollection.js +63 -41
  20. package/dist/channelCollection.js.map +1 -1
  21. package/dist/connectionTelemetry.d.ts +2 -2
  22. package/dist/connectionTelemetry.d.ts.map +1 -1
  23. package/dist/connectionTelemetry.js +4 -4
  24. package/dist/connectionTelemetry.js.map +1 -1
  25. package/dist/containerRuntime.d.ts +14 -30
  26. package/dist/containerRuntime.d.ts.map +1 -1
  27. package/dist/containerRuntime.js +265 -196
  28. package/dist/containerRuntime.js.map +1 -1
  29. package/dist/dataStore.js +6 -3
  30. package/dist/dataStore.js.map +1 -1
  31. package/dist/dataStoreContext.d.ts.map +1 -1
  32. package/dist/dataStoreContext.js +16 -11
  33. package/dist/dataStoreContext.js.map +1 -1
  34. package/dist/dataStoreContexts.d.ts.map +1 -1
  35. package/dist/dataStoreContexts.js +1 -0
  36. package/dist/dataStoreContexts.js.map +1 -1
  37. package/dist/deltaScheduler.d.ts.map +1 -1
  38. package/dist/deltaScheduler.js +5 -5
  39. package/dist/deltaScheduler.js.map +1 -1
  40. package/dist/gc/garbageCollection.d.ts.map +1 -1
  41. package/dist/gc/garbageCollection.js +36 -14
  42. package/dist/gc/garbageCollection.js.map +1 -1
  43. package/dist/gc/gcConfigs.d.ts.map +1 -1
  44. package/dist/gc/gcConfigs.js +2 -0
  45. package/dist/gc/gcConfigs.js.map +1 -1
  46. package/dist/gc/gcDefinitions.d.ts +8 -0
  47. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  48. package/dist/gc/gcDefinitions.js +1 -0
  49. package/dist/gc/gcDefinitions.js.map +1 -1
  50. package/dist/gc/gcHelpers.d.ts.map +1 -1
  51. package/dist/gc/gcHelpers.js +8 -5
  52. package/dist/gc/gcHelpers.js.map +1 -1
  53. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  54. package/dist/gc/gcSummaryStateTracker.js +2 -1
  55. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  56. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  57. package/dist/gc/gcTelemetry.js +29 -15
  58. package/dist/gc/gcTelemetry.js.map +1 -1
  59. package/dist/inboundBatchAggregator.js +3 -3
  60. package/dist/inboundBatchAggregator.js.map +1 -1
  61. package/dist/layerCompatState.d.ts +19 -0
  62. package/dist/layerCompatState.d.ts.map +1 -0
  63. package/dist/layerCompatState.js +64 -0
  64. package/dist/layerCompatState.js.map +1 -0
  65. package/dist/messageTypes.d.ts.map +1 -1
  66. package/dist/messageTypes.js.map +1 -1
  67. package/dist/opLifecycle/duplicateBatchDetector.js +2 -2
  68. package/dist/opLifecycle/duplicateBatchDetector.js.map +1 -1
  69. package/dist/opLifecycle/opCompressor.d.ts +3 -2
  70. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  71. package/dist/opLifecycle/opCompressor.js +13 -19
  72. package/dist/opLifecycle/opCompressor.js.map +1 -1
  73. package/dist/opLifecycle/opDecompressor.d.ts +3 -0
  74. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  75. package/dist/opLifecycle/opDecompressor.js +4 -1
  76. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  77. package/dist/opLifecycle/opGroupingManager.d.ts +1 -1
  78. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  79. package/dist/opLifecycle/opGroupingManager.js +5 -3
  80. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  81. package/dist/opLifecycle/opSplitter.d.ts +13 -10
  82. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  83. package/dist/opLifecycle/opSplitter.js +14 -11
  84. package/dist/opLifecycle/opSplitter.js.map +1 -1
  85. package/dist/opLifecycle/outbox.d.ts +3 -3
  86. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  87. package/dist/opLifecycle/outbox.js +11 -15
  88. package/dist/opLifecycle/outbox.js.map +1 -1
  89. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  90. package/dist/opLifecycle/remoteMessageProcessor.js +3 -1
  91. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  92. package/dist/packageVersion.d.ts +1 -1
  93. package/dist/packageVersion.js +1 -1
  94. package/dist/packageVersion.js.map +1 -1
  95. package/dist/pendingStateManager.d.ts +3 -4
  96. package/dist/pendingStateManager.d.ts.map +1 -1
  97. package/dist/pendingStateManager.js +11 -10
  98. package/dist/pendingStateManager.js.map +1 -1
  99. package/dist/summary/documentSchema.d.ts +7 -0
  100. package/dist/summary/documentSchema.d.ts.map +1 -1
  101. package/dist/summary/documentSchema.js +6 -4
  102. package/dist/summary/documentSchema.js.map +1 -1
  103. package/dist/summary/orderedClientElection.d.ts +1 -0
  104. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  105. package/dist/summary/orderedClientElection.js +13 -11
  106. package/dist/summary/orderedClientElection.js.map +1 -1
  107. package/dist/summary/runWhileConnectedCoordinator.d.ts +1 -0
  108. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  109. package/dist/summary/runWhileConnectedCoordinator.js +7 -2
  110. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  111. package/dist/summary/runningSummarizer.d.ts +2 -2
  112. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  113. package/dist/summary/runningSummarizer.js +38 -17
  114. package/dist/summary/runningSummarizer.js.map +1 -1
  115. package/dist/summary/summarizer.d.ts +1 -0
  116. package/dist/summary/summarizer.d.ts.map +1 -1
  117. package/dist/summary/summarizer.js +18 -9
  118. package/dist/summary/summarizer.js.map +1 -1
  119. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  120. package/dist/summary/summarizerClientElection.js +1 -0
  121. package/dist/summary/summarizerClientElection.js.map +1 -1
  122. package/dist/summary/summarizerHeuristics.js +1 -1
  123. package/dist/summary/summarizerHeuristics.js.map +1 -1
  124. package/dist/summary/summarizerNode/index.d.ts.map +1 -1
  125. package/dist/summary/summarizerNode/index.js.map +1 -1
  126. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  127. package/dist/summary/summarizerNode/summarizerNode.js +30 -31
  128. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  129. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
  130. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +3 -3
  131. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  132. package/dist/summary/summarizerTypes.d.ts +7 -0
  133. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  134. package/dist/summary/summarizerTypes.js.map +1 -1
  135. package/dist/summary/summaryCollection.d.ts +3 -4
  136. package/dist/summary/summaryCollection.d.ts.map +1 -1
  137. package/dist/summary/summaryCollection.js +9 -6
  138. package/dist/summary/summaryCollection.js.map +1 -1
  139. package/dist/summary/summaryFormat.d.ts +4 -1
  140. package/dist/summary/summaryFormat.d.ts.map +1 -1
  141. package/dist/summary/summaryFormat.js +3 -2
  142. package/dist/summary/summaryFormat.js.map +1 -1
  143. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  144. package/dist/summary/summaryGenerator.js +19 -8
  145. package/dist/summary/summaryGenerator.js.map +1 -1
  146. package/dist/summary/summaryManager.d.ts.map +1 -1
  147. package/dist/summary/summaryManager.js +12 -9
  148. package/dist/summary/summaryManager.js.map +1 -1
  149. package/lib/batchTracker.d.ts +1 -2
  150. package/lib/batchTracker.d.ts.map +1 -1
  151. package/lib/batchTracker.js +2 -2
  152. package/lib/batchTracker.js.map +1 -1
  153. package/lib/blobManager/blobManager.d.ts +0 -3
  154. package/lib/blobManager/blobManager.d.ts.map +1 -1
  155. package/lib/blobManager/blobManager.js +26 -20
  156. package/lib/blobManager/blobManager.js.map +1 -1
  157. package/lib/blobManager/blobManagerSnapSum.d.ts +1 -0
  158. package/lib/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  159. package/lib/blobManager/blobManagerSnapSum.js +7 -5
  160. package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
  161. package/lib/channelCollection.d.ts.map +1 -1
  162. package/lib/channelCollection.js +66 -42
  163. package/lib/channelCollection.js.map +1 -1
  164. package/lib/connectionTelemetry.d.ts +2 -2
  165. package/lib/connectionTelemetry.d.ts.map +1 -1
  166. package/lib/connectionTelemetry.js +5 -5
  167. package/lib/connectionTelemetry.js.map +1 -1
  168. package/lib/containerRuntime.d.ts +14 -30
  169. package/lib/containerRuntime.d.ts.map +1 -1
  170. package/lib/containerRuntime.js +272 -198
  171. package/lib/containerRuntime.js.map +1 -1
  172. package/lib/dataStore.js +6 -3
  173. package/lib/dataStore.js.map +1 -1
  174. package/lib/dataStoreContext.d.ts.map +1 -1
  175. package/lib/dataStoreContext.js +16 -11
  176. package/lib/dataStoreContext.js.map +1 -1
  177. package/lib/dataStoreContexts.d.ts.map +1 -1
  178. package/lib/dataStoreContexts.js +1 -0
  179. package/lib/dataStoreContexts.js.map +1 -1
  180. package/lib/deltaScheduler.d.ts.map +1 -1
  181. package/lib/deltaScheduler.js +6 -6
  182. package/lib/deltaScheduler.js.map +1 -1
  183. package/lib/gc/garbageCollection.d.ts.map +1 -1
  184. package/lib/gc/garbageCollection.js +39 -15
  185. package/lib/gc/garbageCollection.js.map +1 -1
  186. package/lib/gc/gcConfigs.d.ts.map +1 -1
  187. package/lib/gc/gcConfigs.js +2 -0
  188. package/lib/gc/gcConfigs.js.map +1 -1
  189. package/lib/gc/gcDefinitions.d.ts +8 -0
  190. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  191. package/lib/gc/gcDefinitions.js +1 -0
  192. package/lib/gc/gcDefinitions.js.map +1 -1
  193. package/lib/gc/gcHelpers.d.ts.map +1 -1
  194. package/lib/gc/gcHelpers.js +8 -5
  195. package/lib/gc/gcHelpers.js.map +1 -1
  196. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  197. package/lib/gc/gcSummaryStateTracker.js +2 -1
  198. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  199. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  200. package/lib/gc/gcTelemetry.js +32 -16
  201. package/lib/gc/gcTelemetry.js.map +1 -1
  202. package/lib/inboundBatchAggregator.js +4 -4
  203. package/lib/inboundBatchAggregator.js.map +1 -1
  204. package/lib/layerCompatState.d.ts +19 -0
  205. package/lib/layerCompatState.d.ts.map +1 -0
  206. package/lib/layerCompatState.js +60 -0
  207. package/lib/layerCompatState.js.map +1 -0
  208. package/lib/messageTypes.d.ts.map +1 -1
  209. package/lib/messageTypes.js.map +1 -1
  210. package/lib/opLifecycle/duplicateBatchDetector.js +2 -2
  211. package/lib/opLifecycle/duplicateBatchDetector.js.map +1 -1
  212. package/lib/opLifecycle/opCompressor.d.ts +3 -2
  213. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  214. package/lib/opLifecycle/opCompressor.js +13 -19
  215. package/lib/opLifecycle/opCompressor.js.map +1 -1
  216. package/lib/opLifecycle/opDecompressor.d.ts +3 -0
  217. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  218. package/lib/opLifecycle/opDecompressor.js +4 -1
  219. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  220. package/lib/opLifecycle/opGroupingManager.d.ts +1 -1
  221. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  222. package/lib/opLifecycle/opGroupingManager.js +5 -3
  223. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  224. package/lib/opLifecycle/opSplitter.d.ts +13 -10
  225. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  226. package/lib/opLifecycle/opSplitter.js +14 -11
  227. package/lib/opLifecycle/opSplitter.js.map +1 -1
  228. package/lib/opLifecycle/outbox.d.ts +3 -3
  229. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  230. package/lib/opLifecycle/outbox.js +11 -15
  231. package/lib/opLifecycle/outbox.js.map +1 -1
  232. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  233. package/lib/opLifecycle/remoteMessageProcessor.js +3 -1
  234. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  235. package/lib/packageVersion.d.ts +1 -1
  236. package/lib/packageVersion.js +1 -1
  237. package/lib/packageVersion.js.map +1 -1
  238. package/lib/pendingStateManager.d.ts +3 -4
  239. package/lib/pendingStateManager.d.ts.map +1 -1
  240. package/lib/pendingStateManager.js +12 -11
  241. package/lib/pendingStateManager.js.map +1 -1
  242. package/lib/summary/documentSchema.d.ts +7 -0
  243. package/lib/summary/documentSchema.d.ts.map +1 -1
  244. package/lib/summary/documentSchema.js +6 -4
  245. package/lib/summary/documentSchema.js.map +1 -1
  246. package/lib/summary/orderedClientElection.d.ts +1 -0
  247. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  248. package/lib/summary/orderedClientElection.js +13 -11
  249. package/lib/summary/orderedClientElection.js.map +1 -1
  250. package/lib/summary/runWhileConnectedCoordinator.d.ts +1 -0
  251. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  252. package/lib/summary/runWhileConnectedCoordinator.js +7 -2
  253. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  254. package/lib/summary/runningSummarizer.d.ts +2 -2
  255. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  256. package/lib/summary/runningSummarizer.js +38 -17
  257. package/lib/summary/runningSummarizer.js.map +1 -1
  258. package/lib/summary/summarizer.d.ts +1 -0
  259. package/lib/summary/summarizer.d.ts.map +1 -1
  260. package/lib/summary/summarizer.js +18 -9
  261. package/lib/summary/summarizer.js.map +1 -1
  262. package/lib/summary/summarizerClientElection.d.ts.map +1 -1
  263. package/lib/summary/summarizerClientElection.js +1 -0
  264. package/lib/summary/summarizerClientElection.js.map +1 -1
  265. package/lib/summary/summarizerHeuristics.js +1 -1
  266. package/lib/summary/summarizerHeuristics.js.map +1 -1
  267. package/lib/summary/summarizerNode/index.d.ts.map +1 -1
  268. package/lib/summary/summarizerNode/index.js.map +1 -1
  269. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  270. package/lib/summary/summarizerNode/summarizerNode.js +30 -31
  271. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  272. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
  273. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +3 -3
  274. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  275. package/lib/summary/summarizerTypes.d.ts +7 -0
  276. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  277. package/lib/summary/summarizerTypes.js.map +1 -1
  278. package/lib/summary/summaryCollection.d.ts +3 -4
  279. package/lib/summary/summaryCollection.d.ts.map +1 -1
  280. package/lib/summary/summaryCollection.js +9 -6
  281. package/lib/summary/summaryCollection.js.map +1 -1
  282. package/lib/summary/summaryFormat.d.ts +4 -1
  283. package/lib/summary/summaryFormat.d.ts.map +1 -1
  284. package/lib/summary/summaryFormat.js +2 -2
  285. package/lib/summary/summaryFormat.js.map +1 -1
  286. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  287. package/lib/summary/summaryGenerator.js +19 -8
  288. package/lib/summary/summaryGenerator.js.map +1 -1
  289. package/lib/summary/summaryManager.d.ts.map +1 -1
  290. package/lib/summary/summaryManager.js +12 -9
  291. package/lib/summary/summaryManager.js.map +1 -1
  292. package/package.json +24 -46
  293. package/src/batchTracker.ts +3 -3
  294. package/src/blobManager/blobManager.ts +27 -28
  295. package/src/blobManager/blobManagerSnapSum.ts +8 -8
  296. package/src/channelCollection.ts +63 -44
  297. package/src/connectionTelemetry.ts +12 -6
  298. package/src/containerRuntime.ts +306 -236
  299. package/src/dataStore.ts +6 -3
  300. package/src/dataStoreContext.ts +16 -16
  301. package/src/dataStoreContexts.ts +1 -0
  302. package/src/deltaScheduler.ts +6 -6
  303. package/src/gc/garbageCollection.ts +47 -20
  304. package/src/gc/gcConfigs.ts +9 -1
  305. package/src/gc/gcDefinitions.ts +12 -0
  306. package/src/gc/gcHelpers.ts +9 -4
  307. package/src/gc/gcSummaryStateTracker.ts +3 -1
  308. package/src/gc/gcTelemetry.ts +26 -11
  309. package/src/inboundBatchAggregator.ts +4 -4
  310. package/src/layerCompatState.ts +75 -0
  311. package/src/messageTypes.ts +2 -0
  312. package/src/opLifecycle/README.md +43 -34
  313. package/src/opLifecycle/duplicateBatchDetector.ts +2 -2
  314. package/src/opLifecycle/opCompressor.ts +16 -23
  315. package/src/opLifecycle/opDecompressor.ts +4 -1
  316. package/src/opLifecycle/opGroupingManager.ts +5 -4
  317. package/src/opLifecycle/opSplitter.ts +14 -11
  318. package/src/opLifecycle/outbox.ts +13 -20
  319. package/src/opLifecycle/remoteMessageProcessor.ts +3 -1
  320. package/src/packageVersion.ts +1 -1
  321. package/src/pendingStateManager.ts +15 -10
  322. package/src/summary/documentSchema.ts +11 -4
  323. package/src/summary/orderedClientElection.ts +14 -11
  324. package/src/summary/runWhileConnectedCoordinator.ts +6 -0
  325. package/src/summary/runningSummarizer.ts +43 -19
  326. package/src/summary/summarizer.ts +24 -11
  327. package/src/summary/summarizerClientElection.ts +2 -0
  328. package/src/summary/summarizerHeuristics.ts +1 -1
  329. package/src/summary/summarizerNode/index.ts +1 -0
  330. package/src/summary/summarizerNode/summarizerNode.ts +32 -31
  331. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +4 -4
  332. package/src/summary/summarizerTypes.ts +7 -0
  333. package/src/summary/summaryCollection.ts +19 -8
  334. package/src/summary/summaryFormat.ts +10 -5
  335. package/src/summary/summaryGenerator.ts +25 -10
  336. package/src/summary/summaryManager.ts +14 -12
  337. package/container-runtime.test-files.tar +0 -0
@@ -24,7 +24,11 @@ const gcDefinitions_js_1 = require("./gcDefinitions.js");
24
24
  * Note: The telemetry for a Deleted node being used is logged elsewhere in this package.
25
25
  */
26
26
  class GCTelemetryTracker {
27
- constructor(mc, configs, isSummarizerClient, createContainerMetadata, getNodeType, getNodeStateTracker, getNodePackagePath) {
27
+ constructor(mc, configs, isSummarizerClient,
28
+ // eslint-disable-next-line import/no-deprecated
29
+ createContainerMetadata,
30
+ // eslint-disable-next-line import/no-deprecated
31
+ getNodeType, getNodeStateTracker, getNodePackagePath) {
28
32
  this.mc = mc;
29
33
  this.configs = configs;
30
34
  this.isSummarizerClient = isSummarizerClient;
@@ -48,15 +52,19 @@ class GCTelemetryTracker {
48
52
  *
49
53
  * 2. An event is logged only once per container instance per event per node.
50
54
  */
51
- shouldLogNonActiveEvent(nodeType, usageType, nodeStateTracker, uniqueEventId) {
55
+ shouldLogNonActiveEvent(
56
+ // eslint-disable-next-line import/no-deprecated
57
+ nodeType, usageType, nodeStateTracker, uniqueEventId) {
52
58
  if (nodeStateTracker.state === gcDefinitions_js_1.UnreferencedState.Active) {
53
59
  return false;
54
60
  }
61
+ // eslint-disable-next-line import/no-deprecated
55
62
  if (nodeType === gcDefinitions_js_1.GCNodeType.Other) {
56
63
  return false;
57
64
  }
58
65
  // For sub data store (DDS) nodes, if they are changed, its data store will also be changed,
59
66
  // so skip logging to make the telemetry less noisy.
67
+ // eslint-disable-next-line import/no-deprecated
60
68
  if (nodeType === gcDefinitions_js_1.GCNodeType.SubDataStore && usageType === "Changed") {
61
69
  return false;
62
70
  }
@@ -80,15 +88,19 @@ class GCTelemetryTracker {
80
88
  const nodeType = this.getNodeType(untaggedId);
81
89
  const timeout = (() => {
82
90
  switch (nodeStateTracker?.state) {
83
- case gcDefinitions_js_1.UnreferencedState.Inactive:
91
+ case gcDefinitions_js_1.UnreferencedState.Inactive: {
84
92
  return this.configs.inactiveTimeoutMs;
85
- case gcDefinitions_js_1.UnreferencedState.TombstoneReady:
93
+ }
94
+ case gcDefinitions_js_1.UnreferencedState.TombstoneReady: {
86
95
  return this.configs.tombstoneTimeoutMs;
87
- case gcDefinitions_js_1.UnreferencedState.SweepReady:
96
+ }
97
+ case gcDefinitions_js_1.UnreferencedState.SweepReady: {
88
98
  return (this.configs.tombstoneTimeoutMs &&
89
99
  this.configs.tombstoneTimeoutMs + this.configs.sweepGracePeriodMs);
90
- default:
100
+ }
101
+ default: {
91
102
  return undefined;
103
+ }
92
104
  }
93
105
  })();
94
106
  const { persistedGcFeatureMatrix, ...configs } = this.configs;
@@ -96,9 +108,9 @@ class GCTelemetryTracker {
96
108
  trackedId,
97
109
  type: nodeType,
98
110
  unrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,
99
- age: nodeStateTracker !== undefined
100
- ? currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs
101
- : -1,
111
+ age: nodeStateTracker === undefined
112
+ ? -1
113
+ : currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,
102
114
  timeout,
103
115
  isTombstoned,
104
116
  ...(0, internal_1.tagCodeArtifacts)({ id: untaggedId, fromId: untaggedFromId }),
@@ -160,7 +172,9 @@ class GCTelemetryTracker {
160
172
  /**
161
173
  * Logs telemetry when a tombstoned object is changed, revived or loaded.
162
174
  */
163
- logTombstoneUsageTelemetry(unrefEventProps, nodeType, usageType, packagePath) {
175
+ logTombstoneUsageTelemetry(unrefEventProps,
176
+ // eslint-disable-next-line import/no-deprecated
177
+ nodeType, usageType, packagePath) {
164
178
  // This will log the following events:
165
179
  // GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived
166
180
  // GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived
@@ -213,7 +227,9 @@ class GCTelemetryTracker {
213
227
  const missingExplicitRoutes = [];
214
228
  for (const route of currentOutboundRoutes) {
215
229
  const nodeType = this.getNodeType(route);
216
- if ((nodeType === gcDefinitions_js_1.GCNodeType.DataStore || nodeType === gcDefinitions_js_1.GCNodeType.Blob) &&
230
+ if (
231
+ // eslint-disable-next-line import/no-deprecated
232
+ (nodeType === gcDefinitions_js_1.GCNodeType.DataStore || nodeType === gcDefinitions_js_1.GCNodeType.Blob) &&
217
233
  !nodeId.startsWith(route) &&
218
234
  !previousRoutes.includes(route) &&
219
235
  !explicitRoutes.includes(route)) {
@@ -254,10 +270,8 @@ class GCTelemetryTracker {
254
270
  const nodeStateTracker = this.getNodeStateTracker(detailedProps.trackedId); // Note: This is never SubDataStore path
255
271
  const active = nodeStateTracker === undefined || nodeStateTracker.state === gcDefinitions_js_1.UnreferencedState.Active;
256
272
  if ((usageType === "Revived") === active) {
257
- const pkg = await this.getNodePackagePath(eventProps.id.value);
258
- const fromPkg = eventProps.fromId
259
- ? await this.getNodePackagePath(eventProps.fromId.value)
260
- : undefined;
273
+ const pkg = await this.getNodePackagePath(id.value);
274
+ const fromPkg = fromId ? await this.getNodePackagePath(fromId.value) : undefined;
261
275
  const event = {
262
276
  eventName: `${state}Object_${usageType}`,
263
277
  id,
@@ -1 +1 @@
1
- {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uEAMkD;AAKlD,yDAK4B;AA2E5B;;;;;;;;;;;;;;;GAeG;AACH,MAAa,kBAAkB;IAO9B,YAC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,IAAA,2BAAgB,EAAC;wBACnB,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;wBACnB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC;qBAC3B,CAAC;iBACF,CAAC;gBAEF,wGAAwG;gBACxG,4DAA4D;gBAC5D,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD;AAnUD,gDAmUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Tagged } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tgenerateStack,\n\ttagCodeArtifacts,\n\ttype ITelemetryPropertiesExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeHeaderData } from \"../containerRuntime.js\";\nimport { ICreateContainerMetadata } from \"../summary/index.js\";\n\nimport {\n\tGCFeatureMatrix,\n\tGCNodeType,\n\tIGarbageCollectorConfigs,\n\tUnreferencedState,\n} from \"./gcDefinitions.js\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker.js\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\" | \"Realized\";\n\n/**\n * Properties that are common to IUnreferencedEventProps and INodeUsageProps\n */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\theaders?: RuntimeHeaderData;\n\tadditionalProps?: ITelemetryPropertiesExt;\n}\n\n/**\n * The event that is logged when unreferenced node is used after a certain time.\n */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\t/**\n\t * The id that GC uses to track the node. May or may not match id\n\t */\n\ttrackedId: string;\n\tstate: UnreferencedState;\n\t/**\n\t * The full path (in GC Path format) to the node in question\n\t */\n\tid: Tagged<string>;\n\tfromId?: Tagged<string>;\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\t// Expanding GC feature matrix. Without doing this, the configs cannot be logged in telemetry directly.\n\tgcConfigs: Omit<IGarbageCollectorConfigs, \"persistedGcFeatureMatrix\"> & {\n\t\t[K in keyof GCFeatureMatrix]: GCFeatureMatrix[K];\n\t};\n\ttimeout?: number;\n}\n\n/**\n * Properties passed to nodeUsed function when a node is used.\n */\ninterface INodeUsageProps extends ICommonProps {\n\t/**\n\t * The full path (in GC Path format) to the node in question\n\t */\n\tid: string;\n\t/**\n\t * Latest timestamp received from the server, as a baseline for computing GC state/age\n\t */\n\tcurrentReferenceTimestampMs: number;\n\t/**\n\t * The package path of the node. This may not be available if the node hasn't been loaded yet\n\t */\n\tpackagePath: readonly string[] | undefined;\n\t/**\n\t * In case of Revived - what node added the reference?\n\t */\n\tfromId?: string;\n\t/**\n\t * In case of Revived - was it revived due to autorecovery?\n\t */\n\tautorecovery?: true;\n\t/**\n\t * URL (including query string) if this usage came from a request\n\t */\n\trequestUrl?: string;\n\t/**\n\t * Original request headers if this usage came from a request or handle.get\n\t */\n\trequestHeaders?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector.\n *\n * These events are not logged as errors, just generic events, since there can be false positives:\n *\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. tombstoneReadyObject telemetry - When a tombstone-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs.\n * 3. sweepReadyObject telemetry - When a sweep-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs + sweepGracePeriodMs.\n *\n * These events are logged as errors since they are based on the core GC logic:\n *\n * 1. Tombstone telemetry - When a tombstoned node is used - A node that has been marked as tombstone.\n * 2. Unknown outbound reference telemetry - When a node is referenced but GC was not notified of it when the new reference appeared.\n *\n * Note: The telemetry for a Deleted node being used is logged elsewhere in this package.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: IGarbageCollectorConfigs,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore.\n\t *\n\t * @remarks\n\t * This does not apply to tombstoned nodes for which an event is always logged. Some scenarios where we won't log:\n\t *\n\t * 1. When a DDS is changed. The corresponding data store's event will be logged instead.\n\t *\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t): boolean {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed, its data store will also be changed,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType === \"Changed\") {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Non-tombstone events are logged once per event per node. A unique id is generated by joining\n\t\t// node state (inactive / sweep ready), node's id and usage (loaded / changed / revived).\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is inactive or tombstoned, log telemetry indicating object is used\n\t * when it should not have been.\n\t * @param trackedId - The id that GC uses to track the node. For SubDataStore nodes, this should be the DataStore ID.\n\t * @param INodeUsageProps - All kind of details about this event to be logged\n\t */\n\tpublic nodeUsed(\n\t\ttrackedId: string,\n\t\t{\n\t\t\tusageType,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tpackagePath,\n\t\t\tid: untaggedId,\n\t\t\tfromId: untaggedFromId,\n\t\t\tisTombstoned,\n\t\t\t...otherNodeUsageProps\n\t\t}: INodeUsageProps,\n\t): void {\n\t\t// Note: For SubDataStore Load usage, trackedId will be the DataStore's id, not the full path in question.\n\t\t// This is necessary because the SubDataStore path may be unrecognized by GC (if suited for a custom request handler)\n\t\tconst nodeStateTracker = this.getNodeStateTracker(trackedId);\n\t\tconst nodeType = this.getNodeType(untaggedId);\n\n\t\tconst timeout = (() => {\n\t\t\tswitch (nodeStateTracker?.state) {\n\t\t\t\tcase UnreferencedState.Inactive:\n\t\t\t\t\treturn this.configs.inactiveTimeoutMs;\n\t\t\t\tcase UnreferencedState.TombstoneReady:\n\t\t\t\t\treturn this.configs.tombstoneTimeoutMs;\n\t\t\t\tcase UnreferencedState.SweepReady:\n\t\t\t\t\treturn (\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs &&\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs + this.configs.sweepGracePeriodMs\n\t\t\t\t\t);\n\t\t\t\tdefault:\n\t\t\t\t\treturn undefined;\n\t\t\t}\n\t\t})();\n\t\tconst { persistedGcFeatureMatrix, ...configs } = this.configs;\n\t\tconst unrefEventProps = {\n\t\t\ttrackedId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,\n\t\t\tage:\n\t\t\t\tnodeStateTracker !== undefined\n\t\t\t\t\t? currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs\n\t\t\t\t\t: -1,\n\t\t\ttimeout,\n\t\t\tisTombstoned,\n\t\t\t...tagCodeArtifacts({ id: untaggedId, fromId: untaggedFromId }),\n\t\t\t...otherNodeUsageProps,\n\t\t\t...this.createContainerMetadata,\n\t\t\tgcConfigs: { ...configs, ...persistedGcFeatureMatrix },\n\t\t} satisfies Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> &\n\t\t\ttypeof otherNodeUsageProps;\n\n\t\t// If the node that is used is tombstoned, log a tombstone telemetry.\n\t\tif (isTombstoned) {\n\t\t\tthis.logTombstoneUsageTelemetry(unrefEventProps, nodeType, usageType, packagePath);\n\t\t}\n\n\t\t// After logging tombstone telemetry, if the node's unreferenced state is not tracked, there is nothing\n\t\t// else to log.\n\t\tif (nodeStateTracker === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${untaggedId}-${usageType}`;\n\n\t\tif (!this.shouldLogNonActiveEvent(nodeType, usageType, nodeStateTracker, uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session.\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...unrefEventProps, // Note: Contains some properties from INodeUsageProps as well\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\t\t\tunrefEventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Logs telemetry when a tombstoned object is changed, revived or loaded.\n\t */\n\tprivate logTombstoneUsageTelemetry(\n\t\tunrefEventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\">,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tpackagePath?: readonly string[],\n\t): void {\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived\n\t\t// GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived\n\t\t// GC_Tombstone_Blob_Requested, GC_Tombstone_Blob_Changed, GC_Tombstone_Blob_Revived\n\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\tunrefEventProps;\n\t\tconst eventUsageName = usageType === \"Loaded\" ? \"Requested\" : usageType;\n\t\tconst event = {\n\t\t\teventName: `GC_Tombstone_${nodeType}_${eventUsageName}`,\n\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\tstack: generateStack(),\n\t\t\tid,\n\t\t\tfromId,\n\t\t\theaders: { ...headers },\n\t\t\tdetails: { ...detailedProps, ...additionalProps }, // Also includes some properties from INodeUsageProps type\n\t\t\tgcConfigs,\n\t\t};\n\n\t\tif (\n\t\t\tusageType === \"Loaded\" &&\n\t\t\tthis.configs.throwOnTombstoneLoad &&\n\t\t\t!headers?.allowTombstone\n\t\t) {\n\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t} else {\n\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t): void {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\t// Send as Generic not Error since there are known corner cases where this will fire.\n\t\t\t\t// E.g. If an old client re-references a node via an attach op (that doesn't include GC Data)\n\t\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt): Promise<void> {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst {\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t\tid,\n\t\t\t\tfromId,\n\t\t\t\theaders,\n\t\t\t\tgcConfigs,\n\t\t\t\tadditionalProps,\n\t\t\t\t...detailedProps\n\t\t\t} = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(detailedProps.trackedId); // Note: This is never SubDataStore path\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined || nodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n"]}
1
+ {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uEAMkD;AAMlD,yDAO4B;AA8E5B;;;;;;;;;;;;;;;GAeG;AACH,MAAa,kBAAkB;IAO9B,YACkB,EAAqB,EACrB,OAAiC,EACjC,kBAA2B;IAC5C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;oBACxC,EAAE;oBACF,MAAM;oBACN,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE;oBACvB,OAAO,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,eAAe,EAAE;oBACjD,SAAS;oBACT,GAAG,IAAA,2BAAgB,EAAC;wBACnB,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;wBACnB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC;qBAC3B,CAAC;iBACF,CAAC;gBAEF,wGAAwG;gBACxG,4DAA4D;gBAC5D,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD;AA5UD,gDA4UC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Tagged } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tgenerateStack,\n\ttagCodeArtifacts,\n\ttype ITelemetryPropertiesExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeHeaderData } from \"../containerRuntime.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ICreateContainerMetadata } from \"../summary/index.js\";\n\nimport {\n\t// eslint-disable-next-line import/no-deprecated\n\tGCFeatureMatrix,\n\t// eslint-disable-next-line import/no-deprecated\n\tGCNodeType,\n\tIGarbageCollectorConfigs,\n\tUnreferencedState,\n} from \"./gcDefinitions.js\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker.js\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\" | \"Realized\";\n\n/**\n * Properties that are common to IUnreferencedEventProps and INodeUsageProps\n */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\theaders?: RuntimeHeaderData;\n\tadditionalProps?: ITelemetryPropertiesExt;\n}\n\n/**\n * The event that is logged when unreferenced node is used after a certain time.\n */\n// eslint-disable-next-line import/no-deprecated\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\t/**\n\t * The id that GC uses to track the node. May or may not match id\n\t */\n\ttrackedId: string;\n\tstate: UnreferencedState;\n\t/**\n\t * The full path (in GC Path format) to the node in question\n\t */\n\tid: Tagged<string>;\n\tfromId?: Tagged<string>;\n\t// eslint-disable-next-line import/no-deprecated\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\t// Expanding GC feature matrix. Without doing this, the configs cannot be logged in telemetry directly.\n\tgcConfigs: Omit<IGarbageCollectorConfigs, \"persistedGcFeatureMatrix\"> & {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\t[K in keyof GCFeatureMatrix]: GCFeatureMatrix[K];\n\t};\n\ttimeout?: number;\n}\n\n/**\n * Properties passed to nodeUsed function when a node is used.\n */\ninterface INodeUsageProps extends ICommonProps {\n\t/**\n\t * The full path (in GC Path format) to the node in question\n\t */\n\tid: string;\n\t/**\n\t * Latest timestamp received from the server, as a baseline for computing GC state/age\n\t */\n\tcurrentReferenceTimestampMs: number;\n\t/**\n\t * The package path of the node. This may not be available if the node hasn't been loaded yet\n\t */\n\tpackagePath: readonly string[] | undefined;\n\t/**\n\t * In case of Revived - what node added the reference?\n\t */\n\tfromId?: string;\n\t/**\n\t * In case of Revived - was it revived due to autorecovery?\n\t */\n\tautorecovery?: true;\n\t/**\n\t * URL (including query string) if this usage came from a request\n\t */\n\trequestUrl?: string;\n\t/**\n\t * Original request headers if this usage came from a request or handle.get\n\t */\n\trequestHeaders?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector.\n *\n * These events are not logged as errors, just generic events, since there can be false positives:\n *\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. tombstoneReadyObject telemetry - When a tombstone-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs.\n * 3. sweepReadyObject telemetry - When a sweep-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs + sweepGracePeriodMs.\n *\n * These events are logged as errors since they are based on the core GC logic:\n *\n * 1. Tombstone telemetry - When a tombstoned node is used - A node that has been marked as tombstone.\n * 2. Unknown outbound reference telemetry - When a node is referenced but GC was not notified of it when the new reference appeared.\n *\n * Note: The telemetry for a Deleted node being used is logged elsewhere in this package.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: IGarbageCollectorConfigs,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore.\n\t *\n\t * @remarks\n\t * This does not apply to tombstoned nodes for which an event is always logged. Some scenarios where we won't log:\n\t *\n\t * 1. When a DDS is changed. The corresponding data store's event will be logged instead.\n\t *\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t): boolean {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed, its data store will also be changed,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType === \"Changed\") {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Non-tombstone events are logged once per event per node. A unique id is generated by joining\n\t\t// node state (inactive / sweep ready), node's id and usage (loaded / changed / revived).\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is inactive or tombstoned, log telemetry indicating object is used\n\t * when it should not have been.\n\t * @param trackedId - The id that GC uses to track the node. For SubDataStore nodes, this should be the DataStore ID.\n\t * @param INodeUsageProps - All kind of details about this event to be logged\n\t */\n\tpublic nodeUsed(\n\t\ttrackedId: string,\n\t\t{\n\t\t\tusageType,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tpackagePath,\n\t\t\tid: untaggedId,\n\t\t\tfromId: untaggedFromId,\n\t\t\tisTombstoned,\n\t\t\t...otherNodeUsageProps\n\t\t}: INodeUsageProps,\n\t): void {\n\t\t// Note: For SubDataStore Load usage, trackedId will be the DataStore's id, not the full path in question.\n\t\t// This is necessary because the SubDataStore path may be unrecognized by GC (if suited for a custom request handler)\n\t\tconst nodeStateTracker = this.getNodeStateTracker(trackedId);\n\t\tconst nodeType = this.getNodeType(untaggedId);\n\n\t\tconst timeout = (() => {\n\t\t\tswitch (nodeStateTracker?.state) {\n\t\t\t\tcase UnreferencedState.Inactive: {\n\t\t\t\t\treturn this.configs.inactiveTimeoutMs;\n\t\t\t\t}\n\t\t\t\tcase UnreferencedState.TombstoneReady: {\n\t\t\t\t\treturn this.configs.tombstoneTimeoutMs;\n\t\t\t\t}\n\t\t\t\tcase UnreferencedState.SweepReady: {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs &&\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs + this.configs.sweepGracePeriodMs\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t})();\n\t\tconst { persistedGcFeatureMatrix, ...configs } = this.configs;\n\t\tconst unrefEventProps = {\n\t\t\ttrackedId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,\n\t\t\tage:\n\t\t\t\tnodeStateTracker === undefined\n\t\t\t\t\t? -1\n\t\t\t\t\t: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout,\n\t\t\tisTombstoned,\n\t\t\t...tagCodeArtifacts({ id: untaggedId, fromId: untaggedFromId }),\n\t\t\t...otherNodeUsageProps,\n\t\t\t...this.createContainerMetadata,\n\t\t\tgcConfigs: { ...configs, ...persistedGcFeatureMatrix },\n\t\t} satisfies Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> &\n\t\t\ttypeof otherNodeUsageProps;\n\n\t\t// If the node that is used is tombstoned, log a tombstone telemetry.\n\t\tif (isTombstoned) {\n\t\t\tthis.logTombstoneUsageTelemetry(unrefEventProps, nodeType, usageType, packagePath);\n\t\t}\n\n\t\t// After logging tombstone telemetry, if the node's unreferenced state is not tracked, there is nothing\n\t\t// else to log.\n\t\tif (nodeStateTracker === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${untaggedId}-${usageType}`;\n\n\t\tif (!this.shouldLogNonActiveEvent(nodeType, usageType, nodeStateTracker, uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session.\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...unrefEventProps, // Note: Contains some properties from INodeUsageProps as well\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\t\t\tunrefEventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Logs telemetry when a tombstoned object is changed, revived or loaded.\n\t */\n\tprivate logTombstoneUsageTelemetry(\n\t\tunrefEventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\">,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tpackagePath?: readonly string[],\n\t): void {\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived\n\t\t// GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived\n\t\t// GC_Tombstone_Blob_Requested, GC_Tombstone_Blob_Changed, GC_Tombstone_Blob_Revived\n\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\tunrefEventProps;\n\t\tconst eventUsageName = usageType === \"Loaded\" ? \"Requested\" : usageType;\n\t\tconst event = {\n\t\t\teventName: `GC_Tombstone_${nodeType}_${eventUsageName}`,\n\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\tstack: generateStack(),\n\t\t\tid,\n\t\t\tfromId,\n\t\t\theaders: { ...headers },\n\t\t\tdetails: { ...detailedProps, ...additionalProps }, // Also includes some properties from INodeUsageProps type\n\t\t\tgcConfigs,\n\t\t};\n\n\t\tif (\n\t\t\tusageType === \"Loaded\" &&\n\t\t\tthis.configs.throwOnTombstoneLoad &&\n\t\t\t!headers?.allowTombstone\n\t\t) {\n\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t} else {\n\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t): void {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\t// Send as Generic not Error since there are known corner cases where this will fire.\n\t\t\t\t// E.g. If an old client re-references a node via an attach op (that doesn't include GC Data)\n\t\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt): Promise<void> {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst {\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t\tid,\n\t\t\t\tfromId,\n\t\t\t\theaders,\n\t\t\t\tgcConfigs,\n\t\t\t\tadditionalProps,\n\t\t\t\t...detailedProps\n\t\t\t} = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(detailedProps.trackedId); // Note: This is never SubDataStore path\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined || nodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(id.value);\n\t\t\t\tconst fromPkg = fromId ? await this.getNodePackagePath(fromId.value) : undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n"]}
@@ -61,7 +61,7 @@ class InboundBatchAggregator {
61
61
  * Called for each incoming op (i.e. inbound "push" notification)
62
62
  */
63
63
  this.trackPending = (message) => {
64
- (0, internal_1.assert)(this.deltaManager.inbound.length !== 0, 0x298 /* "we have something in the queue that generates this event" */);
64
+ (0, internal_1.assert)(this.deltaManager.inbound.length > 0, 0x298 /* "we have something in the queue that generates this event" */);
65
65
  (0, internal_1.assert)((this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined), 0x299 /* "non-synchronized state" */);
66
66
  const metadata = message.metadata;
67
67
  // batchMetadata will be true for the message that starts a batch, false for the one that ends it, and
@@ -154,13 +154,13 @@ class InboundBatchAggregator {
154
154
  pauseQueue() {
155
155
  (0, internal_1.assert)(!this.localPaused, 0x297 /* "always called from resumed state" */);
156
156
  this.localPaused = true;
157
- this.timePaused = client_utils_1.performance.now();
157
+ this.timePaused = (0, client_utils_1.performanceNow)();
158
158
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
159
159
  this.deltaManager.inbound.pause();
160
160
  }
161
161
  resumeQueue(startBatch, messageEndBatch) {
162
162
  const endBatch = messageEndBatch.sequenceNumber;
163
- const duration = this.localPaused ? client_utils_1.performance.now() - this.timePaused : undefined;
163
+ const duration = this.localPaused ? (0, client_utils_1.performanceNow)() - this.timePaused : undefined;
164
164
  this.batchCount++;
165
165
  if (this.batchCount % 1000 === 1) {
166
166
  this.logger.sendTelemetryEvent({
@@ -1 +1 @@
1
- {"version":3,"file":"inbo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UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;aAC7B,CAAC,CAAC;QACJ,CAAC;QAED,qCAAqC;QACrC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO;QACR,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAEzB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC;CACD;AAtOD,wDAsOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { IDeltaManagerFull } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n} from \"@fluidframework/telemetry-utils/internal\";\n\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 ensures that we aggregate a complete batch of incoming ops before processing them. It basically ensures\n * that we never start processing ops in a batch IF we do not have all ops in the batch.\n */\nexport class InboundBatchAggregator {\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 updates and peek at the inbound\n\t\tthis.deltaManager.inbound.on(\"push\", this.trackPending);\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 an error when system ops\n\t\t// precedes start of incomplete batch.\n\t\tthis.deltaManager.on(\"op\", this.afterOpProcessing);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.deltaManager.off(\"op\", this.afterOpProcessing);\n\t\tthis.deltaManager.inbound.off(\"push\", this.trackPending);\n\t}\n\n\t/**\n\t * Callback for DeltaManager's \"op\" event, for us to make decision if op processing should\n\t * be paused or not after that.\n\t */\n\tprivate readonly afterOpProcessing = (message: ISequencedDocumentMessage): void => {\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\"InboundBatchAggregator\",\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\t/**\n\t * Called for each incoming op (i.e. inbound \"push\" notification)\n\t */\n\tprivate readonly trackPending = (message: ISequencedDocumentMessage): void => {\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\tprivate pauseQueue(): void {\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): void {\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"]}
1
+ {"version":3,"file":"inboundBatchAggregator.js","sourceRoot":"","sources":["../src/inboundBatchAggregator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA6D;AAE7D,oEAAyE;AACzE,uEAKkD;AAGlD,2DAAiD;AAQjD;;;GAGG;AACH,MAAa,sBAAsB;IAOlC,YACkB,YAA+B,EAC/B,WAAqC,EACrC,MAA2B;QAF3B,iBAAY,GAAZ,YAAY,CAAmB;QAC/B,gBAAW,GAAX,WAAW,CAA0B;QACrC,WAAM,GAAN,MAAM,CAAqB;QAPrC,gBAAW,GAAG,KAAK,CAAC;QACpB,eAAU,GAAG,CAAC,CAAC;QACf,eAAU,GAAG,CAAC,CAAC;QA0BvB;;;WAGG;QACc,sBAAiB,GAAG,CAAC,OAAkC,EAAQ,EAAE;YACjF,IAAA,iBAAM,EACL,CAAC,IAAI,CAAC,WAAW,EACjB,KAAK,CAAC,kEAAkE,CACxE,CAAC;YAEF,qDAAqD;YACrD,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5C,IAAA,iBAAM,EACL,IAAI,CAAC,mBAAmB,KAAK,SAAS,EACtC,KAAK,CAAC,0DAA0D,CAChE,CAAC;gBACF,OAAO;YACR,CAAC;YAED,eAAe;YACf,wGAAwG;YACxG,sEAAsE;YACtE,6EAA6E;YAC7E,yDAAyD;YAEzD,8CAA8C;YAC9C,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;gBAC5C,IAAI,OAAO,CAAC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,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;gBAC9B,SAAS,EAAE,YAAY;gBACvB,cAAc,EAAE,QAAQ;gBACxB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,CAAC;gBACjC,WAAW,EAAE,QAAQ,GAAG,eAAe,CAAC,qBAAqB;gBAC7D,QAAQ;gBACR,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;aAC7B,CAAC,CAAC;QACJ,CAAC;QAED,qCAAqC;QACrC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO;QACR,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAEzB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC;CACD;AAtOD,wDAsOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport { IDeltaManagerFull } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n} from \"@fluidframework/telemetry-utils/internal\";\n\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 ensures that we aggregate a complete batch of incoming ops before processing them. It basically ensures\n * that we never start processing ops in a batch IF we do not have all ops in the batch.\n */\nexport class InboundBatchAggregator {\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 updates and peek at the inbound\n\t\tthis.deltaManager.inbound.on(\"push\", this.trackPending);\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 an error when system ops\n\t\t// precedes start of incomplete batch.\n\t\tthis.deltaManager.on(\"op\", this.afterOpProcessing);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.deltaManager.off(\"op\", this.afterOpProcessing);\n\t\tthis.deltaManager.inbound.off(\"push\", this.trackPending);\n\t}\n\n\t/**\n\t * Callback for DeltaManager's \"op\" event, for us to make decision if op processing should\n\t * be paused or not after that.\n\t */\n\tprivate readonly afterOpProcessing = (message: ISequencedDocumentMessage): void => {\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\"InboundBatchAggregator\",\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\t/**\n\t * Called for each incoming op (i.e. inbound \"push\" notification)\n\t */\n\tprivate readonly trackPending = (message: ISequencedDocumentMessage): void => {\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\tprivate pauseQueue(): void {\n\t\tassert(!this.localPaused, 0x297 /* \"always called from resumed state\" */);\n\t\tthis.localPaused = true;\n\t\tthis.timePaused = performanceNow();\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): void {\n\t\tconst endBatch = messageEndBatch.sequenceNumber;\n\t\tconst duration = this.localPaused ? performanceNow() - 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"]}
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type ILayerCompatDetails, type ILayerCompatSupportRequirements } from "@fluid-internal/client-utils";
6
+ import type { ICriticalContainerError } from "@fluidframework/container-definitions";
7
+ /**
8
+ * Runtime's compatibility details that is exposed to the Loader layer.
9
+ */
10
+ export declare const RuntimeCompatDetails: ILayerCompatDetails;
11
+ /**
12
+ * The requirements that the Loader layer must meet to be compatible with this Runtime.
13
+ */
14
+ export declare const LoaderSupportRequirements: ILayerCompatSupportRequirements;
15
+ /**
16
+ * Validates that the Loader layer is compatible with this Runtime.
17
+ */
18
+ export declare function validateLoaderCompatibility(maybeLoaderCompatDetails: ILayerCompatDetails | undefined, disposeFn: (error?: ICriticalContainerError) => void): void;
19
+ //# sourceMappingURL=layerCompatState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layerCompatState.d.ts","sourceRoot":"","sources":["../src/layerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAKrF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,mBAalC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,+BAUvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,wBAAwB,EAAE,mBAAmB,GAAG,SAAS,EACzD,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,uBAAuB,KAAK,IAAI,GAClD,IAAI,CAoBN"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.validateLoaderCompatibility = exports.LoaderSupportRequirements = exports.RuntimeCompatDetails = void 0;
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
9
+ const internal_1 = require("@fluidframework/telemetry-utils/internal");
10
+ const packageVersion_js_1 = require("./packageVersion.js");
11
+ /**
12
+ * Runtime's compatibility details that is exposed to the Loader layer.
13
+ */
14
+ exports.RuntimeCompatDetails = {
15
+ /**
16
+ * The package version of the Runtime layer.
17
+ */
18
+ pkgVersion: packageVersion_js_1.pkgVersion,
19
+ /**
20
+ * The current generation of the Runtime layer.
21
+ */
22
+ generation: 1,
23
+ /**
24
+ * The features supported by the Runtime layer across the Runtime / Loader boundary.
25
+ */
26
+ supportedFeatures: new Set(),
27
+ };
28
+ /**
29
+ * The requirements that the Loader layer must meet to be compatible with this Runtime.
30
+ */
31
+ exports.LoaderSupportRequirements = {
32
+ /**
33
+ * Minimum generation that Loader must be at to be compatible with Runtime.
34
+ */
35
+ minSupportedGeneration: 0,
36
+ /**
37
+ * The features that the Loader must support to be compatible with Runtime. Note that 0 is used here for
38
+ * Loader layers before the introduction of the layer compatibility enforcement.
39
+ */
40
+ requiredFeatures: [],
41
+ };
42
+ /**
43
+ * Validates that the Loader layer is compatible with this Runtime.
44
+ */
45
+ function validateLoaderCompatibility(maybeLoaderCompatDetails, disposeFn) {
46
+ const layerCheckResult = (0, client_utils_1.checkLayerCompatibility)(exports.LoaderSupportRequirements, maybeLoaderCompatDetails);
47
+ if (!layerCheckResult.isCompatible) {
48
+ const error = new internal_1.UsageError("Runtime is not compatible with Loader", {
49
+ errorDetails: JSON.stringify({
50
+ runtimeVersion: exports.RuntimeCompatDetails.pkgVersion,
51
+ loaderVersion: maybeLoaderCompatDetails?.pkgVersion,
52
+ runtimeGeneration: exports.RuntimeCompatDetails.generation,
53
+ loaderGeneration: maybeLoaderCompatDetails?.generation,
54
+ minSupportedGeneration: exports.LoaderSupportRequirements.minSupportedGeneration,
55
+ isGenerationCompatible: layerCheckResult.isGenerationCompatible,
56
+ unsupportedFeatures: layerCheckResult.unsupportedFeatures,
57
+ }),
58
+ });
59
+ disposeFn(error);
60
+ throw error;
61
+ }
62
+ }
63
+ exports.validateLoaderCompatibility = validateLoaderCompatibility;
64
+ //# sourceMappingURL=layerCompatState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layerCompatState.js","sourceRoot":"","sources":["../src/layerCompatState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAIsC;AAEtC,uEAAsE;AAEtE,2DAAiD;AAEjD;;GAEG;AACU,QAAA,oBAAoB,GAAwB;IACxD;;OAEG;IACH,UAAU,EAAV,8BAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC;AAEF;;GAEG;AACU,QAAA,yBAAyB,GAAoC;IACzE;;OAEG;IACH,sBAAsB,EAAE,CAAC;IACzB;;;OAGG;IACH,gBAAgB,EAAE,EAAE;CACpB,CAAC;AAEF;;GAEG;AACH,SAAgB,2BAA2B,CAC1C,wBAAyD,EACzD,SAAoD;IAEpD,MAAM,gBAAgB,GAAG,IAAA,sCAAuB,EAC/C,iCAAyB,EACzB,wBAAwB,CACxB,CAAC;IACF,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,IAAI,qBAAU,CAAC,uCAAuC,EAAE;YACrE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;gBAC5B,cAAc,EAAE,4BAAoB,CAAC,UAAU;gBAC/C,aAAa,EAAE,wBAAwB,EAAE,UAAU;gBACnD,iBAAiB,EAAE,4BAAoB,CAAC,UAAU;gBAClD,gBAAgB,EAAE,wBAAwB,EAAE,UAAU;gBACtD,sBAAsB,EAAE,iCAAyB,CAAC,sBAAsB;gBACxE,sBAAsB,EAAE,gBAAgB,CAAC,sBAAsB;gBAC/D,mBAAmB,EAAE,gBAAgB,CAAC,mBAAmB;aACzD,CAAC;SACF,CAAC,CAAC;QACH,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC;AAvBD,kEAuBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tcheckLayerCompatibility,\n\ttype ILayerCompatDetails,\n\ttype ILayerCompatSupportRequirements,\n} from \"@fluid-internal/client-utils\";\nimport type { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Runtime's compatibility details that is exposed to the Loader layer.\n */\nexport const RuntimeCompatDetails: ILayerCompatDetails = {\n\t/**\n\t * The package version of the Runtime layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the Runtime layer.\n\t */\n\tgeneration: 1,\n\t/**\n\t * The features supported by the Runtime layer across the Runtime / Loader boundary.\n\t */\n\tsupportedFeatures: new Set<string>(),\n};\n\n/**\n * The requirements that the Loader layer must meet to be compatible with this Runtime.\n */\nexport const LoaderSupportRequirements: ILayerCompatSupportRequirements = {\n\t/**\n\t * Minimum generation that Loader must be at to be compatible with Runtime.\n\t */\n\tminSupportedGeneration: 0,\n\t/**\n\t * The features that the Loader must support to be compatible with Runtime. Note that 0 is used here for\n\t * Loader layers before the introduction of the layer compatibility enforcement.\n\t */\n\trequiredFeatures: [],\n};\n\n/**\n * Validates that the Loader layer is compatible with this Runtime.\n */\nexport function validateLoaderCompatibility(\n\tmaybeLoaderCompatDetails: ILayerCompatDetails | undefined,\n\tdisposeFn: (error?: ICriticalContainerError) => void,\n): void {\n\tconst layerCheckResult = checkLayerCompatibility(\n\t\tLoaderSupportRequirements,\n\t\tmaybeLoaderCompatDetails,\n\t);\n\tif (!layerCheckResult.isCompatible) {\n\t\tconst error = new UsageError(\"Runtime is not compatible with Loader\", {\n\t\t\terrorDetails: JSON.stringify({\n\t\t\t\truntimeVersion: RuntimeCompatDetails.pkgVersion,\n\t\t\t\tloaderVersion: maybeLoaderCompatDetails?.pkgVersion,\n\t\t\t\truntimeGeneration: RuntimeCompatDetails.generation,\n\t\t\t\tloaderGeneration: maybeLoaderCompatDetails?.generation,\n\t\t\t\tminSupportedGeneration: LoaderSupportRequirements.minSupportedGeneration,\n\t\t\t\tisGenerationCompatible: layerCheckResult.isGenerationCompatible,\n\t\t\t\tunsupportedFeatures: layerCheckResult.unsupportedFeatures,\n\t\t\t}),\n\t\t});\n\t\tdisposeFn(error);\n\t\tthrow error;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../src/messageTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EACN,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CA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,UAAU,CACnB,GACA,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"messageTypes.js","sourceRoot":"","sources":["../src/messageTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH;;;GAGG;AACH,IAAY,oBAoCX;AApCD,WAAY,oBAAoB;IAC/B,iCAAiC;IACjC,sDAA8B,CAAA;IAE9B,sBAAsB;IACtB,yCAAiB,CAAA;IAEjB,qBAAqB;IACrB,+CAAuB,CAAA;IAEvB,yFAAyF;IACzF,iDAAyB,CAAA;IAEzB,oDAAoD;IACpD,yCAAiB,CAAA;IAEjB,sCAAsC;IACtC,uCAAe,CAAA;IAEf;;;;OAIG;IACH,qDAA6B,CAAA;IAE7B;;OAEG;IACH,uDAA+B,CAAA;IAE/B;;;OAGG;IACH,iCAAS,CAAA;AACV,CAAC,EApCW,oBAAoB,oCAApB,oBAAoB,QAoC/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type { IdCreationRange } from \"@fluidframework/id-compressor/internal\";\nimport {\n\tIAttachMessage,\n\tIEnvelope,\n\tInboundAttachMessage,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { IDataStoreAliasMessage } from \"./dataStore.js\";\nimport { GarbageCollectionMessage } from \"./gc/index.js\";\nimport { IChunkedOp } from \"./opLifecycle/index.js\";\nimport { IDocumentSchemaChangeMessage } from \"./summary/index.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport enum ContainerMessageType {\n\t// An op to be delivered to store\n\tFluidDataStoreOp = \"component\",\n\n\t// Creates a new store\n\tAttach = \"attach\",\n\n\t// Chunked operation.\n\tChunkedOp = \"chunkedOp\",\n\n\t// Signifies that a blob has been attached and should not be garbage collected by storage\n\tBlobAttach = \"blobAttach\",\n\n\t// Ties our new clientId to our old one on reconnect\n\tRejoin = \"rejoin\",\n\n\t// Sets the alias of a root data store\n\tAlias = \"alias\",\n\n\t/**\n\t * An op containing an IdRange of Ids allocated using the runtime's IdCompressor since\n\t * the last allocation op was sent.\n\t * See the [IdCompressor README](./id-compressor/README.md) for more details.\n\t */\n\tIdAllocation = \"idAllocation\",\n\n\t/**\n\t * An op that changes document schema\n\t */\n\tDocumentSchemaChange = \"schema\",\n\n\t/**\n\t * Garbage collection specific op. This is sent by the summarizer client when GC runs. It's used to synchronize GC\n\t * state across all clients.\n\t */\n\tGC = \"GC\",\n}\n\n/**\n * The unpacked runtime message / details to be handled or dispatched by the ContainerRuntime.\n * Message type are differentiated via a `type` string and contain different contents depending on their type.\n *\n * IMPORTANT: when creating one to be serialized, set the properties in the order they appear here.\n * This way stringified values can be compared.\n */\ninterface TypedContainerRuntimeMessage<TType extends ContainerMessageType, TContents> {\n\t/**\n\t * Type of the op, within the ContainerRuntime's domain\n\t */\n\ttype: TType;\n\t/**\n\t * Domain-specific contents, interpreted according to the type\n\t */\n\tcontents: TContents;\n}\n\nexport type ContainerRuntimeDataStoreOpMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.FluidDataStoreOp,\n\tIEnvelope\n>;\nexport type InboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Attach,\n\tInboundAttachMessage\n>;\nexport type OutboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Attach,\n\tIAttachMessage\n>;\nexport type ContainerRuntimeChunkedOpMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.ChunkedOp,\n\tIChunkedOp\n>;\nexport type ContainerRuntimeBlobAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.BlobAttach,\n\tundefined\n>;\nexport type ContainerRuntimeRejoinMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Rejoin,\n\tundefined\n>;\nexport type ContainerRuntimeAliasMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Alias,\n\tIDataStoreAliasMessage\n>;\nexport type ContainerRuntimeIdAllocationMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.IdAllocation,\n\tIdCreationRange\n>;\nexport type ContainerRuntimeGCMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.GC,\n\tGarbageCollectionMessage\n>;\nexport type ContainerRuntimeDocumentSchemaMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.DocumentSchemaChange,\n\tIDocumentSchemaChangeMessage\n>;\n\n/**\n * Represents an unrecognized TypedContainerRuntimeMessage, e.g. a message from a future version of the container runtime.\n * @internal\n */\nexport interface UnknownContainerRuntimeMessage {\n\t/**\n\t * Invalid type of the op, within the ContainerRuntime's domain. This value should never exist at runtime.\n\t * This is useful for type narrowing but should never be used as an actual message type at runtime.\n\t * Actual value will not be \"__unknown...\", but the type `Exclude<string, ContainerMessageType>` is not supported.\n\t */\n\ttype: \"__unknown_container_message_type__never_use_as_value__\";\n\n\t/**\n\t * Domain-specific contents, but not decipherable by an unknown op.\n\t */\n\tcontents: unknown;\n}\n\n/**\n * A {@link TypedContainerRuntimeMessage} that is received from the server and will be processed by the container runtime.\n */\nexport type InboundContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| InboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t| ContainerRuntimeGCMessage\n\t// Inbound messages may include unknown types from other clients, so we include that as a special case here\n\t| UnknownContainerRuntimeMessage\n\t| ContainerRuntimeDocumentSchemaMessage;\n\n/**\n * A {@link TypedContainerRuntimeMessage} that has been generated by the container runtime but is not yet being sent to the server.\n * These are messages generated by the local runtime, before the outbox's op virtualization step.\n */\nexport type LocalContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| OutboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t| ContainerRuntimeGCMessage\n\t// In rare cases (e.g. related to stashed ops) we could have a local message of an unknown type\n\t| UnknownContainerRuntimeMessage\n\t| ContainerRuntimeDocumentSchemaMessage;\n\n/**\n * A {@link TypedContainerRuntimeMessage} that is being sent to the server from the container runtime.\n */\nexport type OutboundContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| OutboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t| ContainerRuntimeGCMessage\n\t| ContainerRuntimeDocumentSchemaMessage;\n\n/**\n * An unpacked ISequencedDocumentMessage with the inner TypedContainerRuntimeMessage type/contents/etc\n * promoted up to the outer object\n */\nexport type InboundSequencedContainerRuntimeMessage = Omit<\n\tISequencedDocumentMessage,\n\t\"type\" | \"contents\"\n> &\n\tInboundContainerRuntimeMessage;\n"]}
1
+ {"version":3,"file":"messageTypes.js","sourceRoot":"","sources":["../src/messageTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH;;;GAGG;AACH,IAAY,oBAoCX;AApCD,WAAY,oBAAoB;IAC/B,iCAAiC;IACjC,sDAA8B,CAAA;IAE9B,sBAAsB;IACtB,yCAAiB,CAAA;IAEjB,qBAAqB;IACrB,+CAAuB,CAAA;IAEvB,yFAAyF;IACzF,iDAAyB,CAAA;IAEzB,oDAAoD;IACpD,yCAAiB,CAAA;IAEjB,sCAAsC;IACtC,uCAAe,CAAA;IAEf;;;;OAIG;IACH,qDAA6B,CAAA;IAE7B;;OAEG;IACH,uDAA+B,CAAA;IAE/B;;;OAGG;IACH,iCAAS,CAAA;AACV,CAAC,EApCW,oBAAoB,oCAApB,oBAAoB,QAoC/B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type { IdCreationRange } from \"@fluidframework/id-compressor/internal\";\nimport {\n\tIAttachMessage,\n\tIEnvelope,\n\tInboundAttachMessage,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { IDataStoreAliasMessage } from \"./dataStore.js\";\nimport { GarbageCollectionMessage } from \"./gc/index.js\";\nimport { IChunkedOp } from \"./opLifecycle/index.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { IDocumentSchemaChangeMessage } from \"./summary/index.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport enum ContainerMessageType {\n\t// An op to be delivered to store\n\tFluidDataStoreOp = \"component\",\n\n\t// Creates a new store\n\tAttach = \"attach\",\n\n\t// Chunked operation.\n\tChunkedOp = \"chunkedOp\",\n\n\t// Signifies that a blob has been attached and should not be garbage collected by storage\n\tBlobAttach = \"blobAttach\",\n\n\t// Ties our new clientId to our old one on reconnect\n\tRejoin = \"rejoin\",\n\n\t// Sets the alias of a root data store\n\tAlias = \"alias\",\n\n\t/**\n\t * An op containing an IdRange of Ids allocated using the runtime's IdCompressor since\n\t * the last allocation op was sent.\n\t * See the [IdCompressor README](./id-compressor/README.md) for more details.\n\t */\n\tIdAllocation = \"idAllocation\",\n\n\t/**\n\t * An op that changes document schema\n\t */\n\tDocumentSchemaChange = \"schema\",\n\n\t/**\n\t * Garbage collection specific op. This is sent by the summarizer client when GC runs. It's used to synchronize GC\n\t * state across all clients.\n\t */\n\tGC = \"GC\",\n}\n\n/**\n * The unpacked runtime message / details to be handled or dispatched by the ContainerRuntime.\n * Message type are differentiated via a `type` string and contain different contents depending on their type.\n *\n * IMPORTANT: when creating one to be serialized, set the properties in the order they appear here.\n * This way stringified values can be compared.\n */\ninterface TypedContainerRuntimeMessage<TType extends ContainerMessageType, TContents> {\n\t/**\n\t * Type of the op, within the ContainerRuntime's domain\n\t */\n\ttype: TType;\n\t/**\n\t * Domain-specific contents, interpreted according to the type\n\t */\n\tcontents: TContents;\n}\n\nexport type ContainerRuntimeDataStoreOpMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.FluidDataStoreOp,\n\tIEnvelope\n>;\nexport type InboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Attach,\n\tInboundAttachMessage\n>;\nexport type OutboundContainerRuntimeAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Attach,\n\tIAttachMessage\n>;\nexport type ContainerRuntimeChunkedOpMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.ChunkedOp,\n\tIChunkedOp\n>;\nexport type ContainerRuntimeBlobAttachMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.BlobAttach,\n\tundefined\n>;\nexport type ContainerRuntimeRejoinMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Rejoin,\n\tundefined\n>;\nexport type ContainerRuntimeAliasMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.Alias,\n\tIDataStoreAliasMessage\n>;\nexport type ContainerRuntimeIdAllocationMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.IdAllocation,\n\tIdCreationRange\n>;\nexport type ContainerRuntimeGCMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.GC,\n\tGarbageCollectionMessage\n>;\nexport type ContainerRuntimeDocumentSchemaMessage = TypedContainerRuntimeMessage<\n\tContainerMessageType.DocumentSchemaChange,\n\t// eslint-disable-next-line import/no-deprecated\n\tIDocumentSchemaChangeMessage\n>;\n\n/**\n * Represents an unrecognized TypedContainerRuntimeMessage, e.g. a message from a future version of the container runtime.\n * @internal\n */\nexport interface UnknownContainerRuntimeMessage {\n\t/**\n\t * Invalid type of the op, within the ContainerRuntime's domain. This value should never exist at runtime.\n\t * This is useful for type narrowing but should never be used as an actual message type at runtime.\n\t * Actual value will not be \"__unknown...\", but the type `Exclude<string, ContainerMessageType>` is not supported.\n\t */\n\ttype: \"__unknown_container_message_type__never_use_as_value__\";\n\n\t/**\n\t * Domain-specific contents, but not decipherable by an unknown op.\n\t */\n\tcontents: unknown;\n}\n\n/**\n * A {@link TypedContainerRuntimeMessage} that is received from the server and will be processed by the container runtime.\n */\nexport type InboundContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| InboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t| ContainerRuntimeGCMessage\n\t// Inbound messages may include unknown types from other clients, so we include that as a special case here\n\t| UnknownContainerRuntimeMessage\n\t| ContainerRuntimeDocumentSchemaMessage;\n\n/**\n * A {@link TypedContainerRuntimeMessage} that has been generated by the container runtime but is not yet being sent to the server.\n * These are messages generated by the local runtime, before the outbox's op virtualization step.\n */\nexport type LocalContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| OutboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t| ContainerRuntimeGCMessage\n\t// In rare cases (e.g. related to stashed ops) we could have a local message of an unknown type\n\t| UnknownContainerRuntimeMessage\n\t| ContainerRuntimeDocumentSchemaMessage;\n\n/**\n * A {@link TypedContainerRuntimeMessage} that is being sent to the server from the container runtime.\n */\nexport type OutboundContainerRuntimeMessage =\n\t| ContainerRuntimeDataStoreOpMessage\n\t| OutboundContainerRuntimeAttachMessage\n\t| ContainerRuntimeChunkedOpMessage\n\t| ContainerRuntimeBlobAttachMessage\n\t| ContainerRuntimeRejoinMessage\n\t| ContainerRuntimeAliasMessage\n\t| ContainerRuntimeIdAllocationMessage\n\t| ContainerRuntimeGCMessage\n\t| ContainerRuntimeDocumentSchemaMessage;\n\n/**\n * An unpacked ISequencedDocumentMessage with the inner TypedContainerRuntimeMessage type/contents/etc\n * promoted up to the outer object\n */\nexport type InboundSequencedContainerRuntimeMessage = Omit<\n\tISequencedDocumentMessage,\n\t\"type\" | \"contents\"\n> &\n\tInboundContainerRuntimeMessage;\n"]}
@@ -69,12 +69,12 @@ class DuplicateBatchDetector {
69
69
  * since the batch start has been processed by all clients, and local batches are deduped and the forked client would close.
70
70
  */
71
71
  clearOldBatchIds(msn) {
72
- this.batchIdsBySeqNum.forEach((batchId, sequenceNumber) => {
72
+ for (const [sequenceNumber, batchId] of this.batchIdsBySeqNum) {
73
73
  if (sequenceNumber < msn) {
74
74
  this.batchIdsBySeqNum.delete(sequenceNumber);
75
75
  this.batchIdsAll.delete(batchId);
76
76
  }
77
- });
77
+ }
78
78
  }
79
79
  /**
80
80
  * Returns a snapshot of the state of the detector which can be included in a summary
@@ -1 +1 @@
1
- {"version":3,"file":"duplicateBatchDetector.js","sourceRoot":"","sources":["../../src/opLifecycle/duplicateBatchDetector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,uDAAwD;AAGxD;;GAEG;AACH,MAAa,sBAAsB;IAWlC;;OAEG;IACH,YAAY,oBAAoD;QAbhE;;WAEG;QACc,gBAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjD;;WAEG;QACc,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAM7D,IAAI,oBAAoB,EAAE,CAAC;YAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACtD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACI,mBAAmB,CACzB,UAA0B;QAE1B,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,GAAG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,MAAM,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,4BAA4B,CAClC,gBAAoC;QAEpC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,gBAAgB,EAAE,GAAG,CACpB,+BAA+B,EAC/B,kBAAkB,EAClB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAC1B,CAAC;QAEF,OAAO,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACD;AAtGD,wDAsGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ITelemetryContext } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { getEffectiveBatchId } from \"./batchManager.js\";\nimport { type BatchStartInfo } from \"./remoteMessageProcessor.js\";\n\n/**\n * This class tracks recent batchIds we've seen, and checks incoming batches for duplicates.\n */\nexport class DuplicateBatchDetector {\n\t/**\n\t * All batchIds we've seen recently enough (based on MSN) that we need to watch for duplicates\n\t */\n\tprivate readonly batchIdsAll = new Set<string>();\n\n\t/**\n\t * We map from sequenceNumber to batchId to find which ones we can stop tracking as MSN advances\n\t */\n\tprivate readonly batchIdsBySeqNum = new Map<number, string>();\n\n\t/**\n\t * Initialize from snapshot data if provided - otherwise initialize empty\n\t */\n\tconstructor(batchIdsFromSnapshot: [number, string][] | undefined) {\n\t\tif (batchIdsFromSnapshot) {\n\t\t\tthis.batchIdsBySeqNum = new Map(batchIdsFromSnapshot);\n\t\t\tfor (const batchId of this.batchIdsBySeqNum.values()) {\n\t\t\t\tthis.batchIdsAll.add(batchId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Records this batch's batchId, and checks if it's a duplicate of a batch we've already seen.\n\t * If it's a duplicate, also return the sequence number of the other batch for logging.\n\t *\n\t * @remarks - We also use the minimumSequenceNumber to clear out old batchIds that are no longer at risk for duplicates.\n\t */\n\tpublic processInboundBatch(\n\t\tbatchStart: BatchStartInfo,\n\t): { duplicate: true; otherSequenceNumber: number } | { duplicate: false } {\n\t\tconst { sequenceNumber, minimumSequenceNumber } = batchStart.keyMessage;\n\n\t\t// Glance at this batch's MSN. Any batchIds we're tracking with a lower sequence number are now safe to forget.\n\t\t// Why? Because any other client holding the same batch locally would have seen the earlier batch and closed before submitting its duplicate.\n\t\tthis.clearOldBatchIds(minimumSequenceNumber);\n\n\t\t// getEffectiveBatchId is only needed in the SUPER rare/surprising case where\n\t\t// the original batch (not resubmitted, so no batchId) arrives in parallel with a resubmitted batch.\n\t\t// In the presence of typical network conditions, this would not be possible\n\t\t// (the original batch should roundtrip WAY before another container could rehydrate, connect, and resubmit)\n\t\tconst batchId = getEffectiveBatchId(batchStart);\n\n\t\t// Check this batch against the tracked batchIds to see if it's a duplicate\n\t\tif (this.batchIdsAll.has(batchId)) {\n\t\t\tfor (const [otherSequenceNumber, otherBatchId] of this.batchIdsBySeqNum.entries()) {\n\t\t\t\tif (otherBatchId === batchId) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tduplicate: true,\n\t\t\t\t\t\totherSequenceNumber,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tassert(false, 0xa34 /* Should have found the batchId in batchIdBySeqNum map */);\n\t\t}\n\n\t\t// Now we know it's not a duplicate, so add it to the tracked batchIds and return.\n\t\tassert(\n\t\t\t!this.batchIdsBySeqNum.has(sequenceNumber),\n\t\t\t0xa35 /* batchIdsAll and batchIdsBySeqNum should be in sync */,\n\t\t);\n\t\tthis.batchIdsBySeqNum.set(sequenceNumber, batchId);\n\t\tthis.batchIdsAll.add(batchId);\n\n\t\treturn { duplicate: false };\n\t}\n\n\t/**\n\t * Batches that started before the MSN are not at risk for a sequenced duplicate to arrive,\n\t * since the batch start has been processed by all clients, and local batches are deduped and the forked client would close.\n\t */\n\tprivate clearOldBatchIds(msn: number): void {\n\t\tthis.batchIdsBySeqNum.forEach((batchId, sequenceNumber) => {\n\t\t\tif (sequenceNumber < msn) {\n\t\t\t\tthis.batchIdsBySeqNum.delete(sequenceNumber);\n\t\t\t\tthis.batchIdsAll.delete(batchId);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Returns a snapshot of the state of the detector which can be included in a summary\n\t * and used to \"rehydrate\" this class when loading from a snapshot.\n\t *\n\t * @returns - A serializable object representing the state of the detector, or undefined if there is nothing to save.\n\t */\n\tpublic getRecentBatchInfoForSummary(\n\t\ttelemetryContext?: ITelemetryContext,\n\t): [number, string][] | undefined {\n\t\tif (this.batchIdsBySeqNum.size === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\ttelemetryContext?.set(\n\t\t\t\"fluid_DuplicateBatchDetector_\",\n\t\t\t\"recentBatchCount\",\n\t\t\tthis.batchIdsBySeqNum.size,\n\t\t);\n\n\t\treturn [...this.batchIdsBySeqNum.entries()];\n\t}\n}\n"]}
1
+ {"version":3,"file":"duplicateBatchDetector.js","sourceRoot":"","sources":["../../src/opLifecycle/duplicateBatchDetector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,uDAAwD;AAGxD;;GAEG;AACH,MAAa,sBAAsB;IAWlC;;OAEG;IACH,YAAY,oBAAoD;QAbhE;;WAEG;QACc,gBAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjD;;WAEG;QACc,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAM7D,IAAI,oBAAoB,EAAE,CAAC;YAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACtD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,WAAW,CAA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,CAAC,gBAAgB,EAAE,CAAC;YAC/D,IAAI,cAAc,GAAG,GAAG,EAAE,CAAC;gBAC1B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;gBAC7C,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACI,4BAA4B,CAClC,gBAAoC;QAEpC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,gBAAgB,EAAE,GAAG,CACpB,+BAA+B,EAC/B,kBAAkB,EAClB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAC1B,CAAC;QAEF,OAAO,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACD;AAtGD,wDAsGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ITelemetryContext } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { getEffectiveBatchId } from \"./batchManager.js\";\nimport { type BatchStartInfo } from \"./remoteMessageProcessor.js\";\n\n/**\n * This class tracks recent batchIds we've seen, and checks incoming batches for duplicates.\n */\nexport class DuplicateBatchDetector {\n\t/**\n\t * All batchIds we've seen recently enough (based on MSN) that we need to watch for duplicates\n\t */\n\tprivate readonly batchIdsAll = new Set<string>();\n\n\t/**\n\t * We map from sequenceNumber to batchId to find which ones we can stop tracking as MSN advances\n\t */\n\tprivate readonly batchIdsBySeqNum = new Map<number, string>();\n\n\t/**\n\t * Initialize from snapshot data if provided - otherwise initialize empty\n\t */\n\tconstructor(batchIdsFromSnapshot: [number, string][] | undefined) {\n\t\tif (batchIdsFromSnapshot) {\n\t\t\tthis.batchIdsBySeqNum = new Map(batchIdsFromSnapshot);\n\t\t\tfor (const batchId of this.batchIdsBySeqNum.values()) {\n\t\t\t\tthis.batchIdsAll.add(batchId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Records this batch's batchId, and checks if it's a duplicate of a batch we've already seen.\n\t * If it's a duplicate, also return the sequence number of the other batch for logging.\n\t *\n\t * @remarks - We also use the minimumSequenceNumber to clear out old batchIds that are no longer at risk for duplicates.\n\t */\n\tpublic processInboundBatch(\n\t\tbatchStart: BatchStartInfo,\n\t): { duplicate: true; otherSequenceNumber: number } | { duplicate: false } {\n\t\tconst { sequenceNumber, minimumSequenceNumber } = batchStart.keyMessage;\n\n\t\t// Glance at this batch's MSN. Any batchIds we're tracking with a lower sequence number are now safe to forget.\n\t\t// Why? Because any other client holding the same batch locally would have seen the earlier batch and closed before submitting its duplicate.\n\t\tthis.clearOldBatchIds(minimumSequenceNumber);\n\n\t\t// getEffectiveBatchId is only needed in the SUPER rare/surprising case where\n\t\t// the original batch (not resubmitted, so no batchId) arrives in parallel with a resubmitted batch.\n\t\t// In the presence of typical network conditions, this would not be possible\n\t\t// (the original batch should roundtrip WAY before another container could rehydrate, connect, and resubmit)\n\t\tconst batchId = getEffectiveBatchId(batchStart);\n\n\t\t// Check this batch against the tracked batchIds to see if it's a duplicate\n\t\tif (this.batchIdsAll.has(batchId)) {\n\t\t\tfor (const [otherSequenceNumber, otherBatchId] of this.batchIdsBySeqNum.entries()) {\n\t\t\t\tif (otherBatchId === batchId) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tduplicate: true,\n\t\t\t\t\t\totherSequenceNumber,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tassert(false, 0xa34 /* Should have found the batchId in batchIdBySeqNum map */);\n\t\t}\n\n\t\t// Now we know it's not a duplicate, so add it to the tracked batchIds and return.\n\t\tassert(\n\t\t\t!this.batchIdsBySeqNum.has(sequenceNumber),\n\t\t\t0xa35 /* batchIdsAll and batchIdsBySeqNum should be in sync */,\n\t\t);\n\t\tthis.batchIdsBySeqNum.set(sequenceNumber, batchId);\n\t\tthis.batchIdsAll.add(batchId);\n\n\t\treturn { duplicate: false };\n\t}\n\n\t/**\n\t * Batches that started before the MSN are not at risk for a sequenced duplicate to arrive,\n\t * since the batch start has been processed by all clients, and local batches are deduped and the forked client would close.\n\t */\n\tprivate clearOldBatchIds(msn: number): void {\n\t\tfor (const [sequenceNumber, batchId] of this.batchIdsBySeqNum) {\n\t\t\tif (sequenceNumber < msn) {\n\t\t\t\tthis.batchIdsBySeqNum.delete(sequenceNumber);\n\t\t\t\tthis.batchIdsAll.delete(batchId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns a snapshot of the state of the detector which can be included in a summary\n\t * and used to \"rehydrate\" this class when loading from a snapshot.\n\t *\n\t * @returns - A serializable object representing the state of the detector, or undefined if there is nothing to save.\n\t */\n\tpublic getRecentBatchInfoForSummary(\n\t\ttelemetryContext?: ITelemetryContext,\n\t): [number, string][] | undefined {\n\t\tif (this.batchIdsBySeqNum.size === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\ttelemetryContext?.set(\n\t\t\t\"fluid_DuplicateBatchDetector_\",\n\t\t\t\"recentBatchCount\",\n\t\t\tthis.batchIdsBySeqNum.size,\n\t\t);\n\n\t\treturn [...this.batchIdsBySeqNum.entries()];\n\t}\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
6
- import { IBatch } from "./definitions.js";
6
+ import { BatchMessage, IBatch } from "./definitions.js";
7
7
  /**
8
8
  * Compresses batches of ops. It generates a single compressed op that contains
9
9
  * the contents of each op in the batch. It then submits empty ops for each original
@@ -16,10 +16,11 @@ export declare class OpCompressor {
16
16
  * Combines the contents of the batch into a single JSON string and compresses it, putting
17
17
  * the resulting string as the first message of the batch. The rest of the messages are
18
18
  * empty placeholders to reserve sequence numbers.
19
+ * This should only take a single message batch and compress it.
19
20
  * @param batch - The batch to compress
20
21
  * @returns A batch of the same length as the input batch, containing a single compressed message followed by empty placeholders
21
22
  */
22
- compressBatch(batch: IBatch): IBatch;
23
+ compressBatch(batch: IBatch): IBatch<[BatchMessage]>;
23
24
  /**
24
25
  * Combine the batch's content strings into a single JSON string (a serialized array)
25
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"opCompressor.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/opCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAYvE,OAAO,EAAgB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;GAIG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAEjC,MAAM,EAAE,oBAAoB;IAIxC;;;;;;OAMG;IACI,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAiD3C;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAuB9B"}
1
+ {"version":3,"file":"opCompressor.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/opCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAYvE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;GAIG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAEjC,MAAM,EAAE,oBAAoB;IAIxC;;;;;;;OAOG;IACI,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAyC3D;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAuB9B"}