@fluidframework/container-runtime 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191258

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 (526) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/README.md +4 -3
  3. package/dist/batchTracker.d.ts +3 -2
  4. package/dist/batchTracker.d.ts.map +1 -1
  5. package/dist/batchTracker.js +6 -5
  6. package/dist/batchTracker.js.map +1 -1
  7. package/dist/blobManager.d.ts +10 -16
  8. package/dist/blobManager.d.ts.map +1 -1
  9. package/dist/blobManager.js +184 -172
  10. package/dist/blobManager.js.map +1 -1
  11. package/dist/connectionTelemetry.d.ts.map +1 -1
  12. package/dist/connectionTelemetry.js +25 -16
  13. package/dist/connectionTelemetry.js.map +1 -1
  14. package/dist/containerRuntime.d.ts +161 -35
  15. package/dist/containerRuntime.d.ts.map +1 -1
  16. package/dist/containerRuntime.js +697 -449
  17. package/dist/containerRuntime.js.map +1 -1
  18. package/dist/dataStore.d.ts.map +1 -1
  19. package/dist/dataStore.js +15 -7
  20. package/dist/dataStore.js.map +1 -1
  21. package/dist/dataStoreContext.d.ts +3 -2
  22. package/dist/dataStoreContext.d.ts.map +1 -1
  23. package/dist/dataStoreContext.js +83 -87
  24. package/dist/dataStoreContext.js.map +1 -1
  25. package/dist/dataStoreContexts.d.ts +1 -2
  26. package/dist/dataStoreContexts.d.ts.map +1 -1
  27. package/dist/dataStoreContexts.js +8 -9
  28. package/dist/dataStoreContexts.js.map +1 -1
  29. package/dist/dataStoreRegistry.js +2 -2
  30. package/dist/dataStoreRegistry.js.map +1 -1
  31. package/dist/dataStores.d.ts +22 -6
  32. package/dist/dataStores.d.ts.map +1 -1
  33. package/dist/dataStores.js +123 -81
  34. package/dist/dataStores.js.map +1 -1
  35. package/dist/deltaManagerProxyBase.d.ts +35 -0
  36. package/dist/deltaManagerProxyBase.d.ts.map +1 -0
  37. package/dist/deltaManagerProxyBase.js +77 -0
  38. package/dist/deltaManagerProxyBase.js.map +1 -0
  39. package/dist/deltaManagerSummarizerProxy.d.ts +1 -1
  40. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
  41. package/dist/deltaManagerSummarizerProxy.js +4 -2
  42. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  43. package/dist/deltaScheduler.d.ts.map +1 -1
  44. package/dist/deltaScheduler.js +10 -10
  45. package/dist/deltaScheduler.js.map +1 -1
  46. package/dist/error.d.ts +14 -0
  47. package/dist/error.d.ts.map +1 -0
  48. package/dist/error.js +21 -0
  49. package/dist/error.js.map +1 -0
  50. package/dist/gc/garbageCollection.d.ts +10 -9
  51. package/dist/gc/garbageCollection.d.ts.map +1 -1
  52. package/dist/gc/garbageCollection.js +61 -53
  53. package/dist/gc/garbageCollection.js.map +1 -1
  54. package/dist/gc/gcConfigs.d.ts.map +1 -1
  55. package/dist/gc/gcConfigs.js +18 -14
  56. package/dist/gc/gcConfigs.js.map +1 -1
  57. package/dist/gc/gcDefinitions.d.ts +17 -4
  58. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  59. package/dist/gc/gcDefinitions.js +14 -15
  60. package/dist/gc/gcDefinitions.js.map +1 -1
  61. package/dist/gc/gcHelpers.d.ts +0 -8
  62. package/dist/gc/gcHelpers.d.ts.map +1 -1
  63. package/dist/gc/gcHelpers.js +11 -24
  64. package/dist/gc/gcHelpers.js.map +1 -1
  65. package/dist/gc/gcSummaryStateTracker.d.ts +4 -7
  66. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  67. package/dist/gc/gcSummaryStateTracker.js +19 -58
  68. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  69. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  70. package/dist/gc/gcTelemetry.js +45 -35
  71. package/dist/gc/gcTelemetry.js.map +1 -1
  72. package/dist/gc/gcUnreferencedStateTracker.js +4 -4
  73. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  74. package/dist/gc/index.d.ts +2 -2
  75. package/dist/gc/index.d.ts.map +1 -1
  76. package/dist/gc/index.js +3 -5
  77. package/dist/gc/index.js.map +1 -1
  78. package/dist/id-compressor/appendOnlySortedMap.d.ts +8 -30
  79. package/dist/id-compressor/appendOnlySortedMap.d.ts.map +1 -1
  80. package/dist/id-compressor/appendOnlySortedMap.js +26 -68
  81. package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
  82. package/dist/id-compressor/finalSpace.d.ts +29 -0
  83. package/dist/id-compressor/finalSpace.d.ts.map +1 -0
  84. package/dist/id-compressor/finalSpace.js +62 -0
  85. package/dist/id-compressor/finalSpace.js.map +1 -0
  86. package/dist/id-compressor/idCompressor.d.ts +25 -250
  87. package/dist/id-compressor/idCompressor.d.ts.map +1 -1
  88. package/dist/id-compressor/idCompressor.js +390 -1153
  89. package/dist/id-compressor/idCompressor.js.map +1 -1
  90. package/dist/id-compressor/identifiers.d.ts +32 -0
  91. package/dist/id-compressor/identifiers.d.ts.map +1 -0
  92. package/dist/id-compressor/identifiers.js +15 -0
  93. package/dist/id-compressor/identifiers.js.map +1 -0
  94. package/dist/id-compressor/index.d.ts +5 -6
  95. package/dist/id-compressor/index.d.ts.map +1 -1
  96. package/dist/id-compressor/index.js +20 -26
  97. package/dist/id-compressor/index.js.map +1 -1
  98. package/dist/id-compressor/persistanceUtilities.d.ts +22 -0
  99. package/dist/id-compressor/persistanceUtilities.d.ts.map +1 -0
  100. package/dist/id-compressor/persistanceUtilities.js +43 -0
  101. package/dist/id-compressor/persistanceUtilities.js.map +1 -0
  102. package/dist/id-compressor/sessionSpaceNormalizer.d.ts +46 -0
  103. package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +1 -0
  104. package/dist/id-compressor/sessionSpaceNormalizer.js +80 -0
  105. package/dist/id-compressor/sessionSpaceNormalizer.js.map +1 -0
  106. package/dist/id-compressor/sessions.d.ts +115 -0
  107. package/dist/id-compressor/sessions.d.ts.map +1 -0
  108. package/dist/id-compressor/sessions.js +305 -0
  109. package/dist/id-compressor/sessions.js.map +1 -0
  110. package/dist/id-compressor/utilities.d.ts +49 -0
  111. package/dist/id-compressor/utilities.d.ts.map +1 -0
  112. package/dist/id-compressor/utilities.js +166 -0
  113. package/dist/id-compressor/utilities.js.map +1 -0
  114. package/dist/index.d.ts +3 -3
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +6 -4
  117. package/dist/index.js.map +1 -1
  118. package/dist/opLifecycle/batchManager.js +10 -6
  119. package/dist/opLifecycle/batchManager.js.map +1 -1
  120. package/dist/opLifecycle/opCompressor.d.ts +2 -2
  121. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  122. package/dist/opLifecycle/opCompressor.js +12 -7
  123. package/dist/opLifecycle/opCompressor.js.map +1 -1
  124. package/dist/opLifecycle/opDecompressor.d.ts +2 -2
  125. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  126. package/dist/opLifecycle/opDecompressor.js +23 -20
  127. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  128. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  129. package/dist/opLifecycle/opGroupingManager.js +19 -9
  130. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  131. package/dist/opLifecycle/opSplitter.d.ts +2 -2
  132. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  133. package/dist/opLifecycle/opSplitter.js +22 -19
  134. package/dist/opLifecycle/opSplitter.js.map +1 -1
  135. package/dist/opLifecycle/outbox.d.ts +7 -5
  136. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  137. package/dist/opLifecycle/outbox.js +22 -31
  138. package/dist/opLifecycle/outbox.js.map +1 -1
  139. package/dist/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  140. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  141. package/dist/opLifecycle/remoteMessageProcessor.js +19 -7
  142. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  143. package/dist/opProperties.js +1 -2
  144. package/dist/opProperties.js.map +1 -1
  145. package/dist/packageVersion.d.ts +1 -1
  146. package/dist/packageVersion.js +1 -1
  147. package/dist/packageVersion.js.map +1 -1
  148. package/dist/pendingStateManager.d.ts +18 -8
  149. package/dist/pendingStateManager.d.ts.map +1 -1
  150. package/dist/pendingStateManager.js +73 -51
  151. package/dist/pendingStateManager.js.map +1 -1
  152. package/dist/scheduleManager.d.ts.map +1 -1
  153. package/dist/scheduleManager.js +36 -32
  154. package/dist/scheduleManager.js.map +1 -1
  155. package/dist/summary/index.d.ts +3 -3
  156. package/dist/summary/index.d.ts.map +1 -1
  157. package/dist/summary/index.js +2 -1
  158. package/dist/summary/index.js.map +1 -1
  159. package/dist/summary/orderedClientElection.d.ts +3 -3
  160. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  161. package/dist/summary/orderedClientElection.js +26 -27
  162. package/dist/summary/orderedClientElection.js.map +1 -1
  163. package/dist/summary/runWhileConnectedCoordinator.js +3 -3
  164. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  165. package/dist/summary/runningSummarizer.d.ts +31 -10
  166. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  167. package/dist/summary/runningSummarizer.js +271 -139
  168. package/dist/summary/runningSummarizer.js.map +1 -1
  169. package/dist/summary/summarizer.d.ts +8 -7
  170. package/dist/summary/summarizer.d.ts.map +1 -1
  171. package/dist/summary/summarizer.js +79 -78
  172. package/dist/summary/summarizer.js.map +1 -1
  173. package/dist/summary/summarizerClientElection.d.ts +2 -2
  174. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  175. package/dist/summary/summarizerClientElection.js +7 -11
  176. package/dist/summary/summarizerClientElection.js.map +1 -1
  177. package/dist/summary/summarizerHeuristics.js +10 -14
  178. package/dist/summary/summarizerHeuristics.js.map +1 -1
  179. package/dist/summary/summarizerNode/index.d.ts +1 -1
  180. package/dist/summary/summarizerNode/index.d.ts.map +1 -1
  181. package/dist/summary/summarizerNode/index.js.map +1 -1
  182. package/dist/summary/summarizerNode/summarizerNode.d.ts +10 -19
  183. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  184. package/dist/summary/summarizerNode/summarizerNode.js +57 -130
  185. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  186. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +6 -30
  187. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  188. package/dist/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  189. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  190. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +4 -14
  191. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  192. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +15 -101
  193. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  194. package/dist/summary/summarizerTypes.d.ts +38 -25
  195. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  196. package/dist/summary/summarizerTypes.js.map +1 -1
  197. package/dist/summary/summaryCollection.d.ts +2 -3
  198. package/dist/summary/summaryCollection.d.ts.map +1 -1
  199. package/dist/summary/summaryCollection.js +12 -13
  200. package/dist/summary/summaryCollection.js.map +1 -1
  201. package/dist/summary/summaryFormat.d.ts +3 -0
  202. package/dist/summary/summaryFormat.d.ts.map +1 -1
  203. package/dist/summary/summaryFormat.js +6 -4
  204. package/dist/summary/summaryFormat.js.map +1 -1
  205. package/dist/summary/summaryGenerator.d.ts +10 -4
  206. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  207. package/dist/summary/summaryGenerator.js +106 -57
  208. package/dist/summary/summaryGenerator.js.map +1 -1
  209. package/dist/summary/summaryManager.d.ts +8 -8
  210. package/dist/summary/summaryManager.d.ts.map +1 -1
  211. package/dist/summary/summaryManager.js +38 -28
  212. package/dist/summary/summaryManager.js.map +1 -1
  213. package/lib/batchTracker.d.ts +3 -2
  214. package/lib/batchTracker.d.ts.map +1 -1
  215. package/lib/batchTracker.js +5 -4
  216. package/lib/batchTracker.js.map +1 -1
  217. package/lib/blobManager.d.ts +10 -16
  218. package/lib/blobManager.d.ts.map +1 -1
  219. package/lib/blobManager.js +159 -147
  220. package/lib/blobManager.js.map +1 -1
  221. package/lib/connectionTelemetry.d.ts.map +1 -1
  222. package/lib/connectionTelemetry.js +15 -6
  223. package/lib/connectionTelemetry.js.map +1 -1
  224. package/lib/containerRuntime.d.ts +161 -35
  225. package/lib/containerRuntime.d.ts.map +1 -1
  226. package/lib/containerRuntime.js +651 -402
  227. package/lib/containerRuntime.js.map +1 -1
  228. package/lib/dataStore.d.ts.map +1 -1
  229. package/lib/dataStore.js +13 -5
  230. package/lib/dataStore.js.map +1 -1
  231. package/lib/dataStoreContext.d.ts +3 -2
  232. package/lib/dataStoreContext.d.ts.map +1 -1
  233. package/lib/dataStoreContext.js +47 -51
  234. package/lib/dataStoreContext.js.map +1 -1
  235. package/lib/dataStoreContexts.d.ts +1 -2
  236. package/lib/dataStoreContexts.d.ts.map +1 -1
  237. package/lib/dataStoreContexts.js +3 -4
  238. package/lib/dataStoreContexts.js.map +1 -1
  239. package/lib/dataStoreRegistry.js +1 -1
  240. package/lib/dataStoreRegistry.js.map +1 -1
  241. package/lib/dataStores.d.ts +22 -6
  242. package/lib/dataStores.d.ts.map +1 -1
  243. package/lib/dataStores.js +107 -65
  244. package/lib/dataStores.js.map +1 -1
  245. package/lib/deltaManagerProxyBase.d.ts +35 -0
  246. package/lib/deltaManagerProxyBase.d.ts.map +1 -0
  247. package/lib/deltaManagerProxyBase.js +73 -0
  248. package/lib/deltaManagerProxyBase.js.map +1 -0
  249. package/lib/deltaManagerSummarizerProxy.d.ts +1 -1
  250. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -1
  251. package/lib/deltaManagerSummarizerProxy.js +3 -1
  252. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  253. package/lib/deltaScheduler.d.ts.map +1 -1
  254. package/lib/deltaScheduler.js +7 -7
  255. package/lib/deltaScheduler.js.map +1 -1
  256. package/lib/error.d.ts +14 -0
  257. package/lib/error.d.ts.map +1 -0
  258. package/lib/error.js +17 -0
  259. package/lib/error.js.map +1 -0
  260. package/lib/gc/garbageCollection.d.ts +10 -9
  261. package/lib/gc/garbageCollection.d.ts.map +1 -1
  262. package/lib/gc/garbageCollection.js +61 -53
  263. package/lib/gc/garbageCollection.js.map +1 -1
  264. package/lib/gc/gcConfigs.d.ts.map +1 -1
  265. package/lib/gc/gcConfigs.js +16 -12
  266. package/lib/gc/gcConfigs.js.map +1 -1
  267. package/lib/gc/gcDefinitions.d.ts +17 -4
  268. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  269. package/lib/gc/gcDefinitions.js +13 -14
  270. package/lib/gc/gcDefinitions.js.map +1 -1
  271. package/lib/gc/gcHelpers.d.ts +0 -8
  272. package/lib/gc/gcHelpers.d.ts.map +1 -1
  273. package/lib/gc/gcHelpers.js +5 -17
  274. package/lib/gc/gcHelpers.js.map +1 -1
  275. package/lib/gc/gcSummaryStateTracker.d.ts +4 -7
  276. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  277. package/lib/gc/gcSummaryStateTracker.js +20 -59
  278. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  279. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  280. package/lib/gc/gcTelemetry.js +46 -36
  281. package/lib/gc/gcTelemetry.js.map +1 -1
  282. package/lib/gc/gcUnreferencedStateTracker.js +1 -1
  283. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  284. package/lib/gc/index.d.ts +2 -2
  285. package/lib/gc/index.d.ts.map +1 -1
  286. package/lib/gc/index.js +2 -2
  287. package/lib/gc/index.js.map +1 -1
  288. package/lib/id-compressor/appendOnlySortedMap.d.ts +8 -30
  289. package/lib/id-compressor/appendOnlySortedMap.d.ts.map +1 -1
  290. package/lib/id-compressor/appendOnlySortedMap.js +25 -66
  291. package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
  292. package/lib/id-compressor/finalSpace.d.ts +29 -0
  293. package/lib/id-compressor/finalSpace.d.ts.map +1 -0
  294. package/lib/id-compressor/finalSpace.js +58 -0
  295. package/lib/id-compressor/finalSpace.js.map +1 -0
  296. package/lib/id-compressor/idCompressor.d.ts +25 -250
  297. package/lib/id-compressor/idCompressor.d.ts.map +1 -1
  298. package/lib/id-compressor/idCompressor.js +385 -1142
  299. package/lib/id-compressor/idCompressor.js.map +1 -1
  300. package/lib/id-compressor/identifiers.d.ts +32 -0
  301. package/lib/id-compressor/identifiers.d.ts.map +1 -0
  302. package/lib/id-compressor/identifiers.js +11 -0
  303. package/lib/id-compressor/identifiers.js.map +1 -0
  304. package/lib/id-compressor/index.d.ts +5 -6
  305. package/lib/id-compressor/index.d.ts.map +1 -1
  306. package/lib/id-compressor/index.js +5 -6
  307. package/lib/id-compressor/index.js.map +1 -1
  308. package/lib/id-compressor/persistanceUtilities.d.ts +22 -0
  309. package/lib/id-compressor/persistanceUtilities.d.ts.map +1 -0
  310. package/lib/id-compressor/persistanceUtilities.js +34 -0
  311. package/lib/id-compressor/persistanceUtilities.js.map +1 -0
  312. package/lib/id-compressor/sessionSpaceNormalizer.d.ts +46 -0
  313. package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +1 -0
  314. package/lib/id-compressor/sessionSpaceNormalizer.js +76 -0
  315. package/lib/id-compressor/sessionSpaceNormalizer.js.map +1 -0
  316. package/lib/id-compressor/sessions.d.ts +115 -0
  317. package/lib/id-compressor/sessions.d.ts.map +1 -0
  318. package/lib/id-compressor/sessions.js +290 -0
  319. package/lib/id-compressor/sessions.js.map +1 -0
  320. package/lib/id-compressor/utilities.d.ts +49 -0
  321. package/lib/id-compressor/utilities.d.ts.map +1 -0
  322. package/lib/id-compressor/utilities.js +148 -0
  323. package/lib/id-compressor/utilities.js.map +1 -0
  324. package/lib/index.d.ts +3 -3
  325. package/lib/index.d.ts.map +1 -1
  326. package/lib/index.js +2 -2
  327. package/lib/index.js.map +1 -1
  328. package/lib/opLifecycle/batchManager.js +10 -6
  329. package/lib/opLifecycle/batchManager.js.map +1 -1
  330. package/lib/opLifecycle/opCompressor.d.ts +2 -2
  331. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  332. package/lib/opLifecycle/opCompressor.js +10 -5
  333. package/lib/opLifecycle/opCompressor.js.map +1 -1
  334. package/lib/opLifecycle/opDecompressor.d.ts +2 -2
  335. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  336. package/lib/opLifecycle/opDecompressor.js +15 -12
  337. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  338. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  339. package/lib/opLifecycle/opGroupingManager.js +17 -7
  340. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  341. package/lib/opLifecycle/opSplitter.d.ts +2 -2
  342. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  343. package/lib/opLifecycle/opSplitter.js +13 -10
  344. package/lib/opLifecycle/opSplitter.js.map +1 -1
  345. package/lib/opLifecycle/outbox.d.ts +7 -5
  346. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  347. package/lib/opLifecycle/outbox.js +13 -22
  348. package/lib/opLifecycle/outbox.js.map +1 -1
  349. package/lib/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  350. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  351. package/lib/opLifecycle/remoteMessageProcessor.js +20 -8
  352. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  353. package/lib/opProperties.js +1 -2
  354. package/lib/opProperties.js.map +1 -1
  355. package/lib/packageVersion.d.ts +1 -1
  356. package/lib/packageVersion.js +1 -1
  357. package/lib/packageVersion.js.map +1 -1
  358. package/lib/pendingStateManager.d.ts +18 -8
  359. package/lib/pendingStateManager.d.ts.map +1 -1
  360. package/lib/pendingStateManager.js +62 -40
  361. package/lib/pendingStateManager.js.map +1 -1
  362. package/lib/scheduleManager.d.ts.map +1 -1
  363. package/lib/scheduleManager.js +18 -14
  364. package/lib/scheduleManager.js.map +1 -1
  365. package/lib/summary/index.d.ts +3 -3
  366. package/lib/summary/index.d.ts.map +1 -1
  367. package/lib/summary/index.js +1 -1
  368. package/lib/summary/index.js.map +1 -1
  369. package/lib/summary/orderedClientElection.d.ts +3 -3
  370. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  371. package/lib/summary/orderedClientElection.js +21 -22
  372. package/lib/summary/orderedClientElection.js.map +1 -1
  373. package/lib/summary/runWhileConnectedCoordinator.js +1 -1
  374. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  375. package/lib/summary/runningSummarizer.d.ts +31 -10
  376. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  377. package/lib/summary/runningSummarizer.js +265 -133
  378. package/lib/summary/runningSummarizer.js.map +1 -1
  379. package/lib/summary/summarizer.d.ts +8 -7
  380. package/lib/summary/summarizer.d.ts.map +1 -1
  381. package/lib/summary/summarizer.js +75 -74
  382. package/lib/summary/summarizer.js.map +1 -1
  383. package/lib/summary/summarizerClientElection.d.ts +2 -2
  384. package/lib/summary/summarizerClientElection.d.ts.map +1 -1
  385. package/lib/summary/summarizerClientElection.js +6 -10
  386. package/lib/summary/summarizerClientElection.js.map +1 -1
  387. package/lib/summary/summarizerHeuristics.js +9 -13
  388. package/lib/summary/summarizerHeuristics.js.map +1 -1
  389. package/lib/summary/summarizerNode/index.d.ts +1 -1
  390. package/lib/summary/summarizerNode/index.d.ts.map +1 -1
  391. package/lib/summary/summarizerNode/index.js.map +1 -1
  392. package/lib/summary/summarizerNode/summarizerNode.d.ts +10 -19
  393. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  394. package/lib/summary/summarizerNode/summarizerNode.js +42 -115
  395. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  396. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +6 -30
  397. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  398. package/lib/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  399. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  400. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +4 -14
  401. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  402. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +14 -100
  403. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  404. package/lib/summary/summarizerTypes.d.ts +38 -25
  405. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  406. package/lib/summary/summarizerTypes.js.map +1 -1
  407. package/lib/summary/summaryCollection.d.ts +2 -3
  408. package/lib/summary/summaryCollection.d.ts.map +1 -1
  409. package/lib/summary/summaryCollection.js +5 -6
  410. package/lib/summary/summaryCollection.js.map +1 -1
  411. package/lib/summary/summaryFormat.d.ts +3 -0
  412. package/lib/summary/summaryFormat.d.ts.map +1 -1
  413. package/lib/summary/summaryFormat.js +5 -3
  414. package/lib/summary/summaryFormat.js.map +1 -1
  415. package/lib/summary/summaryGenerator.d.ts +10 -4
  416. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  417. package/lib/summary/summaryGenerator.js +100 -51
  418. package/lib/summary/summaryGenerator.js.map +1 -1
  419. package/lib/summary/summaryManager.d.ts +8 -8
  420. package/lib/summary/summaryManager.d.ts.map +1 -1
  421. package/lib/summary/summaryManager.js +35 -25
  422. package/lib/summary/summaryManager.js.map +1 -1
  423. package/package.json +28 -31
  424. package/src/batchTracker.ts +7 -5
  425. package/src/blobManager.ts +188 -166
  426. package/src/connectionTelemetry.ts +9 -4
  427. package/src/containerRuntime.ts +806 -441
  428. package/src/dataStore.ts +12 -4
  429. package/src/dataStoreContext.ts +39 -43
  430. package/src/dataStoreContexts.ts +4 -6
  431. package/src/dataStoreRegistry.ts +1 -1
  432. package/src/dataStores.ts +114 -80
  433. package/src/deltaManagerProxyBase.ts +111 -0
  434. package/src/deltaManagerSummarizerProxy.ts +4 -1
  435. package/src/deltaScheduler.ts +7 -11
  436. package/src/error.ts +18 -0
  437. package/src/gc/garbageCollection.md +53 -5
  438. package/src/gc/garbageCollection.ts +58 -52
  439. package/src/gc/gcConfigs.ts +4 -2
  440. package/src/gc/gcDefinitions.ts +17 -20
  441. package/src/gc/gcEarlyAdoption.md +145 -0
  442. package/src/gc/gcHelpers.ts +1 -12
  443. package/src/gc/gcSummaryStateTracker.ts +19 -65
  444. package/src/gc/gcTelemetry.ts +14 -12
  445. package/src/gc/gcUnreferencedStateTracker.ts +1 -1
  446. package/src/gc/index.ts +2 -4
  447. package/src/id-compressor/appendOnlySortedMap.ts +26 -87
  448. package/src/id-compressor/finalSpace.ts +67 -0
  449. package/src/id-compressor/idCompressor.ts +458 -1682
  450. package/src/id-compressor/identifiers.ts +42 -0
  451. package/src/id-compressor/index.ts +11 -20
  452. package/src/id-compressor/persistanceUtilities.ts +58 -0
  453. package/src/id-compressor/sessionSpaceNormalizer.ts +83 -0
  454. package/src/id-compressor/sessions.ts +405 -0
  455. package/src/id-compressor/utilities.ts +187 -0
  456. package/src/index.ts +7 -2
  457. package/src/opLifecycle/opCompressor.ts +6 -5
  458. package/src/opLifecycle/opDecompressor.ts +6 -4
  459. package/src/opLifecycle/opGroupingManager.ts +9 -6
  460. package/src/opLifecycle/opSplitter.ts +7 -6
  461. package/src/opLifecycle/outbox.ts +23 -32
  462. package/src/opLifecycle/remoteMessageProcessor.ts +27 -8
  463. package/src/packageVersion.ts +1 -1
  464. package/src/pendingStateManager.ts +72 -42
  465. package/src/scheduleManager.ts +7 -5
  466. package/src/summary/index.ts +4 -3
  467. package/src/summary/orderedClientElection.ts +10 -6
  468. package/src/summary/runWhileConnectedCoordinator.ts +1 -1
  469. package/src/summary/runningSummarizer.ts +291 -163
  470. package/src/summary/summarizer.ts +27 -16
  471. package/src/summary/summarizerClientElection.ts +2 -2
  472. package/src/summary/summarizerHeuristics.ts +1 -1
  473. package/src/summary/summarizerNode/index.ts +1 -2
  474. package/src/summary/summarizerNode/summarizerNode.ts +36 -160
  475. package/src/summary/summarizerNode/summarizerNodeUtils.ts +7 -38
  476. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +11 -130
  477. package/src/summary/summarizerTypes.ts +40 -25
  478. package/src/summary/summaryCollection.ts +3 -3
  479. package/src/summary/summaryFormat.ts +4 -1
  480. package/src/summary/summaryGenerator.ts +52 -52
  481. package/src/summary/summaryManager.ts +44 -17
  482. package/dist/id-compressor/idRange.d.ts +0 -11
  483. package/dist/id-compressor/idRange.d.ts.map +0 -1
  484. package/dist/id-compressor/idRange.js +0 -29
  485. package/dist/id-compressor/idRange.js.map +0 -1
  486. package/dist/id-compressor/numericUuid.d.ts +0 -59
  487. package/dist/id-compressor/numericUuid.d.ts.map +0 -1
  488. package/dist/id-compressor/numericUuid.js +0 -325
  489. package/dist/id-compressor/numericUuid.js.map +0 -1
  490. package/dist/id-compressor/sessionIdNormalizer.d.ts +0 -138
  491. package/dist/id-compressor/sessionIdNormalizer.d.ts.map +0 -1
  492. package/dist/id-compressor/sessionIdNormalizer.js +0 -488
  493. package/dist/id-compressor/sessionIdNormalizer.js.map +0 -1
  494. package/dist/id-compressor/utils.d.ts +0 -57
  495. package/dist/id-compressor/utils.d.ts.map +0 -1
  496. package/dist/id-compressor/utils.js +0 -90
  497. package/dist/id-compressor/utils.js.map +0 -1
  498. package/dist/id-compressor/uuidUtilities.d.ts +0 -28
  499. package/dist/id-compressor/uuidUtilities.d.ts.map +0 -1
  500. package/dist/id-compressor/uuidUtilities.js +0 -104
  501. package/dist/id-compressor/uuidUtilities.js.map +0 -1
  502. package/lib/id-compressor/idRange.d.ts +0 -11
  503. package/lib/id-compressor/idRange.d.ts.map +0 -1
  504. package/lib/id-compressor/idRange.js +0 -25
  505. package/lib/id-compressor/idRange.js.map +0 -1
  506. package/lib/id-compressor/numericUuid.d.ts +0 -59
  507. package/lib/id-compressor/numericUuid.d.ts.map +0 -1
  508. package/lib/id-compressor/numericUuid.js +0 -315
  509. package/lib/id-compressor/numericUuid.js.map +0 -1
  510. package/lib/id-compressor/sessionIdNormalizer.d.ts +0 -138
  511. package/lib/id-compressor/sessionIdNormalizer.d.ts.map +0 -1
  512. package/lib/id-compressor/sessionIdNormalizer.js +0 -484
  513. package/lib/id-compressor/sessionIdNormalizer.js.map +0 -1
  514. package/lib/id-compressor/utils.d.ts +0 -57
  515. package/lib/id-compressor/utils.d.ts.map +0 -1
  516. package/lib/id-compressor/utils.js +0 -79
  517. package/lib/id-compressor/utils.js.map +0 -1
  518. package/lib/id-compressor/uuidUtilities.d.ts +0 -28
  519. package/lib/id-compressor/uuidUtilities.d.ts.map +0 -1
  520. package/lib/id-compressor/uuidUtilities.js +0 -96
  521. package/lib/id-compressor/uuidUtilities.js.map +0 -1
  522. package/src/id-compressor/idRange.ts +0 -35
  523. package/src/id-compressor/numericUuid.ts +0 -383
  524. package/src/id-compressor/sessionIdNormalizer.ts +0 -609
  525. package/src/id-compressor/utils.ts +0 -114
  526. package/src/id-compressor/uuidUtilities.ts +0 -120
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.BlobManager = exports.BlobHandle = void 0;
8
8
  const uuid_1 = require("uuid");
9
9
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
10
- const common_utils_1 = require("@fluidframework/common-utils");
10
+ const core_utils_1 = require("@fluidframework/core-utils");
11
+ const client_utils_1 = require("@fluid-internal/client-utils");
11
12
  const container_definitions_1 = require("@fluidframework/container-definitions");
12
13
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
13
- const container_utils_1 = require("@fluidframework/container-utils");
14
14
  const containerRuntime_1 = require("./containerRuntime");
15
15
  const gc_1 = require("./gc");
16
16
  const throttler_1 = require("./throttler");
@@ -38,10 +38,9 @@ class BlobHandle {
38
38
  return this.routeContext.isAttached && this.attached;
39
39
  }
40
40
  attachGraph() {
41
- var _a;
42
41
  if (!this.attached) {
43
42
  this.attached = true;
44
- (_a = this.onAttachGraph) === null || _a === void 0 ? void 0 : _a.call(this);
43
+ this.onAttachGraph?.();
45
44
  }
46
45
  }
47
46
  bind(handle) {
@@ -52,7 +51,7 @@ exports.BlobHandle = BlobHandle;
52
51
  class CancellableThrottler {
53
52
  constructor(throttler) {
54
53
  this.throttler = throttler;
55
- this.cancelP = new common_utils_1.Deferred();
54
+ this.cancelP = new core_utils_1.Deferred();
56
55
  }
57
56
  async getDelay() {
58
57
  return Promise.race([
@@ -62,19 +61,10 @@ class CancellableThrottler {
62
61
  }
63
62
  cancel() {
64
63
  this.cancelP.resolve();
65
- this.cancelP = new common_utils_1.Deferred();
64
+ this.cancelP = new core_utils_1.Deferred();
66
65
  }
67
66
  }
68
- // Note that while offline we "submit" an op before uploading the blob, but we always
69
- // expect blobs to be uploaded before we actually see the op round-trip
70
- var PendingBlobStatus;
71
- (function (PendingBlobStatus) {
72
- PendingBlobStatus[PendingBlobStatus["OnlinePendingUpload"] = 0] = "OnlinePendingUpload";
73
- PendingBlobStatus[PendingBlobStatus["OnlinePendingOp"] = 1] = "OnlinePendingOp";
74
- PendingBlobStatus[PendingBlobStatus["OfflinePendingUpload"] = 2] = "OfflinePendingUpload";
75
- PendingBlobStatus[PendingBlobStatus["OfflinePendingOp"] = 3] = "OfflinePendingOp";
76
- })(PendingBlobStatus || (PendingBlobStatus = {}));
77
- class BlobManager extends common_utils_1.TypedEventEmitter {
67
+ class BlobManager extends client_utils_1.TypedEventEmitter {
78
68
  constructor(routeContext, snapshot, getStorage,
79
69
  /**
80
70
  * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
@@ -101,9 +91,7 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
101
91
  this.runtime = runtime;
102
92
  this.closeContainer = closeContainer;
103
93
  /**
104
- * Blobs which have not been uploaded or for which we have not yet seen a BlobAttach op round-trip.
105
- * Until we see the op round-trip, there is a possibility we may need to re-upload the blob, so
106
- * we must save it. This is true for both the online and offline flow.
94
+ * Blobs which we have not yet seen a BlobAttach op round-trip and not yet attached to a DDS.
107
95
  */
108
96
  this.pendingBlobs = new Map();
109
97
  /**
@@ -121,27 +109,32 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
121
109
  * Tombstone is a temporary feature that imitates a blob getting swept by garbage collection.
122
110
  */
123
111
  this.tombstonedBlobs = new Set();
124
- this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.runtime.logger, "BlobManager"));
112
+ this.mc = (0, telemetry_utils_1.createChildMonitoringContext)({
113
+ logger: this.runtime.logger,
114
+ namespace: "BlobManager",
115
+ });
125
116
  // Read the feature flag that tells whether to throw when a tombstone blob is requested.
126
117
  this.throwOnTombstoneLoad =
127
118
  this.mc.config.getBoolean(gc_1.throwOnTombstoneLoadKey) === true &&
128
119
  this.runtime.gcTombstoneEnforcementAllowed &&
129
120
  this.runtime.clientDetails.type !== summary_1.summarizerClientType;
130
- this.runtime.on("disconnected", () => this.onDisconnected());
131
121
  this.redirectTable = this.load(snapshot);
132
122
  // Begin uploading stashed blobs from previous container instance
133
123
  Object.entries(stashedBlobs).forEach(([localId, entry]) => {
134
- const blob = (0, common_utils_1.stringToBuffer)(entry.blob, "base64");
124
+ const blob = (0, client_utils_1.stringToBuffer)(entry.blob, "base64");
135
125
  const attached = entry.attached;
136
126
  const acked = entry.acked;
127
+ const storageId = entry.storageId; // entry.storageId = response.id
137
128
  if (entry.minTTLInSeconds && entry.uploadTime) {
138
129
  const timeLapseSinceLocalUpload = (Date.now() - entry.uploadTime) / 1000;
139
130
  // stashed entries with more than half-life in storage will not be reuploaded
140
131
  if (entry.minTTLInSeconds - timeLapseSinceLocalUpload > entry.minTTLInSeconds / 2) {
141
132
  this.pendingBlobs.set(localId, {
142
133
  blob,
143
- status: PendingBlobStatus.OfflinePendingOp,
144
- handleP: new common_utils_1.Deferred(),
134
+ uploading: false,
135
+ opsent: true,
136
+ handleP: new core_utils_1.Deferred(),
137
+ storageId,
145
138
  uploadP: undefined,
146
139
  uploadTime: entry.uploadTime,
147
140
  minTTLInSeconds: entry.minTTLInSeconds,
@@ -153,72 +146,70 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
153
146
  }
154
147
  this.pendingBlobs.set(localId, {
155
148
  blob,
156
- status: PendingBlobStatus.OfflinePendingUpload,
157
- handleP: new common_utils_1.Deferred(),
149
+ uploading: true,
150
+ handleP: new core_utils_1.Deferred(),
158
151
  uploadP: this.uploadBlob(localId, blob),
159
152
  attached,
160
153
  acked,
154
+ opsent: true,
161
155
  });
162
156
  });
163
157
  this.sendBlobAttachOp = (localId, blobId) => {
164
158
  const pendingEntry = this.pendingBlobs.get(localId);
165
- if ((pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.uploadTime) && (pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.minTTLInSeconds)) {
159
+ (0, core_utils_1.assert)(pendingEntry !== undefined, 0x725 /* Must have pending blob entry for upcoming op */);
160
+ if (pendingEntry?.uploadTime && pendingEntry?.minTTLInSeconds) {
166
161
  const secondsSinceUpload = (Date.now() - pendingEntry.uploadTime) / 1000;
167
162
  const expired = pendingEntry.minTTLInSeconds - secondsSinceUpload < 0;
168
163
  this.mc.logger.sendTelemetryEvent({
169
164
  eventName: "sendBlobAttach",
170
- entryStatus: pendingEntry.status,
171
165
  secondsSinceUpload,
172
166
  minTTLInSeconds: pendingEntry.minTTLInSeconds,
173
167
  expired,
174
168
  });
175
169
  if (expired) {
176
170
  // we want to avoid submitting ops with broken handles
177
- this.closeContainer(new container_utils_1.GenericError("Trying to submit a BlobAttach for expired blob", undefined, {
171
+ this.closeContainer(new telemetry_utils_1.GenericError("Trying to submit a BlobAttach for expired blob", undefined, {
178
172
  localId,
179
173
  blobId,
180
- entryStatus: pendingEntry.status,
181
174
  secondsSinceUpload,
182
175
  }));
183
176
  }
184
177
  }
178
+ pendingEntry.opsent = true;
185
179
  return sendBlobAttachOp(localId, blobId);
186
180
  };
187
181
  }
188
- get pendingOfflineUploads() {
189
- return Array.from(this.pendingBlobs.values()).filter((e) => e.status === PendingBlobStatus.OfflinePendingUpload);
190
- }
191
- get hasPendingOfflineUploads() {
192
- return this.pendingOfflineUploads.length > 0;
182
+ get allBlobsAttached() {
183
+ for (const [, entry] of this.pendingBlobs) {
184
+ if (entry.attached === false) {
185
+ return false;
186
+ }
187
+ }
188
+ return true;
193
189
  }
194
190
  get hasPendingBlobs() {
195
191
  return ((this.runtime.attachState !== container_definitions_1.AttachState.Attached && this.redirectTable.size > 0) ||
196
192
  this.pendingBlobs.size > 0);
197
193
  }
194
+ createAbortError(pending) {
195
+ return new telemetry_utils_1.LoggingError("uploadBlob aborted", {
196
+ acked: pending?.acked,
197
+ uploadTime: pending?.uploadTime,
198
+ });
199
+ }
198
200
  /**
199
201
  * Upload blobs added while offline. This must be completed before connecting and resubmitting ops.
200
202
  */
201
- async onConnected() {
203
+ async processStashedChanges() {
202
204
  this.retryThrottler.cancel();
203
- const pendingUploads = this.pendingOfflineUploads.map(async (e) => e.uploadP);
205
+ const pendingUploads = Array.from(this.pendingBlobs.values())
206
+ .filter((e) => e.uploading === true)
207
+ .map(async (e) => e.uploadP);
204
208
  await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, {
205
- eventName: "BlobUploadOnConnected",
209
+ eventName: "BlobUploadProcessStashedChanges",
206
210
  count: pendingUploads.length,
207
211
  }, async () => Promise.all(pendingUploads), { start: true, end: true });
208
212
  }
209
- /**
210
- * Transition online blobs waiting for BlobAttach op round-trip since we will not see the op until we are connected
211
- * again
212
- */
213
- onDisconnected() {
214
- for (const [localId, entry] of this.pendingBlobs) {
215
- if (entry.status === PendingBlobStatus.OnlinePendingOp) {
216
- // This will submit another BlobAttach op for this blob. This is necessary because the one we sent
217
- // already didn't have the local ID.
218
- this.transitionToOffline(localId);
219
- }
220
- }
221
- }
222
213
  /**
223
214
  * Set of actual storage IDs (i.e., IDs that can be requested from storage). This will be empty if the container is
224
215
  * detached or there are no (non-pending) attachment blobs in the document
@@ -229,7 +220,7 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
229
220
  const undefinedValueInTable = ids.delete(undefined);
230
221
  // For a detached container, entries are inserted into the redirect table with an undefined storage ID.
231
222
  // For an attached container, entries are inserted w/storage ID after the BlobAttach op round-trips.
232
- (0, common_utils_1.assert)(!undefinedValueInTable ||
223
+ (0, core_utils_1.assert)(!undefinedValueInTable ||
233
224
  (this.runtime.attachState === container_definitions_1.AttachState.Detached && ids.size === 0), 0x382 /* 'redirectTable' must contain only undefined while detached / defined values while attached */);
234
225
  return ids;
235
226
  }
@@ -243,14 +234,14 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
243
234
  }
244
235
  let storageId;
245
236
  if (this.runtime.attachState === container_definitions_1.AttachState.Detached) {
246
- (0, common_utils_1.assert)(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);
237
+ (0, core_utils_1.assert)(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);
247
238
  // Blobs created while the container is detached are stored in IDetachedBlobStorage.
248
239
  // The 'IDocumentStorageService.readBlob()' call below will retrieve these via localId.
249
240
  storageId = blobId;
250
241
  }
251
242
  else {
252
243
  const attachedStorageId = this.redirectTable.get(blobId);
253
- (0, common_utils_1.assert)(!!attachedStorageId, 0x11f /* "requesting unknown blobs" */);
244
+ (0, core_utils_1.assert)(!!attachedStorageId, 0x11f /* "requesting unknown blobs" */);
254
245
  storageId = attachedStorageId;
255
246
  }
256
247
  // Let runtime know that the corresponding GC node was requested.
@@ -260,11 +251,12 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
260
251
  }, { end: true, cancel: "error" });
261
252
  }
262
253
  getBlobHandle(id) {
263
- (0, common_utils_1.assert)(this.redirectTable.has(id) || this.pendingBlobs.has(id), 0x384 /* requesting handle for unknown blob */);
254
+ (0, core_utils_1.assert)(this.redirectTable.has(id) || this.pendingBlobs.has(id), 0x384 /* requesting handle for unknown blob */);
264
255
  const pending = this.pendingBlobs.get(id);
265
256
  const callback = pending
266
257
  ? () => {
267
258
  pending.attached = true;
259
+ this.emit("blobAttached", pending);
268
260
  this.deletePendingBlobMaybe(id);
269
261
  }
270
262
  : undefined;
@@ -277,7 +269,7 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
277
269
  this.setRedirection(response.id, undefined);
278
270
  return this.getBlobHandle(response.id);
279
271
  }
280
- async createBlob(blob) {
272
+ async createBlob(blob, signal) {
281
273
  if (this.runtime.attachState === container_definitions_1.AttachState.Detached) {
282
274
  return this.createBlobDetached(blob);
283
275
  }
@@ -286,20 +278,33 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
286
278
  this.mc.logger.sendTelemetryEvent({ eventName: "CreateBlobWhileAttaching" });
287
279
  await new Promise((resolve) => this.runtime.once("attached", resolve));
288
280
  }
289
- (0, common_utils_1.assert)(this.runtime.attachState === container_definitions_1.AttachState.Attached, 0x385 /* For clarity and paranoid defense against adding future attachment states */);
281
+ (0, core_utils_1.assert)(this.runtime.attachState === container_definitions_1.AttachState.Attached, 0x385 /* For clarity and paranoid defense against adding future attachment states */);
282
+ if (signal?.aborted) {
283
+ throw this.createAbortError();
284
+ }
290
285
  // Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to
291
286
  // storage ID mapping is created.
292
287
  const localId = (0, uuid_1.v4)();
293
288
  const pendingEntry = {
294
289
  blob,
295
- status: PendingBlobStatus.OnlinePendingUpload,
296
- handleP: new common_utils_1.Deferred(),
290
+ uploading: true,
291
+ handleP: new core_utils_1.Deferred(),
297
292
  uploadP: this.uploadBlob(localId, blob),
298
293
  attached: false,
299
294
  acked: false,
295
+ abortSignal: signal,
296
+ opsent: false,
300
297
  };
301
298
  this.pendingBlobs.set(localId, pendingEntry);
302
- return pendingEntry.handleP.promise;
299
+ const abortListener = () => {
300
+ if (!pendingEntry.acked) {
301
+ pendingEntry.handleP.reject(this.createAbortError(pendingEntry));
302
+ }
303
+ };
304
+ signal?.addEventListener("abort", abortListener, { once: true });
305
+ return pendingEntry.handleP.promise.finally(() => {
306
+ signal?.removeEventListener("abort", abortListener);
307
+ });
303
308
  }
304
309
  async uploadBlob(localId, blob) {
305
310
  return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "createBlob" }, async () => this.getStorage().createBlob(blob), { end: true, cancel: this.runtime.connected ? "error" : "generic" }).then((response) => this.onUploadResolve(localId, response), async (err) => this.onUploadReject(localId, err));
@@ -314,69 +319,59 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
314
319
  deletePendingBlobMaybe(id) {
315
320
  if (this.pendingBlobs.has(id)) {
316
321
  const entry = this.pendingBlobs.get(id);
317
- if ((entry === null || entry === void 0 ? void 0 : entry.attached) && (entry === null || entry === void 0 ? void 0 : entry.acked)) {
318
- this.pendingBlobs.delete(id);
319
- if (!this.hasPendingBlobs) {
320
- this.emit("noPendingBlobs");
321
- }
322
+ if (entry?.attached && entry?.acked) {
323
+ this.deletePendingBlob(id);
322
324
  }
323
325
  }
324
326
  }
327
+ deletePendingBlob(id) {
328
+ if (this.pendingBlobs.delete(id) && !this.hasPendingBlobs) {
329
+ this.emit("noPendingBlobs");
330
+ }
331
+ }
325
332
  onUploadResolve(localId, response) {
326
- var _a;
327
333
  const entry = this.pendingBlobs.get(localId);
328
- (0, common_utils_1.assert)(entry !== undefined, 0x6c8 /* pending blob entry not found for uploaded blob */);
329
- (0, common_utils_1.assert)(entry.status === PendingBlobStatus.OnlinePendingUpload ||
330
- entry.status === PendingBlobStatus.OfflinePendingUpload, 0x386 /* Must have pending blob entry for uploaded blob */);
334
+ (0, core_utils_1.assert)(entry !== undefined, 0x6c8 /* pending blob entry not found for uploaded blob */);
335
+ if (entry.abortSignal?.aborted === true && !entry.opsent) {
336
+ this.deletePendingBlob(localId);
337
+ return;
338
+ }
339
+ (0, core_utils_1.assert)(entry.uploading === true, 0x386 /* Must have pending blob entry for uploaded blob */);
331
340
  entry.storageId = response.id;
332
341
  entry.uploadTime = Date.now();
333
342
  entry.minTTLInSeconds = response.minTTLInSeconds;
334
- if (this.runtime.connected) {
335
- if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
336
- // Send a blob attach op. This serves two purposes:
337
- // 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op
338
- // until its storage ID is added to the next summary.
339
- // 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
340
- // blob from the server via the storage ID.
341
- this.sendBlobAttachOp(localId, response.id);
342
- if (this.storageIds.has(response.id)) {
343
- // The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
344
- // an existing blob, we don't have to wait for the op to be ack'd since this step has already
345
- // happened before and so, the server won't delete it.
346
- this.setRedirection(localId, response.id);
347
- entry.handleP.resolve(this.getBlobHandle(localId));
348
- this.deletePendingBlobMaybe(localId);
349
- }
350
- else {
351
- // If there is already an op for this storage ID, append the local ID to the list. Once any op for
352
- // this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
353
- // blob alive in storage.
354
- this.opsInFlight.set(response.id, ((_a = this.opsInFlight.get(response.id)) !== null && _a !== void 0 ? _a : []).concat(localId));
355
- entry.status = PendingBlobStatus.OnlinePendingOp;
356
- }
357
- }
358
- else if (entry.status === PendingBlobStatus.OfflinePendingUpload) {
359
- // We already submitted a BlobAttach op for this blob when it was transitioned to offline flow
360
- entry.status = PendingBlobStatus.OfflinePendingOp;
361
- }
343
+ // Send a blob attach op. This serves two purposes:
344
+ // 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op
345
+ // until its storage ID is added to the next summary.
346
+ // 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
347
+ // blob from the server via the storage ID.
348
+ if (!entry.opsent) {
349
+ this.sendBlobAttachOp(localId, response.id);
350
+ }
351
+ if (this.storageIds.has(response.id)) {
352
+ // The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
353
+ // an existing blob, we don't have to wait for the op to be ack'd since this step has already
354
+ // happened before and so, the server won't delete it.
355
+ this.setRedirection(localId, response.id);
356
+ entry.handleP.resolve(this.getBlobHandle(localId));
357
+ this.deletePendingBlobMaybe(localId);
362
358
  }
363
359
  else {
364
- // connected to storage but not ordering service?
365
- this.mc.logger.sendTelemetryEvent({ eventName: "BlobUploadSuccessWhileDisconnected" });
366
- if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
367
- this.transitionToOffline(localId);
368
- }
369
- entry.status = PendingBlobStatus.OfflinePendingOp;
360
+ // If there is already an op for this storage ID, append the local ID to the list. Once any op for
361
+ // this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
362
+ // blob alive in storage.
363
+ this.opsInFlight.set(response.id, (this.opsInFlight.get(response.id) ?? []).concat(localId));
370
364
  }
371
365
  return response;
372
366
  }
373
367
  async onUploadReject(localId, error) {
374
368
  const entry = this.pendingBlobs.get(localId);
375
- (0, common_utils_1.assert)(!!entry, 0x387 /* Must have pending blob entry for blob which failed to upload */);
369
+ (0, core_utils_1.assert)(!!entry, 0x387 /* Must have pending blob entry for blob which failed to upload */);
370
+ if (entry.abortSignal?.aborted === true && !entry.opsent) {
371
+ this.deletePendingBlob(localId);
372
+ return;
373
+ }
376
374
  if (!this.runtime.connected) {
377
- if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
378
- this.transitionToOffline(localId);
379
- }
380
375
  // we are probably not connected to storage but start another upload request in case we are
381
376
  entry.uploadP = this.retryThrottler
382
377
  .getDelay()
@@ -388,50 +383,34 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
388
383
  throw error;
389
384
  }
390
385
  }
391
- transitionToOffline(localId) {
392
- (0, common_utils_1.assert)(!this.runtime.connected, 0x388 /* Must only transition to offline flow while runtime is disconnected */);
393
- const entry = this.pendingBlobs.get(localId);
394
- (0, common_utils_1.assert)(!!entry, 0x389 /* No pending blob entry */);
395
- (0, common_utils_1.assert)([PendingBlobStatus.OnlinePendingUpload, PendingBlobStatus.OnlinePendingOp].includes(entry.status), 0x38a /* Blob must be in online flow to transition to offline flow */);
396
- /**
397
- * If we haven't already submitted a BlobAttach op for this entry, send it before returning the blob handle.
398
- * This will make sure that the BlobAttach op is sequenced prior to any ops referencing the handle. Otherwise,
399
- * an invalid handle could be added to the document.
400
- * storageId may be undefined but since we are not connected we will have a chance to add it when reSubmit()
401
- * is called on reconnection.
402
- */
403
- if (entry.status !== PendingBlobStatus.OnlinePendingOp) {
404
- this.sendBlobAttachOp(localId, entry.storageId);
405
- }
406
- entry.status =
407
- entry.status === PendingBlobStatus.OnlinePendingUpload
408
- ? PendingBlobStatus.OfflinePendingUpload
409
- : PendingBlobStatus.OfflinePendingOp;
410
- entry.handleP.resolve(this.getBlobHandle(localId));
411
- }
412
386
  /**
413
387
  * Resubmit a BlobAttach op. Used to add storage IDs to ops that were
414
388
  * submitted to runtime while disconnected.
415
389
  * @param metadata - op metadata containing storage and/or local IDs
416
390
  */
417
391
  reSubmit(metadata) {
418
- (0, common_utils_1.assert)(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
392
+ (0, core_utils_1.assert)(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
419
393
  const { localId, blobId } = metadata;
420
- (0, common_utils_1.assert)(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
394
+ (0, core_utils_1.assert)(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
421
395
  const pendingEntry = this.pendingBlobs.get(localId);
422
396
  if (!blobId) {
423
397
  // We submitted this op while offline. The blob should have been uploaded by now.
424
- (0, common_utils_1.assert)((pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.status) === PendingBlobStatus.OfflinePendingOp &&
425
- !!(pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.storageId), 0x38d /* blob must be uploaded before resubmitting BlobAttach op */);
426
- return this.sendBlobAttachOp(localId, pendingEntry.storageId);
398
+ (0, core_utils_1.assert)(pendingEntry?.opsent === true && !!pendingEntry?.storageId, 0x38d /* blob must be uploaded before resubmitting BlobAttach op */);
399
+ return this.sendBlobAttachOp(localId, pendingEntry?.storageId);
427
400
  }
428
401
  return this.sendBlobAttachOp(localId, blobId);
429
402
  }
430
403
  processBlobAttachOp(message, local) {
431
- var _a, _b;
432
- const localId = (_a = message.metadata) === null || _a === void 0 ? void 0 : _a.localId;
433
- const blobId = (_b = message.metadata) === null || _b === void 0 ? void 0 : _b.blobId;
434
- (0, common_utils_1.assert)(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
404
+ const localId = message.metadata?.localId;
405
+ const blobId = message.metadata?.blobId;
406
+ if (localId) {
407
+ const pendingEntry = this.pendingBlobs.get(localId);
408
+ if (pendingEntry?.abortSignal?.aborted) {
409
+ this.deletePendingBlob(localId);
410
+ return;
411
+ }
412
+ }
413
+ (0, core_utils_1.assert)(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
435
414
  // Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be
436
415
  // requested from the server.
437
416
  // Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that
@@ -442,7 +421,7 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
442
421
  // set identity (id -> id) entry
443
422
  this.setRedirection(blobId, blobId);
444
423
  if (local) {
445
- (0, common_utils_1.assert)(localId !== undefined, 0x50e /* local ID not present in blob attach message */);
424
+ (0, core_utils_1.assert)(localId !== undefined, 0x50e /* local ID not present in blob attach message */);
446
425
  const waitingBlobs = this.opsInFlight.get(blobId);
447
426
  if (waitingBlobs !== undefined) {
448
427
  // For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.
@@ -450,22 +429,18 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
450
429
  // storage ID is already in flight and any op containing this local ID will be sequenced after that.
451
430
  waitingBlobs.forEach((pendingLocalId) => {
452
431
  const entry = this.pendingBlobs.get(pendingLocalId);
453
- (0, common_utils_1.assert)(entry !== undefined, 0x38f /* local online BlobAttach op with no pending blob entry */);
454
- // It's possible we transitioned to offline flow while waiting for this op.
455
- if (entry.status === PendingBlobStatus.OnlinePendingOp) {
456
- this.setRedirection(pendingLocalId, blobId);
457
- entry.acked = true;
458
- entry.handleP.resolve(this.getBlobHandle(pendingLocalId));
459
- this.deletePendingBlobMaybe(pendingLocalId);
460
- }
432
+ (0, core_utils_1.assert)(entry !== undefined, 0x38f /* local online BlobAttach op with no pending blob entry */);
433
+ this.setRedirection(pendingLocalId, blobId);
434
+ entry.acked = true;
435
+ entry.handleP.resolve(this.getBlobHandle(pendingLocalId));
436
+ this.deletePendingBlobMaybe(pendingLocalId);
461
437
  });
462
438
  this.opsInFlight.delete(blobId);
463
439
  }
464
- // offline flow does not resolve the handle (since it was already resolved)
465
- // but we still need to delete the entry in case is acked and attached.
466
440
  const localEntry = this.pendingBlobs.get(localId);
467
441
  if (localEntry) {
468
442
  localEntry.acked = true;
443
+ localEntry.handleP.resolve(this.getBlobHandle(localId));
469
444
  this.deletePendingBlobMaybe(localId);
470
445
  }
471
446
  }
@@ -494,11 +469,10 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
494
469
  * Load a set of previously attached blob IDs and redirect table from a previous snapshot.
495
470
  */
496
471
  load(snapshot) {
497
- var _a, _b, _c;
498
472
  this.mc.logger.sendTelemetryEvent({
499
473
  eventName: "AttachmentBlobsLoaded",
500
- count: (_b = (_a = snapshot.ids) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
501
- redirectTable: (_c = snapshot.redirectTable) === null || _c === void 0 ? void 0 : _c.length,
474
+ count: snapshot.ids?.length ?? 0,
475
+ redirectTable: snapshot.redirectTable?.length,
502
476
  });
503
477
  const table = new Map(snapshot.redirectTable);
504
478
  if (snapshot.ids) {
@@ -535,7 +509,7 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
535
509
  getGCData(fullGC = false) {
536
510
  const gcData = { gcNodes: {} };
537
511
  for (const [localId, storageId] of this.redirectTable) {
538
- (0, common_utils_1.assert)(!!storageId, 0x390 /* Must be attached to get GC data */);
512
+ (0, core_utils_1.assert)(!!storageId, 0x390 /* Must be attached to get GC data */);
539
513
  // Only return local ids as GC nodes because a blob can only be referenced via its local id. The storage
540
514
  // id entries have the same key and value, ignore them.
541
515
  // The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced
@@ -557,11 +531,11 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
557
531
  * Delete attachment blobs that are sweep ready.
558
532
  * @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will
559
533
  * be based off of local ids.
560
- * @returns - The routes of blobs that were deleted.
534
+ * @returns The routes of blobs that were deleted.
561
535
  */
562
536
  deleteSweepReadyNodes(sweepReadyBlobRoutes) {
563
537
  // If sweep for attachment blobs is not enabled, return empty list indicating nothing is deleted.
564
- if (this.mc.config.getBoolean(gc_1.sweepAttachmentBlobsKey) !== true) {
538
+ if (this.mc.config.getBoolean(gc_1.disableAttachmentBlobSweepKey) === true) {
565
539
  return [];
566
540
  }
567
541
  this.deleteBlobsFromRedirectTable(sweepReadyBlobRoutes);
@@ -595,14 +569,14 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
595
569
  continue;
596
570
  }
597
571
  const storageId = this.redirectTable.get(blobId);
598
- (0, common_utils_1.assert)(!!storageId, 0x5bb /* Must be attached to run GC */);
572
+ (0, core_utils_1.assert)(!!storageId, 0x5bb /* Must be attached to run GC */);
599
573
  maybeUnusedStorageIds.add(storageId);
600
574
  this.redirectTable.delete(blobId);
601
575
  }
602
576
  // Find out storage ids that are in-use and remove them from maybeUnusedStorageIds. A storage id is in-use if
603
577
  // the redirect table has a local id -> storage id entry for it.
604
578
  for (const [localId, storageId] of this.redirectTable.entries()) {
605
- (0, common_utils_1.assert)(!!storageId, 0x5bc /* Must be attached to run GC */);
579
+ (0, core_utils_1.assert)(!!storageId, 0x5bc /* Must be attached to run GC */);
606
580
  // For every storage id, the redirect table has a id -> id entry. These do not make the storage id in-use.
607
581
  if (maybeUnusedStorageIds.has(storageId) && localId !== storageId) {
608
582
  maybeUnusedStorageIds.delete(storageId);
@@ -676,27 +650,65 @@ class BlobManager extends common_utils_1.TypedEventEmitter {
676
650
  }
677
651
  }
678
652
  setRedirectTable(table) {
679
- (0, common_utils_1.assert)(this.runtime.attachState === container_definitions_1.AttachState.Detached, 0x252 /* "redirect table can only be set in detached container" */);
680
- (0, common_utils_1.assert)(this.redirectTable.size === table.size, 0x391 /* Redirect table size must match BlobManager's local ID count */);
653
+ (0, core_utils_1.assert)(this.runtime.attachState === container_definitions_1.AttachState.Detached, 0x252 /* "redirect table can only be set in detached container" */);
654
+ (0, core_utils_1.assert)(this.redirectTable.size === table.size, 0x391 /* Redirect table size must match BlobManager's local ID count */);
681
655
  for (const [localId, storageId] of table) {
682
- (0, common_utils_1.assert)(this.redirectTable.has(localId), 0x254 /* "unrecognized id in redirect table" */);
656
+ (0, core_utils_1.assert)(this.redirectTable.has(localId), 0x254 /* "unrecognized id in redirect table" */);
683
657
  this.setRedirection(localId, storageId);
684
658
  // set identity (id -> id) entry
685
659
  this.setRedirection(storageId, storageId);
686
660
  }
687
661
  }
688
- getPendingBlobs() {
689
- const blobs = {};
690
- for (const [key, entry] of this.pendingBlobs) {
691
- blobs[key] = {
692
- blob: (0, common_utils_1.bufferToString)(entry.blob, "base64"),
693
- attached: entry.attached,
694
- acked: entry.acked,
695
- minTTLInSeconds: entry.minTTLInSeconds,
696
- uploadTime: entry.uploadTime,
697
- };
698
- }
699
- return blobs;
662
+ async getPendingBlobs(waitBlobsToAttach) {
663
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "GetPendingBlobs" }, async () => {
664
+ if (this.pendingBlobs.size === 0) {
665
+ return;
666
+ }
667
+ const blobs = {};
668
+ const localBlobs = new Set();
669
+ while (localBlobs.size < this.pendingBlobs.size) {
670
+ const attachBlobsP = [];
671
+ for (const [id, entry] of this.pendingBlobs) {
672
+ if (!localBlobs.has(entry)) {
673
+ localBlobs.add(entry);
674
+ if (waitBlobsToAttach) {
675
+ if (!entry.opsent) {
676
+ this.sendBlobAttachOp(id, entry.storageId);
677
+ }
678
+ entry.handleP.resolve(this.getBlobHandle(id));
679
+ attachBlobsP.push(new Promise((resolve) => {
680
+ const onBlobAttached = (attachedEntry) => {
681
+ if (attachedEntry === entry) {
682
+ this.off("blobAttached", onBlobAttached);
683
+ resolve();
684
+ }
685
+ };
686
+ if (!entry.attached) {
687
+ this.on("blobAttached", onBlobAttached);
688
+ }
689
+ else {
690
+ resolve();
691
+ }
692
+ }));
693
+ }
694
+ }
695
+ }
696
+ await Promise.all(attachBlobsP);
697
+ }
698
+ // another for is needed to correctly mark attach state
699
+ // future optimization won't add unattached blobs to the list
700
+ for (const [id, entry] of this.pendingBlobs) {
701
+ blobs[id] = {
702
+ blob: (0, client_utils_1.bufferToString)(entry.blob, "base64"),
703
+ storageId: entry.storageId,
704
+ attached: entry.attached,
705
+ acked: entry.acked,
706
+ minTTLInSeconds: entry.minTTLInSeconds,
707
+ uploadTime: entry.uploadTime,
708
+ };
709
+ }
710
+ return blobs;
711
+ });
700
712
  }
701
713
  }
702
714
  exports.BlobManager = BlobManager;
@@ -715,7 +727,7 @@ function getGCNodePathFromBlobId(blobId) {
715
727
  */
716
728
  function getBlobIdFromGCNodePath(nodePath) {
717
729
  const pathParts = nodePath.split("/");
718
- (0, common_utils_1.assert)(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x5bd /* Invalid blob node path */);
730
+ (0, core_utils_1.assert)(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x5bd /* Invalid blob node path */);
719
731
  return pathParts[2];
720
732
  }
721
733
  //# sourceMappingURL=blobManager.js.map