@fluidframework/container-loader 2.0.2 → 2.1.0-276326

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 (227) hide show
  1. package/.eslintrc.cjs +2 -5
  2. package/api-extractor/api-extractor.legacy.json +4 -0
  3. package/api-report/container-loader.beta.api.md +0 -27
  4. package/api-report/{container-loader.alpha.api.md → container-loader.legacy.alpha.api.md} +0 -27
  5. package/api-report/container-loader.public.api.md +0 -27
  6. package/dist/attachment.d.ts +2 -1
  7. package/dist/attachment.d.ts.map +1 -1
  8. package/dist/attachment.js.map +1 -1
  9. package/dist/audience.d.ts.map +1 -1
  10. package/dist/audience.js +4 -4
  11. package/dist/audience.js.map +1 -1
  12. package/dist/catchUpMonitor.d.ts +15 -4
  13. package/dist/catchUpMonitor.d.ts.map +1 -1
  14. package/dist/catchUpMonitor.js +12 -3
  15. package/dist/catchUpMonitor.js.map +1 -1
  16. package/dist/connectionManager.d.ts +24 -8
  17. package/dist/connectionManager.d.ts.map +1 -1
  18. package/dist/connectionManager.js +36 -23
  19. package/dist/connectionManager.js.map +1 -1
  20. package/dist/connectionStateHandler.d.ts +30 -20
  21. package/dist/connectionStateHandler.d.ts.map +1 -1
  22. package/dist/connectionStateHandler.js +15 -11
  23. package/dist/connectionStateHandler.js.map +1 -1
  24. package/dist/container.d.ts +7 -2
  25. package/dist/container.d.ts.map +1 -1
  26. package/dist/container.js +45 -28
  27. package/dist/container.js.map +1 -1
  28. package/dist/containerContext.d.ts +8 -4
  29. package/dist/containerContext.d.ts.map +1 -1
  30. package/dist/containerContext.js +3 -1
  31. package/dist/containerContext.js.map +1 -1
  32. package/dist/containerStorageAdapter.d.ts +1 -1
  33. package/dist/containerStorageAdapter.d.ts.map +1 -1
  34. package/dist/containerStorageAdapter.js +12 -6
  35. package/dist/containerStorageAdapter.js.map +1 -1
  36. package/dist/contracts.d.ts +17 -8
  37. package/dist/contracts.d.ts.map +1 -1
  38. package/dist/contracts.js +4 -2
  39. package/dist/contracts.js.map +1 -1
  40. package/dist/debugLogger.js +3 -3
  41. package/dist/debugLogger.js.map +1 -1
  42. package/dist/deltaManager.d.ts +13 -9
  43. package/dist/deltaManager.d.ts.map +1 -1
  44. package/dist/deltaManager.js +32 -23
  45. package/dist/deltaManager.js.map +1 -1
  46. package/dist/deltaQueue.d.ts +1 -4
  47. package/dist/deltaQueue.d.ts.map +1 -1
  48. package/dist/deltaQueue.js +2 -2
  49. package/dist/deltaQueue.js.map +1 -1
  50. package/dist/disposal.d.ts +1 -1
  51. package/dist/disposal.d.ts.map +1 -1
  52. package/dist/disposal.js.map +1 -1
  53. package/dist/error.d.ts.map +1 -1
  54. package/dist/error.js.map +1 -1
  55. package/dist/legacy.d.ts +1 -1
  56. package/dist/loadPaused.d.ts +2 -2
  57. package/dist/loadPaused.d.ts.map +1 -1
  58. package/dist/loadPaused.js +7 -3
  59. package/dist/loadPaused.js.map +1 -1
  60. package/dist/loader.d.ts +10 -1
  61. package/dist/loader.d.ts.map +1 -1
  62. package/dist/loader.js +11 -1
  63. package/dist/loader.js.map +1 -1
  64. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
  65. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
  66. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
  67. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
  68. package/dist/memoryBlobStorage.d.ts.map +1 -1
  69. package/dist/memoryBlobStorage.js +4 -2
  70. package/dist/memoryBlobStorage.js.map +1 -1
  71. package/dist/noopHeuristic.js +1 -1
  72. package/dist/noopHeuristic.js.map +1 -1
  73. package/dist/packageVersion.d.ts +1 -1
  74. package/dist/packageVersion.d.ts.map +1 -1
  75. package/dist/packageVersion.js +1 -1
  76. package/dist/packageVersion.js.map +1 -1
  77. package/dist/protocol/protocol.d.ts +4 -3
  78. package/dist/protocol/protocol.d.ts.map +1 -1
  79. package/dist/protocol/protocol.js +6 -5
  80. package/dist/protocol/protocol.js.map +1 -1
  81. package/dist/protocol/quorum.d.ts +11 -8
  82. package/dist/protocol/quorum.d.ts.map +1 -1
  83. package/dist/protocol/quorum.js +8 -8
  84. package/dist/protocol/quorum.js.map +1 -1
  85. package/dist/protocol.d.ts +2 -0
  86. package/dist/protocol.d.ts.map +1 -1
  87. package/dist/protocol.js +7 -2
  88. package/dist/protocol.js.map +1 -1
  89. package/dist/protocolTreeDocumentStorageService.d.ts +2 -2
  90. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  91. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  92. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  93. package/dist/retriableDocumentStorageService.js +4 -1
  94. package/dist/retriableDocumentStorageService.js.map +1 -1
  95. package/dist/serializedStateManager.d.ts +29 -12
  96. package/dist/serializedStateManager.d.ts.map +1 -1
  97. package/dist/serializedStateManager.js +55 -24
  98. package/dist/serializedStateManager.js.map +1 -1
  99. package/dist/utils.d.ts +4 -2
  100. package/dist/utils.d.ts.map +1 -1
  101. package/dist/utils.js +15 -6
  102. package/dist/utils.js.map +1 -1
  103. package/lib/attachment.d.ts +2 -1
  104. package/lib/attachment.d.ts.map +1 -1
  105. package/lib/attachment.js.map +1 -1
  106. package/lib/audience.d.ts.map +1 -1
  107. package/lib/audience.js +4 -4
  108. package/lib/audience.js.map +1 -1
  109. package/lib/catchUpMonitor.d.ts +15 -4
  110. package/lib/catchUpMonitor.d.ts.map +1 -1
  111. package/lib/catchUpMonitor.js +12 -3
  112. package/lib/catchUpMonitor.js.map +1 -1
  113. package/lib/connectionManager.d.ts +24 -8
  114. package/lib/connectionManager.d.ts.map +1 -1
  115. package/lib/connectionManager.js +36 -23
  116. package/lib/connectionManager.js.map +1 -1
  117. package/lib/connectionStateHandler.d.ts +30 -20
  118. package/lib/connectionStateHandler.d.ts.map +1 -1
  119. package/lib/connectionStateHandler.js +14 -12
  120. package/lib/connectionStateHandler.js.map +1 -1
  121. package/lib/container.d.ts +7 -2
  122. package/lib/container.d.ts.map +1 -1
  123. package/lib/container.js +45 -28
  124. package/lib/container.js.map +1 -1
  125. package/lib/containerContext.d.ts +8 -4
  126. package/lib/containerContext.d.ts.map +1 -1
  127. package/lib/containerContext.js +3 -1
  128. package/lib/containerContext.js.map +1 -1
  129. package/lib/containerStorageAdapter.d.ts +1 -1
  130. package/lib/containerStorageAdapter.d.ts.map +1 -1
  131. package/lib/containerStorageAdapter.js +12 -6
  132. package/lib/containerStorageAdapter.js.map +1 -1
  133. package/lib/contracts.d.ts +17 -8
  134. package/lib/contracts.d.ts.map +1 -1
  135. package/lib/contracts.js +4 -2
  136. package/lib/contracts.js.map +1 -1
  137. package/lib/debugLogger.js +3 -3
  138. package/lib/debugLogger.js.map +1 -1
  139. package/lib/deltaManager.d.ts +13 -9
  140. package/lib/deltaManager.d.ts.map +1 -1
  141. package/lib/deltaManager.js +32 -23
  142. package/lib/deltaManager.js.map +1 -1
  143. package/lib/deltaQueue.d.ts +1 -4
  144. package/lib/deltaQueue.d.ts.map +1 -1
  145. package/lib/deltaQueue.js +2 -2
  146. package/lib/deltaQueue.js.map +1 -1
  147. package/lib/disposal.d.ts +1 -1
  148. package/lib/disposal.d.ts.map +1 -1
  149. package/lib/disposal.js.map +1 -1
  150. package/lib/error.d.ts.map +1 -1
  151. package/lib/error.js.map +1 -1
  152. package/lib/legacy.d.ts +1 -1
  153. package/lib/loadPaused.d.ts +2 -2
  154. package/lib/loadPaused.d.ts.map +1 -1
  155. package/lib/loadPaused.js +8 -4
  156. package/lib/loadPaused.js.map +1 -1
  157. package/lib/loader.d.ts +10 -1
  158. package/lib/loader.d.ts.map +1 -1
  159. package/lib/loader.js +11 -1
  160. package/lib/loader.js.map +1 -1
  161. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
  162. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
  163. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
  164. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
  165. package/lib/memoryBlobStorage.d.ts.map +1 -1
  166. package/lib/memoryBlobStorage.js +4 -2
  167. package/lib/memoryBlobStorage.js.map +1 -1
  168. package/lib/noopHeuristic.js +1 -1
  169. package/lib/noopHeuristic.js.map +1 -1
  170. package/lib/packageVersion.d.ts +1 -1
  171. package/lib/packageVersion.d.ts.map +1 -1
  172. package/lib/packageVersion.js +1 -1
  173. package/lib/packageVersion.js.map +1 -1
  174. package/lib/protocol/protocol.d.ts +4 -3
  175. package/lib/protocol/protocol.d.ts.map +1 -1
  176. package/lib/protocol/protocol.js +6 -5
  177. package/lib/protocol/protocol.js.map +1 -1
  178. package/lib/protocol/quorum.d.ts +11 -8
  179. package/lib/protocol/quorum.d.ts.map +1 -1
  180. package/lib/protocol/quorum.js +8 -8
  181. package/lib/protocol/quorum.js.map +1 -1
  182. package/lib/protocol.d.ts +2 -0
  183. package/lib/protocol.d.ts.map +1 -1
  184. package/lib/protocol.js +7 -2
  185. package/lib/protocol.js.map +1 -1
  186. package/lib/protocolTreeDocumentStorageService.d.ts +2 -2
  187. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  188. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  189. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  190. package/lib/retriableDocumentStorageService.js +4 -1
  191. package/lib/retriableDocumentStorageService.js.map +1 -1
  192. package/lib/serializedStateManager.d.ts +29 -12
  193. package/lib/serializedStateManager.d.ts.map +1 -1
  194. package/lib/serializedStateManager.js +56 -25
  195. package/lib/serializedStateManager.js.map +1 -1
  196. package/lib/utils.d.ts +4 -2
  197. package/lib/utils.d.ts.map +1 -1
  198. package/lib/utils.js +16 -7
  199. package/lib/utils.js.map +1 -1
  200. package/package.json +21 -17
  201. package/src/attachment.ts +2 -1
  202. package/src/audience.ts +4 -4
  203. package/src/catchUpMonitor.ts +23 -8
  204. package/src/connectionManager.ts +85 -60
  205. package/src/connectionStateHandler.ts +85 -63
  206. package/src/container.ts +118 -84
  207. package/src/containerContext.ts +5 -3
  208. package/src/containerStorageAdapter.ts +20 -13
  209. package/src/contracts.ts +21 -9
  210. package/src/debugLogger.ts +4 -4
  211. package/src/deltaManager.ts +75 -56
  212. package/src/deltaQueue.ts +16 -10
  213. package/src/disposal.ts +3 -3
  214. package/src/error.ts +2 -1
  215. package/src/loadPaused.ts +16 -8
  216. package/src/loader.ts +20 -2
  217. package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +7 -3
  218. package/src/memoryBlobStorage.ts +5 -3
  219. package/src/noopHeuristic.ts +1 -1
  220. package/src/packageVersion.ts +1 -1
  221. package/src/protocol/protocol.ts +12 -11
  222. package/src/protocol/quorum.ts +49 -40
  223. package/src/protocol.ts +12 -4
  224. package/src/protocolTreeDocumentStorageService.ts +3 -2
  225. package/src/retriableDocumentStorageService.ts +6 -3
  226. package/src/serializedStateManager.ts +95 -39
  227. package/src/utils.ts +26 -10
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAa7D,oEAAqE;AACrE,uEAIkD;AAElD,MAAa,+BAA+B;IAG3C,YACkB,uBAAyD,EACzD,MAA2B;QAD3B,4BAAuB,GAAvB,uBAAuB,CAAkC;QACzD,WAAM,GAAN,MAAM,CAAqB;QAJrC,cAAS,GAAG,KAAK,CAAC;QAMzB,IAAI,CAAC,uBAAuB;aAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC,CAAC;aAC9C,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACnB,CAAC;IAED,IAAW,QAAQ;QAClB,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC,sBAAsB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AAC,eAAe,CAAC,MAAM,CAAC,CAAC,EACrF,yBAAyB,CACzB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAC9E,oBAAoB,CACpB,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,QAAgB,EAAE,KAAc;QAC5D,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAC7B;gBACC,SAAS,EAAE,GAAG,QAAQ,yBAAyB;gBAC/C,aAAa,EAAE,QAAQ,EAAE,gDAAgD;aACzE,EACD,KAAK,CACL,CAAC;YACF,4DAA4D;YAC5D,MAAM,IAAI,uBAAY,CAAC,2CAA2C,EAAE;gBACnE,QAAQ,EAAE,KAAK;aACf,CAAC,CAAC;QACJ,CAAC;QACD,OAAO;IACR,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACpE,OAAO,IAAA,uBAAY,EAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD;AAjJD,0EAiJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { runWithRetry } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tGenericError,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tprivate internalStorageService: IDocumentStorageService | undefined;\n\tconstructor(\n\t\tprivate readonly internalStorageServiceP: Promise<IDocumentStorageService>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.internalStorageServiceP\n\t\t\t.then((s) => (this.internalStorageService = s))\n\t\t\t.catch(() => {});\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.policies;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getSnapshotTree(version, scenarioName),\n\t\t\t\t),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) => {\n\t\t\t\t\tif (s.getSnapshot !== undefined) {\n\t\t\t\t\t\treturn s.getSnapshot(snapshotFetchOptions);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"getSnapshot api should exist on internal storage in RetriableDocStorageService class\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t\"storage_getSnapshot\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getVersions(versionId, count, scenarioName, fetchSource),\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageServiceP.then(async (s) =>\n\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t\t),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.downloadSummary(handle)),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.createBlob(file)),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAa7D,oEAAqE;AACrE,uEAIkD;AAElD,MAA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AAA,uBAAY,EAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD;AApJD,0EAoJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { runWithRetry } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tGenericError,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tprivate internalStorageService: IDocumentStorageService | undefined;\n\tconstructor(\n\t\tprivate readonly internalStorageServiceP: Promise<IDocumentStorageService>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.internalStorageServiceP\n\t\t\t.then((s) => (this.internalStorageService = s))\n\t\t\t.catch(() => {});\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.policies;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null -- API used below returns null\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getSnapshotTree(version, scenarioName),\n\t\t\t\t),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) => {\n\t\t\t\t\tif (s.getSnapshot !== undefined) {\n\t\t\t\t\t\treturn s.getSnapshot(snapshotFetchOptions);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"getSnapshot api should exist on internal storage in RetriableDocStorageService class\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t\"storage_getSnapshot\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\t// API used below returns null\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getVersions(versionId, count, scenarioName, fetchSource),\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageServiceP.then(async (s) =>\n\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t\t),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.downloadSummary(handle)),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.createBlob(file)),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown): void {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
@@ -34,7 +34,9 @@ export interface SnapshotWithBlobs {
34
34
  * @internal
35
35
  */
36
36
  export interface IPendingContainerState extends SnapshotWithBlobs {
37
- /** This container was attached (as opposed to IPendingDetachedContainerState.attached which is false) */
37
+ /**
38
+ * This container was attached (as opposed to IPendingDetachedContainerState.attached which is false)
39
+ */
38
40
  attached: true;
39
41
  /**
40
42
  * Runtime-specific state that will be needed to properly rehydrate
@@ -51,9 +53,13 @@ export interface IPendingContainerState extends SnapshotWithBlobs {
51
53
  * ops at the same sequence number at which they were made.
52
54
  */
53
55
  savedOps: ISequencedDocumentMessage[];
54
- /** The Container's URL in the service, needed to hook up the driver during rehydration */
56
+ /**
57
+ * The Container's URL in the service, needed to hook up the driver during rehydration
58
+ */
55
59
  url: string;
56
- /** If the Container was connected when serialized, its clientId. Used as the initial clientId upon rehydration, until reconnected. */
60
+ /**
61
+ * If the Container was connected when serialized, its clientId. Used as the initial clientId upon rehydration, until reconnected.
62
+ */
57
63
  clientId?: string;
58
64
  }
59
65
  /**
@@ -62,11 +68,17 @@ export interface IPendingContainerState extends SnapshotWithBlobs {
62
68
  * @internal
63
69
  */
64
70
  export interface IPendingDetachedContainerState extends SnapshotWithBlobs {
65
- /** This container was not attached (as opposed to IPendingContainerState.attached which is true) */
71
+ /**
72
+ * This container was not attached (as opposed to IPendingContainerState.attached which is true)
73
+ */
66
74
  attached: false;
67
- /** Indicates whether we expect the rehydrated container to have non-empty Detached Blob Storage */
75
+ /**
76
+ * Indicates whether we expect the rehydrated container to have non-empty Detached Blob Storage
77
+ */
68
78
  hasAttachmentBlobs: boolean;
69
- /** Used by the memory blob storage to persisted attachment blobs */
79
+ /**
80
+ * Used by the memory blob storage to persisted attachment blobs
81
+ */
70
82
  attachmentBlobs?: string;
71
83
  /**
72
84
  * Runtime-specific state that will be needed to properly rehydrate
@@ -101,8 +113,10 @@ export declare class SerializedStateManager {
101
113
  private readonly mc;
102
114
  private snapshot;
103
115
  private latestSnapshot;
104
- private refreshSnapshotP;
116
+ private _refreshSnapshotP;
105
117
  private readonly lastSavedOpSequenceNumber;
118
+ private readonly refreshTimer;
119
+ private readonly snapshotRefreshTimeoutMs;
106
120
  /**
107
121
  * @param pendingLocalState - The pendingLocalState being rehydrated, if any (undefined when loading directly from storage)
108
122
  * @param subLogger - Container's logger to use as parent for our logger
@@ -111,12 +125,14 @@ export declare class SerializedStateManager {
111
125
  * @param containerEvent - Source of the "saved" event when the container has all its pending state uploaded
112
126
  * @param containerDirty - Is the container "dirty"? That's the opposite of "saved" - there is pending state that may not have been received yet by the service.
113
127
  */
114
- constructor(pendingLocalState: IPendingContainerState | undefined, subLogger: ITelemetryBaseLogger, storageAdapter: ISerializedStateManagerDocumentStorageService, _offlineLoadEnabled: boolean, containerEvent: IEventProvider<ISerializerEvent>, containerDirty: () => boolean, supportGetSnapshotApi: () => boolean);
128
+ constructor(pendingLocalState: IPendingContainerState | undefined, subLogger: ITelemetryBaseLogger, storageAdapter: ISerializedStateManagerDocumentStorageService, _offlineLoadEnabled: boolean, containerEvent: IEventProvider<ISerializerEvent>, containerDirty: () => boolean, supportGetSnapshotApi: () => boolean, snapshotRefreshTimeoutMs?: number);
115
129
  get offlineLoadEnabled(): boolean;
116
130
  /**
117
131
  * Promise that will resolve (or reject) once we've tried to download the latest snapshot(s) from storage
132
+ * only intended to be used for testing purposes.
133
+ * @returns The snapshot sequence number associated with the latest fetched snapshot
118
134
  */
119
- get waitForInitialRefresh(): Promise<void> | undefined;
135
+ get refreshSnapshotP(): Promise<number> | undefined;
120
136
  /**
121
137
  * Called whenever an incoming op is processed by the Container
122
138
  */
@@ -125,16 +141,17 @@ export declare class SerializedStateManager {
125
141
  * This wraps the basic functionality of fetching the snapshot for this container during Container load.
126
142
  *
127
143
  * If we have pendingLocalState, we get the snapshot from there.
128
- * Otherwise, fetch it from storage (according to specifiedVersion if provided)
144
+ * Otherwise, fetch it from storage (according to specifiedVersion if provided).
129
145
  *
130
- * @param specifiedVersion - If a version is specified and we don't have pendingLocalState, fetch this version from storage
146
+ * @param specifiedVersion - If a version is specified and we don't have pendingLocalState, fetch this version from storage.
131
147
  * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.
132
148
  * @returns The snapshot to boot the container from
133
149
  */
134
150
  fetchSnapshot(specifiedVersion: string | undefined): Promise<{
135
- baseSnapshot: ISnapshotTree | ISnapshot;
151
+ baseSnapshot: ISnapshot | ISnapshotTree;
136
152
  version: IVersion | undefined;
137
153
  }>;
154
+ private tryRefreshSnapshot;
138
155
  /**
139
156
  * Fetch the latest snapshot for the container, including delay-loaded groupIds if pendingLocalState was provided and contained any groupIds.
140
157
  * Note that this will update the StorageAdapter's cached snapshots for the groupIds (if present)
@@ -1 +1 @@
1
- {"version":3,"file":"serializedStateManager.d.ts","sourceRoot":"","sources":["../src/serializedStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,0BAA0B,EAC1B,QAAQ,EACR,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,cAAc,EACd,MAAM,EACN,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAEN,uBAAuB,EACvB,YAAY,EACZ,SAAS,EAET,aAAa,EACb,QAAQ,EACR,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO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AE,QAAQ,CAAC,EAAE,aAAa,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC,CAwBvE"}
@@ -28,7 +28,7 @@ class SerializedStateManager {
28
28
  * @param containerEvent - Source of the "saved" event when the container has all its pending state uploaded
29
29
  * @param containerDirty - Is the container "dirty"? That's the opposite of "saved" - there is pending state that may not have been received yet by the service.
30
30
  */
31
- constructor(pendingLocalState, subLogger, storageAdapter, _offlineLoadEnabled, containerEvent, containerDirty, supportGetSnapshotApi) {
31
+ constructor(pendingLocalState, subLogger, storageAdapter, _offlineLoadEnabled, containerEvent, containerDirty, supportGetSnapshotApi, snapshotRefreshTimeoutMs) {
32
32
  this.pendingLocalState = pendingLocalState;
33
33
  this.storageAdapter = storageAdapter;
34
34
  this._offlineLoadEnabled = _offlineLoadEnabled;
@@ -36,10 +36,13 @@ class SerializedStateManager {
36
36
  this.supportGetSnapshotApi = supportGetSnapshotApi;
37
37
  this.processedOps = [];
38
38
  this.lastSavedOpSequenceNumber = 0;
39
+ this.snapshotRefreshTimeoutMs = 60 * 60 * 24 * 1000;
39
40
  this.mc = (0, internal_4.createChildMonitoringContext)({
40
41
  logger: subLogger,
41
42
  namespace: "serializedStateManager",
42
43
  });
44
+ this.snapshotRefreshTimeoutMs = snapshotRefreshTimeoutMs ?? this.snapshotRefreshTimeoutMs;
45
+ this.refreshTimer = new internal_1.Timer(this.snapshotRefreshTimeoutMs, () => this.tryRefreshSnapshot());
43
46
  // special case handle. Obtaining the last saved op seq num to avoid
44
47
  // refreshing the snapshot before we have processed it. It could cause
45
48
  // a subsequent stashing to have a newer snapshot than allowed.
@@ -48,16 +51,18 @@ class SerializedStateManager {
48
51
  this.lastSavedOpSequenceNumber =
49
52
  pendingLocalState.savedOps[savedOpsSize - 1].sequenceNumber;
50
53
  }
51
- containerEvent.once("saved", () => this.updateSnapshotAndProcessedOpsMaybe());
54
+ containerEvent.on("saved", () => this.updateSnapshotAndProcessedOpsMaybe());
52
55
  }
53
56
  get offlineLoadEnabled() {
54
57
  return this._offlineLoadEnabled;
55
58
  }
56
59
  /**
57
60
  * Promise that will resolve (or reject) once we've tried to download the latest snapshot(s) from storage
61
+ * only intended to be used for testing purposes.
62
+ * @returns The snapshot sequence number associated with the latest fetched snapshot
58
63
  */
59
- get waitForInitialRefresh() {
60
- return this.refreshSnapshotP;
64
+ get refreshSnapshotP() {
65
+ return this._refreshSnapshotP;
61
66
  }
62
67
  /**
63
68
  * Called whenever an incoming op is processed by the Container
@@ -72,9 +77,9 @@ class SerializedStateManager {
72
77
  * This wraps the basic functionality of fetching the snapshot for this container during Container load.
73
78
  *
74
79
  * If we have pendingLocalState, we get the snapshot from there.
75
- * Otherwise, fetch it from storage (according to specifiedVersion if provided)
80
+ * Otherwise, fetch it from storage (according to specifiedVersion if provided).
76
81
  *
77
- * @param specifiedVersion - If a version is specified and we don't have pendingLocalState, fetch this version from storage
82
+ * @param specifiedVersion - If a version is specified and we don't have pendingLocalState, fetch this version from storage.
78
83
  * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.
79
84
  * @returns The snapshot to boot the container from
80
85
  */
@@ -91,6 +96,7 @@ class SerializedStateManager {
91
96
  snapshotBlobs,
92
97
  snapshotSequenceNumber: attributes.sequenceNumber,
93
98
  };
99
+ this.refreshTimer.start();
94
100
  }
95
101
  return { baseSnapshot, version };
96
102
  }
@@ -102,17 +108,7 @@ class SerializedStateManager {
102
108
  snapshotBlobs,
103
109
  snapshotSequenceNumber: attributes.sequenceNumber,
104
110
  };
105
- if (this.refreshSnapshotP === undefined &&
106
- this.mc.config.getBoolean("Fluid.Container.enableOfflineSnapshotRefresh") === true) {
107
- // Don't block on the refresh snapshot call - it is for the next time we serialize, not booting this incarnation
108
- this.refreshSnapshotP = this.refreshLatestSnapshot(this.supportGetSnapshotApi());
109
- this.refreshSnapshotP.catch((e) => {
110
- this.mc.logger.sendErrorEvent({
111
- eventName: "RefreshLatestSnapshotFailed",
112
- error: e,
113
- });
114
- });
115
- }
111
+ this.tryRefreshSnapshot();
116
112
  const blobContents = new Map();
117
113
  for (const [id, value] of Object.entries(snapshotBlobs)) {
118
114
  blobContents.set(id, (0, client_utils_1.stringToBuffer)(value, "utf8"));
@@ -128,6 +124,24 @@ class SerializedStateManager {
128
124
  return { baseSnapshot: iSnapshot, version: undefined };
129
125
  }
130
126
  }
127
+ tryRefreshSnapshot() {
128
+ if (this.mc.config.getBoolean("Fluid.Container.enableOfflineSnapshotRefresh") === true &&
129
+ this._refreshSnapshotP === undefined &&
130
+ this.latestSnapshot === undefined) {
131
+ // Don't block on the refresh snapshot call - it is for the next time we serialize, not booting this incarnation
132
+ this._refreshSnapshotP = this.refreshLatestSnapshot(this.supportGetSnapshotApi());
133
+ this._refreshSnapshotP
134
+ .catch((error) => {
135
+ this.mc.logger.sendTelemetryEvent({
136
+ eventName: "RefreshLatestSnapshotFailed",
137
+ error,
138
+ });
139
+ })
140
+ .finally(() => {
141
+ this._refreshSnapshotP = undefined;
142
+ });
143
+ }
144
+ }
131
145
  /**
132
146
  * Fetch the latest snapshot for the container, including delay-loaded groupIds if pendingLocalState was provided and contained any groupIds.
133
147
  * Note that this will update the StorageAdapter's cached snapshots for the groupIds (if present)
@@ -151,22 +165,22 @@ class SerializedStateManager {
151
165
  });
152
166
  (0, internal_1.assert)(snapshot !== undefined, 0x973 /* Snapshot should exist */);
153
167
  }
154
- this.updateSnapshotAndProcessedOpsMaybe();
168
+ return this.updateSnapshotAndProcessedOpsMaybe();
155
169
  }
156
170
  /**
157
171
  * Updates class snapshot and processedOps if we have a new snapshot and it's among processedOps range.
158
172
  */
159
173
  updateSnapshotAndProcessedOpsMaybe() {
160
- if (this.latestSnapshot === undefined ||
174
+ const snapshotSequenceNumber = this.latestSnapshot?.snapshotSequenceNumber;
175
+ if (snapshotSequenceNumber === undefined ||
161
176
  this.processedOps.length === 0 ||
162
177
  this.processedOps[this.processedOps.length - 1].sequenceNumber <
163
178
  this.lastSavedOpSequenceNumber ||
164
179
  this.containerDirty()) {
165
180
  // can't refresh latest snapshot until we have processed the ops up to it.
166
181
  // Pending state would be behind the latest snapshot.
167
- return;
182
+ return -1;
168
183
  }
169
- const snapshotSequenceNumber = this.latestSnapshot.snapshotSequenceNumber;
170
184
  const firstProcessedOpSequenceNumber = this.processedOps[0].sequenceNumber;
171
185
  const lastProcessedOpSequenceNumber = this.processedOps[this.processedOps.length - 1].sequenceNumber;
172
186
  if (snapshotSequenceNumber < firstProcessedOpSequenceNumber) {
@@ -180,6 +194,7 @@ class SerializedStateManager {
180
194
  stashedSnapshotSequenceNumber: this.snapshot?.snapshotSequenceNumber,
181
195
  });
182
196
  this.latestSnapshot = undefined;
197
+ this.refreshTimer.restart();
183
198
  }
184
199
  else if (snapshotSequenceNumber <= lastProcessedOpSequenceNumber) {
185
200
  // Snapshot seq num is between the first and last processed op.
@@ -187,6 +202,7 @@ class SerializedStateManager {
187
202
  this.processedOps.splice(0, snapshotSequenceNumber - firstProcessedOpSequenceNumber + 1);
188
203
  this.snapshot = this.latestSnapshot;
189
204
  this.latestSnapshot = undefined;
205
+ this.refreshTimer.restart();
190
206
  this.mc.logger.sendTelemetryEvent({
191
207
  eventName: "SnapshotRefreshed",
192
208
  snapshotSequenceNumber,
@@ -194,6 +210,7 @@ class SerializedStateManager {
194
210
  newFirstProcessedOpSequenceNumber: this.processedOps.length === 0 ? undefined : this.processedOps[0].sequenceNumber,
195
211
  });
196
212
  }
213
+ return snapshotSequenceNumber;
197
214
  }
198
215
  /**
199
216
  * When the Container attaches, we need to stash the initial snapshot (a form of the attach summary).
@@ -209,9 +226,17 @@ class SerializedStateManager {
209
226
  const attributesHash = ".protocol" in baseSnapshot.trees
210
227
  ? baseSnapshot.trees[".protocol"].blobs.attributes
211
228
  : baseSnapshot.blobs[".attributes"];
229
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
212
230
  const attributes = JSON.parse(snapshotBlobs[attributesHash]);
213
- (0, internal_1.assert)(attributes.sequenceNumber === 0, 0x939 /* trying to set a non attachment snapshot */);
214
- this.snapshot = { ...snapshot, snapshotSequenceNumber: attributes.sequenceNumber };
231
+ (0, internal_1.assert)(
232
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
233
+ attributes.sequenceNumber === 0, 0x939 /* trying to set a non attachment snapshot */);
234
+ this.snapshot = {
235
+ ...snapshot,
236
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
237
+ snapshotSequenceNumber: attributes.sequenceNumber,
238
+ };
239
+ this.refreshTimer.start();
215
240
  }
216
241
  }
217
242
  /**
@@ -273,7 +298,11 @@ exports.SerializedStateManager = SerializedStateManager;
273
298
  */
274
299
  async function getLatestSnapshotInfo(mc, storageAdapter, supportGetSnapshotApi) {
275
300
  return internal_4.PerformanceEvent.timedExecAsync(mc.logger, { eventName: "GetLatestSnapshotInfo" }, async () => {
276
- const { baseSnapshot } = await getSnapshot(mc, storageAdapter, supportGetSnapshotApi, undefined);
301
+ // get the latest non cached snapshot version
302
+ const specifiedVersion = await storageAdapter.getVersions(
303
+ // eslint-disable-next-line unicorn/no-null
304
+ null, 1, "getLatestSnapshotInfo", internal_2.FetchSource.noCache);
305
+ const { baseSnapshot } = await getSnapshot(mc, storageAdapter, supportGetSnapshotApi, specifiedVersion[0]?.id);
277
306
  const baseSnapshotTree = (0, internal_3.getSnapshotTree)(baseSnapshot);
278
307
  const snapshotFetchedTime = Date.now();
279
308
  const snapshotBlobs = await (0, containerStorageAdapter_js_1.getBlobContentsFromTree)(baseSnapshotTree, storageAdapter);
@@ -344,6 +373,8 @@ exports.fetchISnapshot = fetchISnapshot;
344
373
  * @returns - The fetched snapshot tree and its version.
345
374
  */
346
375
  async function fetchISnapshotTree(mc, storageAdapter, specifiedVersion) {
376
+ // API uses null
377
+ // eslint-disable-next-line unicorn/no-null
347
378
  const versions = await storageAdapter.getVersions(specifiedVersion ?? null, 1);
348
379
  const version = versions[0];
349
380
  if (version === undefined && specifiedVersion !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"serializedStateManager.js","sourceRoot":"","sources":["../src/serializedStateManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAU9D,kEAA6D;AAC7D,0EASqD;AACrD,oEAAwE;AACxE,uEAKkD;AAElD,6EAGsC;AACtC,yCAAkF;AAwFlF;;;;;;GAMG;AACH,MAAa,sBAAsB;IAQlC;;;;;;;OAOG;IACH,YACkB,iBAAqD,EACtE,SAA+B,EACd,cAA6D,EAC7D,mBAA4B,EAC7C,cAAgD,EAC/B,cAA6B,EAC7B,qBAAoC;QANpC,sBAAiB,GAAjB,iBAAiB,CAAoC;QAErD,mBAAc,GAAd,cAAc,CAA+C;QAC7D,wBAAmB,GAAnB,mBAAmB,CAAS;QAE5B,mBAAc,GAAd,cAAc,CAAe;QAC7B,0BAAqB,GAArB,qBAAqB,CAAe;QAtBrC,iBAAY,GAAgC,EAAE,CAAC;QAK/C,8BAAyB,GAAW,CAAC,CAAC;QAmBtD,IAAI,CAAC,EAAE,GAAG,IAAA,uCAA4B,EAAC;YACtC,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,wBAAwB;SACnC,CAAC,CAAC;QAEH,oEAAoE;QACpE,sEAAsE;QACtE,+DAA+D;QAC/D,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChE,MAAM,YAAY,GAAG,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC;YACvD,IAAI,CAAC,yBAAyB;gBAC7B,iBAAiB,CAAC,QAAQ,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC;QAC9D,CAAC;QACD,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACjC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AAC,CAAC;IAE5B,IAAI,OAAO,KAAK,SAAS,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC7D,+EAA+E;QAC/E,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;YACxB,SAAS,EAAE,6BAA6B;YACxC,EAAE,EAAE,gBAAgB;SACpB,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,MAAM,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,SAAS,CAAC;IAE9E,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACrD,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,EAAE,EAAE,KAAK,SAAS,EAAE,CAAC;QAChE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;YACxB,SAAS,EAAE,wCAAwC;YACnD,UAAU,EAAE,OAAO,KAAK,SAAS,EAAE,mFAAmF;SACtH,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AA1BD,gDA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tIGetPendingLocalStateProps,\n\tIRuntime,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIEventProvider,\n\tIEvent,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISnapshot,\n\ttype IDocumentAttributes,\n\tISnapshotTree,\n\tIVersion,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { getSnapshotTree } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tMonitoringContext,\n\tPerformanceEvent,\n\tUsageError,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tISerializableBlobContents,\n\tgetBlobContentsFromTree,\n} from \"./containerStorageAdapter.js\";\nimport { convertSnapshotToSnapshotInfo, getDocumentAttributes } from \"./utils.js\";\n\n/**\n * This is very similar to {@link @fluidframework/protocol-definitions/internal#ISnapshot}, but the difference is\n * that the blobs of ISnapshot are of type ArrayBufferLike, while the blobs of this interface are serializable because\n * they are already converted to string.\n */\nexport interface SnapshotWithBlobs {\n\t/**\n\t * Snapshot from which container initially loaded.\n\t */\n\tbaseSnapshot: ISnapshotTree;\n\t/**\n\t * Serializable blobs from the base snapshot. Used to load offline since\n\t * storage is not available.\n\t */\n\tsnapshotBlobs: ISerializableBlobContents;\n}\n\n/**\n * State saved by a container at close time, to be used to load a new instance\n * of the container to the same state\n *\n * This is very similar to {@link @fluidframework/protocol-definitions/internal#ISnapshot}, but the difference is\n * that the blobs of ISnapshot are of type ArrayBufferLike, while the blobs of this interface are serializable because\n * they are already converted to string.\n *\n * @internal\n */\nexport interface IPendingContainerState extends SnapshotWithBlobs {\n\t/** This container was attached (as opposed to IPendingDetachedContainerState.attached which is false) */\n\tattached: true;\n\t/**\n\t * Runtime-specific state that will be needed to properly rehydrate\n\t * (it's included in ContainerContext passed to instantiateRuntime)\n\t */\n\tpendingRuntimeState: unknown;\n\t/**\n\t * Any group snapshots (aka delay-loaded) we've downloaded from the service for this container\n\t */\n\tloadedGroupIdSnapshots?: Record<string, ISnapshotInfo>;\n\t/**\n\t * All ops since base snapshot sequence number up to the latest op\n\t * seen when the container was closed. Used to apply stashed (saved pending)\n\t * ops at the same sequence number at which they were made.\n\t */\n\tsavedOps: ISequencedDocumentMessage[];\n\t/** The Container's URL in the service, needed to hook up the driver during rehydration */\n\turl: string;\n\t/** If the Container was connected when serialized, its clientId. Used as the initial clientId upon rehydration, until reconnected. */\n\tclientId?: string;\n}\n\n/**\n * State saved by a container in detached state, to be used to load a new instance\n * of the container to the same state (rehydrate)\n * @internal\n */\nexport interface IPendingDetachedContainerState extends SnapshotWithBlobs {\n\t/** This container was not attached (as opposed to IPendingContainerState.attached which is true) */\n\tattached: false;\n\t/** Indicates whether we expect the rehydrated container to have non-empty Detached Blob Storage */\n\thasAttachmentBlobs: boolean;\n\t/** Used by the memory blob storage to persisted attachment blobs */\n\tattachmentBlobs?: string;\n\t/**\n\t * Runtime-specific state that will be needed to properly rehydrate\n\t * (it's included in ContainerContext passed to instantiateRuntime)\n\t */\n\tpendingRuntimeState?: unknown;\n}\n\nexport interface ISnapshotInfo extends SnapshotWithBlobs {\n\tsnapshotSequenceNumber: number;\n\tsnapshotFetchedTime?: number | undefined;\n}\n\nexport type ISerializedStateManagerDocumentStorageService = Pick<\n\tIDocumentStorageService,\n\t\"getSnapshot\" | \"getSnapshotTree\" | \"getVersions\" | \"readBlob\"\n> & {\n\tloadedGroupIdSnapshots: Record<string, ISnapshot>;\n};\n\ninterface ISerializerEvent extends IEvent {\n\t(event: \"saved\", listener: (dirty: boolean) => void): void;\n}\n\n/**\n * Helper class to manage the state of the container needed for proper serialization.\n *\n * It holds the pendingLocalState the container was rehydrated from (if any),\n * as well as the snapshot to be used for serialization.\n * It also keeps track of container dirty state and which local ops have been processed\n */\nexport class SerializedStateManager {\n\tprivate readonly processedOps: ISequencedDocumentMessage[] = [];\n\tprivate readonly mc: MonitoringContext;\n\tprivate snapshot: ISnapshotInfo | undefined;\n\tprivate latestSnapshot: ISnapshotInfo | undefined;\n\tprivate refreshSnapshotP: Promise<void> | undefined;\n\tprivate readonly lastSavedOpSequenceNumber: number = 0;\n\n\t/**\n\t * @param pendingLocalState - The pendingLocalState being rehydrated, if any (undefined when loading directly from storage)\n\t * @param subLogger - Container's logger to use as parent for our logger\n\t * @param storageAdapter - Storage adapter for fetching snapshots\n\t * @param _offlineLoadEnabled - Is serializing/rehydrating containers allowed?\n\t * @param containerEvent - Source of the \"saved\" event when the container has all its pending state uploaded\n\t * @param containerDirty - Is the container \"dirty\"? That's the opposite of \"saved\" - there is pending state that may not have been received yet by the service.\n\t */\n\tconstructor(\n\t\tprivate readonly pendingLocalState: IPendingContainerState | undefined,\n\t\tsubLogger: ITelemetryBaseLogger,\n\t\tprivate readonly storageAdapter: ISerializedStateManagerDocumentStorageService,\n\t\tprivate readonly _offlineLoadEnabled: boolean,\n\t\tcontainerEvent: IEventProvider<ISerializerEvent>,\n\t\tprivate readonly containerDirty: () => boolean,\n\t\tprivate readonly supportGetSnapshotApi: () => boolean,\n\t) {\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: subLogger,\n\t\t\tnamespace: \"serializedStateManager\",\n\t\t});\n\n\t\t// special case handle. Obtaining the last saved op seq num to avoid\n\t\t// refreshing the snapshot before we have processed it. It could cause\n\t\t// a subsequent stashing to have a newer snapshot than allowed.\n\t\tif (pendingLocalState && pendingLocalState.savedOps.length > 0) {\n\t\t\tconst savedOpsSize = pendingLocalState.savedOps.length;\n\t\t\tthis.lastSavedOpSequenceNumber =\n\t\t\t\tpendingLocalState.savedOps[savedOpsSize - 1].sequenceNumber;\n\t\t}\n\t\tcontainerEvent.once(\"saved\", () => this.updateSnapshotAndProcessedOpsMaybe());\n\t}\n\n\tpublic get offlineLoadEnabled(): boolean {\n\t\treturn this._offlineLoadEnabled;\n\t}\n\n\t/**\n\t * Promise that will resolve (or reject) once we've tried to download the latest snapshot(s) from storage\n\t */\n\tpublic get waitForInitialRefresh(): Promise<void> | undefined {\n\t\treturn this.refreshSnapshotP;\n\t}\n\n\t/**\n\t * Called whenever an incoming op is processed by the Container\n\t */\n\tpublic addProcessedOp(message: ISequencedDocumentMessage) {\n\t\tif (this.offlineLoadEnabled) {\n\t\t\tthis.processedOps.push(message);\n\t\t\tthis.updateSnapshotAndProcessedOpsMaybe();\n\t\t}\n\t}\n\n\t/**\n\t * This wraps the basic functionality of fetching the snapshot for this container during Container load.\n\t *\n\t * If we have pendingLocalState, we get the snapshot from there.\n\t * Otherwise, fetch it from storage (according to specifiedVersion if provided)\n\t *\n\t * @param specifiedVersion - If a version is specified and we don't have pendingLocalState, fetch this version from storage\n\t * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.\n\t * @returns The snapshot to boot the container from\n\t */\n\tpublic async fetchSnapshot(specifiedVersion: string | undefined) {\n\t\tif (this.pendingLocalState === undefined) {\n\t\t\tconst { baseSnapshot, version } = await getSnapshot(\n\t\t\t\tthis.mc,\n\t\t\t\tthis.storageAdapter,\n\t\t\t\tthis.supportGetSnapshotApi(),\n\t\t\t\tspecifiedVersion,\n\t\t\t);\n\t\t\tconst baseSnapshotTree: ISnapshotTree | undefined = getSnapshotTree(baseSnapshot);\n\t\t\t// non-interactive clients will not have any pending state we want to save\n\t\t\tif (this.offlineLoadEnabled) {\n\t\t\t\tconst snapshotBlobs = await getBlobContentsFromTree(\n\t\t\t\t\tbaseSnapshotTree,\n\t\t\t\t\tthis.storageAdapter,\n\t\t\t\t);\n\t\t\t\tconst attributes = await getDocumentAttributes(this.storageAdapter, baseSnapshotTree);\n\t\t\t\tthis.snapshot = {\n\t\t\t\t\tbaseSnapshot: baseSnapshotTree,\n\t\t\t\t\tsnapshotBlobs,\n\t\t\t\t\tsnapshotSequenceNumber: attributes.sequenceNumber,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { baseSnapshot, version };\n\t\t} else {\n\t\t\tconst { baseSnapshot, snapshotBlobs } = this.pendingLocalState;\n\t\t\tconst attributes = await getDocumentAttributes(this.storageAdapter, baseSnapshot);\n\t\t\tthis.snapshot = {\n\t\t\t\tbaseSnapshot,\n\t\t\t\tsnapshotBlobs,\n\t\t\t\tsnapshotSequenceNumber: attributes.sequenceNumber,\n\t\t\t};\n\n\t\t\tif (\n\t\t\t\tthis.refreshSnapshotP === undefined &&\n\t\t\t\tthis.mc.config.getBoolean(\"Fluid.Container.enableOfflineSnapshotRefresh\") === true\n\t\t\t) {\n\t\t\t\t// Don't block on the refresh snapshot call - it is for the next time we serialize, not booting this incarnation\n\t\t\t\tthis.refreshSnapshotP = this.refreshLatestSnapshot(this.supportGetSnapshotApi());\n\t\t\t\tthis.refreshSnapshotP.catch((e) => {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"RefreshLatestSnapshotFailed\",\n\t\t\t\t\t\terror: e,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\t\tfor (const [id, value] of Object.entries(snapshotBlobs)) {\n\t\t\t\tblobContents.set(id, stringToBuffer(value, \"utf8\"));\n\t\t\t}\n\t\t\tconst iSnapshot: ISnapshot = {\n\t\t\t\tsequenceNumber: this.snapshot.snapshotSequenceNumber,\n\t\t\t\tsnapshotTree: baseSnapshot,\n\t\t\t\tblobContents,\n\t\t\t\tlatestSequenceNumber: undefined,\n\t\t\t\tops: [],\n\t\t\t\tsnapshotFormatV: 1,\n\t\t\t};\n\t\t\treturn { baseSnapshot: iSnapshot, version: undefined };\n\t\t}\n\t}\n\n\t/**\n\t * Fetch the latest snapshot for the container, including delay-loaded groupIds if pendingLocalState was provided and contained any groupIds.\n\t * Note that this will update the StorageAdapter's cached snapshots for the groupIds (if present)\n\t *\n\t * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree (must be true to fetch by groupIds)\n\t */\n\tprivate async refreshLatestSnapshot(supportGetSnapshotApi: boolean): Promise<void> {\n\t\tthis.latestSnapshot = await getLatestSnapshotInfo(\n\t\t\tthis.mc,\n\t\t\tthis.storageAdapter,\n\t\t\tsupportGetSnapshotApi,\n\t\t);\n\n\t\t// These are loading groupIds that the containerRuntime has requested over its lifetime.\n\t\t// We will fetch the latest snapshot for the groupIds, which will update storageAdapter.loadedGroupIdSnapshots's cache\n\t\tconst downloadedGroupIds = Object.keys(this.storageAdapter.loadedGroupIdSnapshots);\n\t\tif (supportGetSnapshotApi && downloadedGroupIds.length > 0) {\n\t\t\tassert(\n\t\t\t\tthis.storageAdapter.getSnapshot !== undefined,\n\t\t\t\t0x972 /* getSnapshot should exist */,\n\t\t\t);\n\t\t\t// (This is a separate network call from above because it requires work for storage to add a special base groupId)\n\t\t\tconst snapshot = await this.storageAdapter.getSnapshot({\n\t\t\t\tversionId: undefined,\n\t\t\t\tscenarioName: \"getLatestSnapshotInfo\",\n\t\t\t\tcacheSnapshot: false,\n\t\t\t\tloadingGroupIds: downloadedGroupIds,\n\t\t\t\tfetchSource: FetchSource.noCache,\n\t\t\t});\n\t\t\tassert(snapshot !== undefined, 0x973 /* Snapshot should exist */);\n\t\t}\n\n\t\tthis.updateSnapshotAndProcessedOpsMaybe();\n\t}\n\n\t/**\n\t * Updates class snapshot and processedOps if we have a new snapshot and it's among processedOps range.\n\t */\n\tprivate updateSnapshotAndProcessedOpsMaybe() {\n\t\tif (\n\t\t\tthis.latestSnapshot === undefined ||\n\t\t\tthis.processedOps.length === 0 ||\n\t\t\tthis.processedOps[this.processedOps.length - 1].sequenceNumber <\n\t\t\t\tthis.lastSavedOpSequenceNumber ||\n\t\t\tthis.containerDirty()\n\t\t) {\n\t\t\t// can't refresh latest snapshot until we have processed the ops up to it.\n\t\t\t// Pending state would be behind the latest snapshot.\n\t\t\treturn;\n\t\t}\n\t\tconst snapshotSequenceNumber = this.latestSnapshot.snapshotSequenceNumber;\n\t\tconst firstProcessedOpSequenceNumber = this.processedOps[0].sequenceNumber;\n\t\tconst lastProcessedOpSequenceNumber =\n\t\t\tthis.processedOps[this.processedOps.length - 1].sequenceNumber;\n\n\t\tif (snapshotSequenceNumber < firstProcessedOpSequenceNumber) {\n\t\t\t// Snapshot seq number is older than our first processed op, which could mean we're fetching\n\t\t\t// the same snapshot that we already have or snapshot is too old, implicating an unexpected behavior.\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"OldSnapshotFetchWhileRefreshing\",\n\t\t\t\tsnapshotSequenceNumber,\n\t\t\t\tfirstProcessedOpSequenceNumber,\n\t\t\t\tlastProcessedOpSequenceNumber,\n\t\t\t\tstashedSnapshotSequenceNumber: this.snapshot?.snapshotSequenceNumber,\n\t\t\t});\n\t\t\tthis.latestSnapshot = undefined;\n\t\t} else if (snapshotSequenceNumber <= lastProcessedOpSequenceNumber) {\n\t\t\t// Snapshot seq num is between the first and last processed op.\n\t\t\t// Remove the ops that are already part of the snapshot\n\t\t\tthis.processedOps.splice(0, snapshotSequenceNumber - firstProcessedOpSequenceNumber + 1);\n\t\t\tthis.snapshot = this.latestSnapshot;\n\t\t\tthis.latestSnapshot = undefined;\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"SnapshotRefreshed\",\n\t\t\t\tsnapshotSequenceNumber,\n\t\t\t\tfirstProcessedOpSequenceNumber,\n\t\t\t\tnewFirstProcessedOpSequenceNumber:\n\t\t\t\t\tthis.processedOps.length === 0 ? undefined : this.processedOps[0].sequenceNumber,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * When the Container attaches, we need to stash the initial snapshot (a form of the attach summary).\n\t * This method is only meant to be used by Container.attach() to set the initial\n\t * base snapshot when attaching.\n\t * @param snapshot - snapshot and blobs collected while attaching (a form of the attach summary)\n\t */\n\tpublic setInitialSnapshot(snapshot: SnapshotWithBlobs | undefined) {\n\t\tif (this.offlineLoadEnabled) {\n\t\t\tassert(\n\t\t\t\tthis.snapshot === undefined,\n\t\t\t\t0x937 /* inital snapshot should only be defined once */,\n\t\t\t);\n\t\t\tassert(snapshot !== undefined, 0x938 /* attachment snapshot should be defined */);\n\t\t\tconst { baseSnapshot, snapshotBlobs } = snapshot;\n\t\t\tconst attributesHash =\n\t\t\t\t\".protocol\" in baseSnapshot.trees\n\t\t\t\t\t? baseSnapshot.trees[\".protocol\"].blobs.attributes\n\t\t\t\t\t: baseSnapshot.blobs[\".attributes\"];\n\t\t\tconst attributes = JSON.parse(snapshotBlobs[attributesHash]);\n\t\t\tassert(\n\t\t\t\tattributes.sequenceNumber === 0,\n\t\t\t\t0x939 /* trying to set a non attachment snapshot */,\n\t\t\t);\n\t\t\tthis.snapshot = { ...snapshot, snapshotSequenceNumber: attributes.sequenceNumber };\n\t\t}\n\t}\n\n\t/**\n\t * Assembles and serializes the {@link IPendingContainerState} for the container,\n\t * to be stored and used to rehydrate the container at a later time.\n\t */\n\tpublic async getPendingLocalState(\n\t\tprops: IGetPendingLocalStateProps,\n\t\tclientId: string | undefined,\n\t\truntime: Pick<IRuntime, \"getPendingLocalState\">,\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<string> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\teventName: \"getPendingLocalState\",\n\t\t\t\tdetails: {\n\t\t\t\t\tnotifyImminentClosure: props.notifyImminentClosure,\n\t\t\t\t\tsessionExpiryTimerStarted: props.sessionExpiryTimerStarted,\n\t\t\t\t\tsnapshotSequenceNumber: props.snapshotSequenceNumber,\n\t\t\t\t\tprocessedOpsSize: this.processedOps.length,\n\t\t\t\t},\n\t\t\t\tclientId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (!this.offlineLoadEnabled) {\n\t\t\t\t\tthrow new UsageError(\"Can't get pending local state unless offline load is enabled\");\n\t\t\t\t}\n\t\t\t\tassert(this.snapshot !== undefined, 0x8e5 /* no base data */);\n\t\t\t\tconst pendingRuntimeState = await runtime.getPendingLocalState({\n\t\t\t\t\t...props,\n\t\t\t\t\tsnapshotSequenceNumber: this.snapshot.snapshotSequenceNumber,\n\t\t\t\t\tsessionExpiryTimerStarted: this.snapshot.snapshotFetchedTime,\n\t\t\t\t});\n\t\t\t\t// This conversion is required because ArrayBufferLike doesn't survive JSON.stringify\n\t\t\t\tconst loadedGroupIdSnapshots = {};\n\t\t\t\tlet hasGroupIdSnapshots = false;\n\t\t\t\tconst groupIdSnapshots = Object.entries(this.storageAdapter.loadedGroupIdSnapshots);\n\t\t\t\tif (groupIdSnapshots.length > 0) {\n\t\t\t\t\tfor (const [groupId, snapshot] of groupIdSnapshots) {\n\t\t\t\t\t\thasGroupIdSnapshots = true;\n\t\t\t\t\t\tloadedGroupIdSnapshots[groupId] = convertSnapshotToSnapshotInfo(snapshot);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst pendingState: IPendingContainerState = {\n\t\t\t\t\tattached: true,\n\t\t\t\t\tpendingRuntimeState,\n\t\t\t\t\tbaseSnapshot: this.snapshot.baseSnapshot,\n\t\t\t\t\tsnapshotBlobs: this.snapshot.snapshotBlobs,\n\t\t\t\t\tloadedGroupIdSnapshots: hasGroupIdSnapshots ? loadedGroupIdSnapshots : undefined,\n\t\t\t\t\tsavedOps: this.processedOps,\n\t\t\t\t\turl: resolvedUrl.url,\n\t\t\t\t\tclientId,\n\t\t\t\t};\n\n\t\t\t\treturn JSON.stringify(pendingState);\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Retrieves the most recent snapshot and returns its info.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing methods to retrieve the snapshot.\n * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.\n * @returns a SnapshotInfo object containing the snapshot tree, snapshot blobs and its sequence number.\n */\nexport async function getLatestSnapshotInfo(\n\tmc: MonitoringContext,\n\tstorageAdapter: ISerializedStateManagerDocumentStorageService,\n\tsupportGetSnapshotApi: boolean,\n): Promise<ISnapshotInfo | undefined> {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tmc.logger,\n\t\t{ eventName: \"GetLatestSnapshotInfo\" },\n\t\tasync () => {\n\t\t\tconst { baseSnapshot } = await getSnapshot(\n\t\t\t\tmc,\n\t\t\t\tstorageAdapter,\n\t\t\t\tsupportGetSnapshotApi,\n\t\t\t\tundefined,\n\t\t\t);\n\n\t\t\tconst baseSnapshotTree: ISnapshotTree | undefined = getSnapshotTree(baseSnapshot);\n\t\t\tconst snapshotFetchedTime = Date.now();\n\t\t\tconst snapshotBlobs = await getBlobContentsFromTree(baseSnapshotTree, storageAdapter);\n\t\t\tconst attributes: IDocumentAttributes = await getDocumentAttributes(\n\t\t\t\tstorageAdapter,\n\t\t\t\tbaseSnapshotTree,\n\t\t\t);\n\t\t\tconst snapshotSequenceNumber = attributes.sequenceNumber;\n\t\t\treturn {\n\t\t\t\tbaseSnapshot: baseSnapshotTree,\n\t\t\t\tsnapshotBlobs,\n\t\t\t\tsnapshotSequenceNumber,\n\t\t\t\tsnapshotFetchedTime,\n\t\t\t};\n\t\t},\n\t).catch(() => undefined);\n}\n\n/**\n * Retrieves a snapshot from the storage adapter and transforms it into an ISnapshotTree object.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing methods to retrieve the snapshot.\n * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.\n * @param specifiedVersion - An optional version string specifying the version of the snapshot tree to fetch.\n * @returns - An ISnapshotTree and its version.\n */\nasync function getSnapshot(\n\tmc: MonitoringContext,\n\tstorageAdapter: Pick<\n\t\tIDocumentStorageService,\n\t\t\"getSnapshot\" | \"getSnapshotTree\" | \"getVersions\"\n\t>,\n\tsupportGetSnapshotApi: boolean,\n\tspecifiedVersion: string | undefined,\n): Promise<{ baseSnapshot: ISnapshot | ISnapshotTree; version?: IVersion }> {\n\tconst { snapshot, version } = supportGetSnapshotApi\n\t\t? await fetchISnapshot(mc, storageAdapter, specifiedVersion)\n\t\t: await fetchISnapshotTree(mc, storageAdapter, specifiedVersion);\n\tassert(snapshot !== undefined, 0x8e4 /* Snapshot should exist */);\n\treturn { baseSnapshot: snapshot, version };\n}\n\n/**\n * Fetches an ISnapshot from a storage adapter based on the specified version.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing a getSnapshot method to retrieve the ISnapshot and version.\n * @param specifiedVersion - An optional version string specifying the version of the snapshot tree to fetch.\n * @returns - The fetched snapshot tree and its version.\n */\nexport async function fetchISnapshot(\n\tmc: MonitoringContext,\n\tstorageAdapter: Pick<IDocumentStorageService, \"getSnapshot\">,\n\tspecifiedVersion: string | undefined,\n): Promise<{ snapshot?: ISnapshot; version?: IVersion }> {\n\tconst snapshot = await storageAdapter.getSnapshot?.({ versionId: specifiedVersion });\n\tconst version: IVersion | undefined =\n\t\tsnapshot?.snapshotTree.id === undefined\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tid: snapshot.snapshotTree.id,\n\t\t\t\t\ttreeId: snapshot.snapshotTree.id,\n\t\t\t\t};\n\n\tif (snapshot === undefined && specifiedVersion !== undefined) {\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"getSnapshotTreeFailed\",\n\t\t\tid: specifiedVersion,\n\t\t});\n\t} else if (snapshot !== undefined && version?.id === undefined) {\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"getSnapshotFetchedTreeWithoutVersionId\",\n\t\t\thasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.\n\t\t});\n\t}\n\treturn { snapshot, version };\n}\n\n/**\n * Fetches an ISnapshotTree from a storage adapter based on the specified version.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing methods to retrieve the ISnapshotTree and version.\n * @param specifiedVersion - An optional version string specifying the version of the snapshot tree to fetch.\n * @returns - The fetched snapshot tree and its version.\n */\nexport async function fetchISnapshotTree(\n\tmc: MonitoringContext,\n\tstorageAdapter: Pick<IDocumentStorageService, \"getSnapshotTree\" | \"getVersions\">,\n\tspecifiedVersion: string | undefined,\n): Promise<{ snapshot?: ISnapshotTree; version?: IVersion | undefined }> {\n\tconst versions = await storageAdapter.getVersions(specifiedVersion ?? null, 1);\n\tconst version = versions[0];\n\n\tif (version === undefined && specifiedVersion !== undefined) {\n\t\t// We should have a defined version to load from if specified version requested\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"NoVersionFoundWhenSpecified\",\n\t\t\tid: specifiedVersion,\n\t\t});\n\t}\n\tconst snapshot = (await storageAdapter.getSnapshotTree(version)) ?? undefined;\n\n\tif (snapshot === undefined && version !== undefined) {\n\t\tmc.logger.sendErrorEvent({ eventName: \"getSnapshotTreeFailed\", id: version.id });\n\t} else if (snapshot !== undefined && version?.id === undefined) {\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"getSnapshotFetchedTreeWithoutVersionId\",\n\t\t\thasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.\n\t\t});\n\t}\n\treturn { snapshot, version };\n}\n"]}
1
+ {"version":3,"file":"serializedStateManager.js","sourceRoot":"","sources":["../src/serializedStateManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAW9D,kEAAoE;AACpE,0EASqD;AACrD,oEAAwE;AACxE,uEAMkD;AAElD,6EAGsC;AACtC,yCAAkF;AAoGlF;;;;;;GAMG;AACH,MAAa,sBAAsB;IAUlC;;;;;;;OAOG;IACH,YACkB,iBAAqD,EACtE,SAA+B,EACd,cAA6D,EAC7D,mBAA4B,EAC7C,cAAgD,EAC/B,cAA6B,EAC7B,qBAAoC,EACrD,wBAAiC;QAPhB,sBAAiB,GAAjB,iBAAiB,CAAoC;QAErD,mBAAc,GAAd,cAAc,CAA+C;QAC7D,wBAAmB,GAAnB,mBAAmB,CAAS;QAE5B,mBAAc,GAAd,cAAc,CAAe;QAC7B,0BAAqB,GAArB,qBAAqB,CAAe;QAxBrC,iBAAY,GAAgC,EAAE,CAAC;QAK/C,8BAAyB,GAAW,CAAC,CAAC;QAEtC,6BAAwB,GAAW,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAoBvE,IAAI,CAAC,EAAE,GAAG,IAAA,uCAA4B,EAAC;YACtC,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,wBAAwB;SACnC,CAAC,CAAC;QAEH,IAAI,CAAC,wBAA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AM,cAAc,CAAC,WAAW,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/E,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5B,IAAI,OAAO,KAAK,SAAS,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC7D,+EAA+E;QAC/E,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;YACxB,SAAS,EAAE,6BAA6B;YACxC,EAAE,EAAE,gBAAgB;SACpB,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,MAAM,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,SAAS,CAAC;IAE9E,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACrD,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,EAAE,EAAE,KAAK,SAAS,EAAE,CAAC;QAChE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;YACxB,SAAS,EAAE,wCAAwC;YACnD,UAAU,EAAE,OAAO,KAAK,SAAS,EAAE,mFAAmF;SACtH,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AA5BD,gDA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tIGetPendingLocalStateProps,\n\tIRuntime,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIEventProvider,\n\tIEvent,\n\tITelemetryBaseLogger,\n\tTagged,\n} from \"@fluidframework/core-interfaces\";\nimport { Timer, assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISnapshot,\n\ttype IDocumentAttributes,\n\tISnapshotTree,\n\tIVersion,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { getSnapshotTree } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tMonitoringContext,\n\tPerformanceEvent,\n\tUsageError,\n\tcreateChildMonitoringContext,\n\ttype TelemetryEventPropertyTypeExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tISerializableBlobContents,\n\tgetBlobContentsFromTree,\n} from \"./containerStorageAdapter.js\";\nimport { convertSnapshotToSnapshotInfo, getDocumentAttributes } from \"./utils.js\";\n\n/**\n * This is very similar to {@link @fluidframework/protocol-definitions/internal#ISnapshot}, but the difference is\n * that the blobs of ISnapshot are of type ArrayBufferLike, while the blobs of this interface are serializable because\n * they are already converted to string.\n */\nexport interface SnapshotWithBlobs {\n\t/**\n\t * Snapshot from which container initially loaded.\n\t */\n\tbaseSnapshot: ISnapshotTree;\n\t/**\n\t * Serializable blobs from the base snapshot. Used to load offline since\n\t * storage is not available.\n\t */\n\tsnapshotBlobs: ISerializableBlobContents;\n}\n\n/**\n * State saved by a container at close time, to be used to load a new instance\n * of the container to the same state\n *\n * This is very similar to {@link @fluidframework/protocol-definitions/internal#ISnapshot}, but the difference is\n * that the blobs of ISnapshot are of type ArrayBufferLike, while the blobs of this interface are serializable because\n * they are already converted to string.\n *\n * @internal\n */\nexport interface IPendingContainerState extends SnapshotWithBlobs {\n\t/**\n\t * This container was attached (as opposed to IPendingDetachedContainerState.attached which is false)\n\t */\n\tattached: true;\n\t/**\n\t * Runtime-specific state that will be needed to properly rehydrate\n\t * (it's included in ContainerContext passed to instantiateRuntime)\n\t */\n\tpendingRuntimeState: unknown;\n\t/**\n\t * Any group snapshots (aka delay-loaded) we've downloaded from the service for this container\n\t */\n\tloadedGroupIdSnapshots?: Record<string, ISnapshotInfo>;\n\t/**\n\t * All ops since base snapshot sequence number up to the latest op\n\t * seen when the container was closed. Used to apply stashed (saved pending)\n\t * ops at the same sequence number at which they were made.\n\t */\n\tsavedOps: ISequencedDocumentMessage[];\n\t/**\n\t * The Container's URL in the service, needed to hook up the driver during rehydration\n\t */\n\turl: string;\n\t/**\n\t * If the Container was connected when serialized, its clientId. Used as the initial clientId upon rehydration, until reconnected.\n\t */\n\tclientId?: string;\n}\n\n/**\n * State saved by a container in detached state, to be used to load a new instance\n * of the container to the same state (rehydrate)\n * @internal\n */\nexport interface IPendingDetachedContainerState extends SnapshotWithBlobs {\n\t/**\n\t * This container was not attached (as opposed to IPendingContainerState.attached which is true)\n\t */\n\tattached: false;\n\t/**\n\t * Indicates whether we expect the rehydrated container to have non-empty Detached Blob Storage\n\t */\n\thasAttachmentBlobs: boolean;\n\t/**\n\t * Used by the memory blob storage to persisted attachment blobs\n\t */\n\tattachmentBlobs?: string;\n\t/**\n\t * Runtime-specific state that will be needed to properly rehydrate\n\t * (it's included in ContainerContext passed to instantiateRuntime)\n\t */\n\tpendingRuntimeState?: unknown;\n}\n\nexport interface ISnapshotInfo extends SnapshotWithBlobs {\n\tsnapshotSequenceNumber: number;\n\tsnapshotFetchedTime?: number | undefined;\n}\n\nexport type ISerializedStateManagerDocumentStorageService = Pick<\n\tIDocumentStorageService,\n\t\"getSnapshot\" | \"getSnapshotTree\" | \"getVersions\" | \"readBlob\"\n> & {\n\tloadedGroupIdSnapshots: Record<string, ISnapshot>;\n};\n\ninterface ISerializerEvent extends IEvent {\n\t(event: \"saved\", listener: (dirty: boolean) => void): void;\n}\n\n/**\n * Helper class to manage the state of the container needed for proper serialization.\n *\n * It holds the pendingLocalState the container was rehydrated from (if any),\n * as well as the snapshot to be used for serialization.\n * It also keeps track of container dirty state and which local ops have been processed\n */\nexport class SerializedStateManager {\n\tprivate readonly processedOps: ISequencedDocumentMessage[] = [];\n\tprivate readonly mc: MonitoringContext;\n\tprivate snapshot: ISnapshotInfo | undefined;\n\tprivate latestSnapshot: ISnapshotInfo | undefined;\n\tprivate _refreshSnapshotP: Promise<number> | undefined;\n\tprivate readonly lastSavedOpSequenceNumber: number = 0;\n\tprivate readonly refreshTimer: Timer;\n\tprivate readonly snapshotRefreshTimeoutMs: number = 60 * 60 * 24 * 1000;\n\n\t/**\n\t * @param pendingLocalState - The pendingLocalState being rehydrated, if any (undefined when loading directly from storage)\n\t * @param subLogger - Container's logger to use as parent for our logger\n\t * @param storageAdapter - Storage adapter for fetching snapshots\n\t * @param _offlineLoadEnabled - Is serializing/rehydrating containers allowed?\n\t * @param containerEvent - Source of the \"saved\" event when the container has all its pending state uploaded\n\t * @param containerDirty - Is the container \"dirty\"? That's the opposite of \"saved\" - there is pending state that may not have been received yet by the service.\n\t */\n\tconstructor(\n\t\tprivate readonly pendingLocalState: IPendingContainerState | undefined,\n\t\tsubLogger: ITelemetryBaseLogger,\n\t\tprivate readonly storageAdapter: ISerializedStateManagerDocumentStorageService,\n\t\tprivate readonly _offlineLoadEnabled: boolean,\n\t\tcontainerEvent: IEventProvider<ISerializerEvent>,\n\t\tprivate readonly containerDirty: () => boolean,\n\t\tprivate readonly supportGetSnapshotApi: () => boolean,\n\t\tsnapshotRefreshTimeoutMs?: number,\n\t) {\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: subLogger,\n\t\t\tnamespace: \"serializedStateManager\",\n\t\t});\n\n\t\tthis.snapshotRefreshTimeoutMs = snapshotRefreshTimeoutMs ?? this.snapshotRefreshTimeoutMs;\n\t\tthis.refreshTimer = new Timer(this.snapshotRefreshTimeoutMs, () =>\n\t\t\tthis.tryRefreshSnapshot(),\n\t\t);\n\t\t// special case handle. Obtaining the last saved op seq num to avoid\n\t\t// refreshing the snapshot before we have processed it. It could cause\n\t\t// a subsequent stashing to have a newer snapshot than allowed.\n\t\tif (pendingLocalState && pendingLocalState.savedOps.length > 0) {\n\t\t\tconst savedOpsSize = pendingLocalState.savedOps.length;\n\t\t\tthis.lastSavedOpSequenceNumber =\n\t\t\t\tpendingLocalState.savedOps[savedOpsSize - 1].sequenceNumber;\n\t\t}\n\t\tcontainerEvent.on(\"saved\", () => this.updateSnapshotAndProcessedOpsMaybe());\n\t}\n\n\tpublic get offlineLoadEnabled(): boolean {\n\t\treturn this._offlineLoadEnabled;\n\t}\n\n\t/**\n\t * Promise that will resolve (or reject) once we've tried to download the latest snapshot(s) from storage\n\t * only intended to be used for testing purposes.\n\t * @returns The snapshot sequence number associated with the latest fetched snapshot\n\t */\n\tpublic get refreshSnapshotP(): Promise<number> | undefined {\n\t\treturn this._refreshSnapshotP;\n\t}\n\n\t/**\n\t * Called whenever an incoming op is processed by the Container\n\t */\n\tpublic addProcessedOp(message: ISequencedDocumentMessage): void {\n\t\tif (this.offlineLoadEnabled) {\n\t\t\tthis.processedOps.push(message);\n\t\t\tthis.updateSnapshotAndProcessedOpsMaybe();\n\t\t}\n\t}\n\n\t/**\n\t * This wraps the basic functionality of fetching the snapshot for this container during Container load.\n\t *\n\t * If we have pendingLocalState, we get the snapshot from there.\n\t * Otherwise, fetch it from storage (according to specifiedVersion if provided).\n\t *\n\t * @param specifiedVersion - If a version is specified and we don't have pendingLocalState, fetch this version from storage.\n\t * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.\n\t * @returns The snapshot to boot the container from\n\t */\n\tpublic async fetchSnapshot(specifiedVersion: string | undefined): Promise<{\n\t\tbaseSnapshot: ISnapshot | ISnapshotTree;\n\t\tversion: IVersion | undefined;\n\t}> {\n\t\tif (this.pendingLocalState === undefined) {\n\t\t\tconst { baseSnapshot, version } = await getSnapshot(\n\t\t\t\tthis.mc,\n\t\t\t\tthis.storageAdapter,\n\t\t\t\tthis.supportGetSnapshotApi(),\n\t\t\t\tspecifiedVersion,\n\t\t\t);\n\t\t\tconst baseSnapshotTree: ISnapshotTree | undefined = getSnapshotTree(baseSnapshot);\n\t\t\t// non-interactive clients will not have any pending state we want to save\n\t\t\tif (this.offlineLoadEnabled) {\n\t\t\t\tconst snapshotBlobs = await getBlobContentsFromTree(\n\t\t\t\t\tbaseSnapshotTree,\n\t\t\t\t\tthis.storageAdapter,\n\t\t\t\t);\n\t\t\t\tconst attributes = await getDocumentAttributes(this.storageAdapter, baseSnapshotTree);\n\t\t\t\tthis.snapshot = {\n\t\t\t\t\tbaseSnapshot: baseSnapshotTree,\n\t\t\t\t\tsnapshotBlobs,\n\t\t\t\t\tsnapshotSequenceNumber: attributes.sequenceNumber,\n\t\t\t\t};\n\t\t\t\tthis.refreshTimer.start();\n\t\t\t}\n\t\t\treturn { baseSnapshot, version };\n\t\t} else {\n\t\t\tconst { baseSnapshot, snapshotBlobs } = this.pendingLocalState;\n\t\t\tconst attributes = await getDocumentAttributes(this.storageAdapter, baseSnapshot);\n\t\t\tthis.snapshot = {\n\t\t\t\tbaseSnapshot,\n\t\t\t\tsnapshotBlobs,\n\t\t\t\tsnapshotSequenceNumber: attributes.sequenceNumber,\n\t\t\t};\n\t\t\tthis.tryRefreshSnapshot();\n\t\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\t\tfor (const [id, value] of Object.entries(snapshotBlobs)) {\n\t\t\t\tblobContents.set(id, stringToBuffer(value, \"utf8\"));\n\t\t\t}\n\t\t\tconst iSnapshot: ISnapshot = {\n\t\t\t\tsequenceNumber: this.snapshot.snapshotSequenceNumber,\n\t\t\t\tsnapshotTree: baseSnapshot,\n\t\t\t\tblobContents,\n\t\t\t\tlatestSequenceNumber: undefined,\n\t\t\t\tops: [],\n\t\t\t\tsnapshotFormatV: 1,\n\t\t\t};\n\t\t\treturn { baseSnapshot: iSnapshot, version: undefined };\n\t\t}\n\t}\n\n\tprivate tryRefreshSnapshot(): void {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Container.enableOfflineSnapshotRefresh\") === true &&\n\t\t\tthis._refreshSnapshotP === undefined &&\n\t\t\tthis.latestSnapshot === undefined\n\t\t) {\n\t\t\t// Don't block on the refresh snapshot call - it is for the next time we serialize, not booting this incarnation\n\t\t\tthis._refreshSnapshotP = this.refreshLatestSnapshot(this.supportGetSnapshotApi());\n\t\t\tthis._refreshSnapshotP\n\t\t\t\t.catch(\n\t\t\t\t\t(error: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>) => {\n\t\t\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\t\t\teventName: \"RefreshLatestSnapshotFailed\",\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis._refreshSnapshotP = undefined;\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Fetch the latest snapshot for the container, including delay-loaded groupIds if pendingLocalState was provided and contained any groupIds.\n\t * Note that this will update the StorageAdapter's cached snapshots for the groupIds (if present)\n\t *\n\t * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree (must be true to fetch by groupIds)\n\t */\n\tprivate async refreshLatestSnapshot(supportGetSnapshotApi: boolean): Promise<number> {\n\t\tthis.latestSnapshot = await getLatestSnapshotInfo(\n\t\t\tthis.mc,\n\t\t\tthis.storageAdapter,\n\t\t\tsupportGetSnapshotApi,\n\t\t);\n\n\t\t// These are loading groupIds that the containerRuntime has requested over its lifetime.\n\t\t// We will fetch the latest snapshot for the groupIds, which will update storageAdapter.loadedGroupIdSnapshots's cache\n\t\tconst downloadedGroupIds = Object.keys(this.storageAdapter.loadedGroupIdSnapshots);\n\t\tif (supportGetSnapshotApi && downloadedGroupIds.length > 0) {\n\t\t\tassert(\n\t\t\t\tthis.storageAdapter.getSnapshot !== undefined,\n\t\t\t\t0x972 /* getSnapshot should exist */,\n\t\t\t);\n\t\t\t// (This is a separate network call from above because it requires work for storage to add a special base groupId)\n\t\t\tconst snapshot = await this.storageAdapter.getSnapshot({\n\t\t\t\tversionId: undefined,\n\t\t\t\tscenarioName: \"getLatestSnapshotInfo\",\n\t\t\t\tcacheSnapshot: false,\n\t\t\t\tloadingGroupIds: downloadedGroupIds,\n\t\t\t\tfetchSource: FetchSource.noCache,\n\t\t\t});\n\t\t\tassert(snapshot !== undefined, 0x973 /* Snapshot should exist */);\n\t\t}\n\n\t\treturn this.updateSnapshotAndProcessedOpsMaybe();\n\t}\n\n\t/**\n\t * Updates class snapshot and processedOps if we have a new snapshot and it's among processedOps range.\n\t */\n\tprivate updateSnapshotAndProcessedOpsMaybe(): number {\n\t\tconst snapshotSequenceNumber = this.latestSnapshot?.snapshotSequenceNumber;\n\t\tif (\n\t\t\tsnapshotSequenceNumber === undefined ||\n\t\t\tthis.processedOps.length === 0 ||\n\t\t\tthis.processedOps[this.processedOps.length - 1].sequenceNumber <\n\t\t\t\tthis.lastSavedOpSequenceNumber ||\n\t\t\tthis.containerDirty()\n\t\t) {\n\t\t\t// can't refresh latest snapshot until we have processed the ops up to it.\n\t\t\t// Pending state would be behind the latest snapshot.\n\t\t\treturn -1;\n\t\t}\n\t\tconst firstProcessedOpSequenceNumber = this.processedOps[0].sequenceNumber;\n\t\tconst lastProcessedOpSequenceNumber =\n\t\t\tthis.processedOps[this.processedOps.length - 1].sequenceNumber;\n\n\t\tif (snapshotSequenceNumber < firstProcessedOpSequenceNumber) {\n\t\t\t// Snapshot seq number is older than our first processed op, which could mean we're fetching\n\t\t\t// the same snapshot that we already have or snapshot is too old, implicating an unexpected behavior.\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"OldSnapshotFetchWhileRefreshing\",\n\t\t\t\tsnapshotSequenceNumber,\n\t\t\t\tfirstProcessedOpSequenceNumber,\n\t\t\t\tlastProcessedOpSequenceNumber,\n\t\t\t\tstashedSnapshotSequenceNumber: this.snapshot?.snapshotSequenceNumber,\n\t\t\t});\n\t\t\tthis.latestSnapshot = undefined;\n\t\t\tthis.refreshTimer.restart();\n\t\t} else if (snapshotSequenceNumber <= lastProcessedOpSequenceNumber) {\n\t\t\t// Snapshot seq num is between the first and last processed op.\n\t\t\t// Remove the ops that are already part of the snapshot\n\t\t\tthis.processedOps.splice(0, snapshotSequenceNumber - firstProcessedOpSequenceNumber + 1);\n\t\t\tthis.snapshot = this.latestSnapshot;\n\t\t\tthis.latestSnapshot = undefined;\n\t\t\tthis.refreshTimer.restart();\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"SnapshotRefreshed\",\n\t\t\t\tsnapshotSequenceNumber,\n\t\t\t\tfirstProcessedOpSequenceNumber,\n\t\t\t\tnewFirstProcessedOpSequenceNumber:\n\t\t\t\t\tthis.processedOps.length === 0 ? undefined : this.processedOps[0].sequenceNumber,\n\t\t\t});\n\t\t}\n\t\treturn snapshotSequenceNumber;\n\t}\n\n\t/**\n\t * When the Container attaches, we need to stash the initial snapshot (a form of the attach summary).\n\t * This method is only meant to be used by Container.attach() to set the initial\n\t * base snapshot when attaching.\n\t * @param snapshot - snapshot and blobs collected while attaching (a form of the attach summary)\n\t */\n\tpublic setInitialSnapshot(snapshot: SnapshotWithBlobs | undefined): void {\n\t\tif (this.offlineLoadEnabled) {\n\t\t\tassert(\n\t\t\t\tthis.snapshot === undefined,\n\t\t\t\t0x937 /* inital snapshot should only be defined once */,\n\t\t\t);\n\t\t\tassert(snapshot !== undefined, 0x938 /* attachment snapshot should be defined */);\n\t\t\tconst { baseSnapshot, snapshotBlobs } = snapshot;\n\t\t\tconst attributesHash =\n\t\t\t\t\".protocol\" in baseSnapshot.trees\n\t\t\t\t\t? baseSnapshot.trees[\".protocol\"].blobs.attributes\n\t\t\t\t\t: baseSnapshot.blobs[\".attributes\"];\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst attributes = JSON.parse(snapshotBlobs[attributesHash]);\n\t\t\tassert(\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\tattributes.sequenceNumber === 0,\n\t\t\t\t0x939 /* trying to set a non attachment snapshot */,\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\t...snapshot,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\tsnapshotSequenceNumber: attributes.sequenceNumber as number,\n\t\t\t};\n\t\t\tthis.refreshTimer.start();\n\t\t}\n\t}\n\n\t/**\n\t * Assembles and serializes the {@link IPendingContainerState} for the container,\n\t * to be stored and used to rehydrate the container at a later time.\n\t */\n\tpublic async getPendingLocalState(\n\t\tprops: IGetPendingLocalStateProps,\n\t\tclientId: string | undefined,\n\t\truntime: Pick<IRuntime, \"getPendingLocalState\">,\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<string> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\teventName: \"getPendingLocalState\",\n\t\t\t\tdetails: {\n\t\t\t\t\tnotifyImminentClosure: props.notifyImminentClosure,\n\t\t\t\t\tsessionExpiryTimerStarted: props.sessionExpiryTimerStarted,\n\t\t\t\t\tsnapshotSequenceNumber: props.snapshotSequenceNumber,\n\t\t\t\t\tprocessedOpsSize: this.processedOps.length,\n\t\t\t\t},\n\t\t\t\tclientId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tif (!this.offlineLoadEnabled) {\n\t\t\t\t\tthrow new UsageError(\"Can't get pending local state unless offline load is enabled\");\n\t\t\t\t}\n\t\t\t\tassert(this.snapshot !== undefined, 0x8e5 /* no base data */);\n\t\t\t\tconst pendingRuntimeState = await runtime.getPendingLocalState({\n\t\t\t\t\t...props,\n\t\t\t\t\tsnapshotSequenceNumber: this.snapshot.snapshotSequenceNumber,\n\t\t\t\t\tsessionExpiryTimerStarted: this.snapshot.snapshotFetchedTime,\n\t\t\t\t});\n\t\t\t\t// This conversion is required because ArrayBufferLike doesn't survive JSON.stringify\n\t\t\t\tconst loadedGroupIdSnapshots = {};\n\t\t\t\tlet hasGroupIdSnapshots = false;\n\t\t\t\tconst groupIdSnapshots = Object.entries(this.storageAdapter.loadedGroupIdSnapshots);\n\t\t\t\tif (groupIdSnapshots.length > 0) {\n\t\t\t\t\tfor (const [groupId, snapshot] of groupIdSnapshots) {\n\t\t\t\t\t\thasGroupIdSnapshots = true;\n\t\t\t\t\t\tloadedGroupIdSnapshots[groupId] = convertSnapshotToSnapshotInfo(snapshot);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst pendingState: IPendingContainerState = {\n\t\t\t\t\tattached: true,\n\t\t\t\t\tpendingRuntimeState,\n\t\t\t\t\tbaseSnapshot: this.snapshot.baseSnapshot,\n\t\t\t\t\tsnapshotBlobs: this.snapshot.snapshotBlobs,\n\t\t\t\t\tloadedGroupIdSnapshots: hasGroupIdSnapshots ? loadedGroupIdSnapshots : undefined,\n\t\t\t\t\tsavedOps: this.processedOps,\n\t\t\t\t\turl: resolvedUrl.url,\n\t\t\t\t\tclientId,\n\t\t\t\t};\n\n\t\t\t\treturn JSON.stringify(pendingState);\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Retrieves the most recent snapshot and returns its info.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing methods to retrieve the snapshot.\n * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.\n * @returns a SnapshotInfo object containing the snapshot tree, snapshot blobs and its sequence number.\n */\nexport async function getLatestSnapshotInfo(\n\tmc: MonitoringContext,\n\tstorageAdapter: ISerializedStateManagerDocumentStorageService,\n\tsupportGetSnapshotApi: boolean,\n): Promise<ISnapshotInfo | undefined> {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tmc.logger,\n\t\t{ eventName: \"GetLatestSnapshotInfo\" },\n\t\tasync () => {\n\t\t\t// get the latest non cached snapshot version\n\t\t\tconst specifiedVersion: IVersion[] = await storageAdapter.getVersions(\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tnull,\n\t\t\t\t1,\n\t\t\t\t\"getLatestSnapshotInfo\",\n\t\t\t\tFetchSource.noCache,\n\t\t\t);\n\t\t\tconst { baseSnapshot } = await getSnapshot(\n\t\t\t\tmc,\n\t\t\t\tstorageAdapter,\n\t\t\t\tsupportGetSnapshotApi,\n\t\t\t\tspecifiedVersion[0]?.id,\n\t\t\t);\n\n\t\t\tconst baseSnapshotTree: ISnapshotTree | undefined = getSnapshotTree(baseSnapshot);\n\t\t\tconst snapshotFetchedTime = Date.now();\n\t\t\tconst snapshotBlobs = await getBlobContentsFromTree(baseSnapshotTree, storageAdapter);\n\t\t\tconst attributes: IDocumentAttributes = await getDocumentAttributes(\n\t\t\t\tstorageAdapter,\n\t\t\t\tbaseSnapshotTree,\n\t\t\t);\n\t\t\tconst snapshotSequenceNumber = attributes.sequenceNumber;\n\t\t\treturn {\n\t\t\t\tbaseSnapshot: baseSnapshotTree,\n\t\t\t\tsnapshotBlobs,\n\t\t\t\tsnapshotSequenceNumber,\n\t\t\t\tsnapshotFetchedTime,\n\t\t\t};\n\t\t},\n\t).catch(() => undefined);\n}\n\n/**\n * Retrieves a snapshot from the storage adapter and transforms it into an ISnapshotTree object.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing methods to retrieve the snapshot.\n * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.\n * @param specifiedVersion - An optional version string specifying the version of the snapshot tree to fetch.\n * @returns - An ISnapshotTree and its version.\n */\nasync function getSnapshot(\n\tmc: MonitoringContext,\n\tstorageAdapter: Pick<\n\t\tIDocumentStorageService,\n\t\t\"getSnapshot\" | \"getSnapshotTree\" | \"getVersions\"\n\t>,\n\tsupportGetSnapshotApi: boolean,\n\tspecifiedVersion: string | undefined,\n): Promise<{ baseSnapshot: ISnapshot | ISnapshotTree; version?: IVersion }> {\n\tconst { snapshot, version } = supportGetSnapshotApi\n\t\t? await fetchISnapshot(mc, storageAdapter, specifiedVersion)\n\t\t: await fetchISnapshotTree(mc, storageAdapter, specifiedVersion);\n\tassert(snapshot !== undefined, 0x8e4 /* Snapshot should exist */);\n\treturn { baseSnapshot: snapshot, version };\n}\n\n/**\n * Fetches an ISnapshot from a storage adapter based on the specified version.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing a getSnapshot method to retrieve the ISnapshot and version.\n * @param specifiedVersion - An optional version string specifying the version of the snapshot tree to fetch.\n * @returns - The fetched snapshot tree and its version.\n */\nexport async function fetchISnapshot(\n\tmc: MonitoringContext,\n\tstorageAdapter: Pick<IDocumentStorageService, \"getSnapshot\">,\n\tspecifiedVersion: string | undefined,\n): Promise<{ snapshot?: ISnapshot; version?: IVersion }> {\n\tconst snapshot = await storageAdapter.getSnapshot?.({ versionId: specifiedVersion });\n\tconst version: IVersion | undefined =\n\t\tsnapshot?.snapshotTree.id === undefined\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tid: snapshot.snapshotTree.id,\n\t\t\t\t\ttreeId: snapshot.snapshotTree.id,\n\t\t\t\t};\n\n\tif (snapshot === undefined && specifiedVersion !== undefined) {\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"getSnapshotTreeFailed\",\n\t\t\tid: specifiedVersion,\n\t\t});\n\t} else if (snapshot !== undefined && version?.id === undefined) {\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"getSnapshotFetchedTreeWithoutVersionId\",\n\t\t\thasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.\n\t\t});\n\t}\n\treturn { snapshot, version };\n}\n\n/**\n * Fetches an ISnapshotTree from a storage adapter based on the specified version.\n *\n * @param mc - The monitoring context.\n * @param storageAdapter - The storage adapter providing methods to retrieve the ISnapshotTree and version.\n * @param specifiedVersion - An optional version string specifying the version of the snapshot tree to fetch.\n * @returns - The fetched snapshot tree and its version.\n */\nexport async function fetchISnapshotTree(\n\tmc: MonitoringContext,\n\tstorageAdapter: Pick<IDocumentStorageService, \"getSnapshotTree\" | \"getVersions\">,\n\tspecifiedVersion: string | undefined,\n): Promise<{ snapshot?: ISnapshotTree; version?: IVersion | undefined }> {\n\t// API uses null\n\t// eslint-disable-next-line unicorn/no-null\n\tconst versions = await storageAdapter.getVersions(specifiedVersion ?? null, 1);\n\tconst version = versions[0];\n\n\tif (version === undefined && specifiedVersion !== undefined) {\n\t\t// We should have a defined version to load from if specified version requested\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"NoVersionFoundWhenSpecified\",\n\t\t\tid: specifiedVersion,\n\t\t});\n\t}\n\tconst snapshot = (await storageAdapter.getSnapshotTree(version)) ?? undefined;\n\n\tif (snapshot === undefined && version !== undefined) {\n\t\tmc.logger.sendErrorEvent({ eventName: \"getSnapshotTreeFailed\", id: version.id });\n\t} else if (snapshot !== undefined && version?.id === undefined) {\n\t\tmc.logger.sendErrorEvent({\n\t\t\teventName: \"getSnapshotFetchedTreeWithoutVersionId\",\n\t\t\thasVersion: version !== undefined, // if hasVersion is true, this means that the contract with the service was broken.\n\t\t});\n\t}\n\treturn { snapshot, version };\n}\n"]}
package/dist/utils.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
20
20
  * Interface to represent the parsed parts of IResolvedUrl.url to help
21
21
  * in getting info about different parts of the url.
22
22
  * May not be compatible or relevant for any Url Resolver
23
+ * @legacy
23
24
  * @alpha
24
25
  */
25
26
  export interface IParsedUrl {
@@ -48,6 +49,7 @@ export interface IParsedUrl {
48
49
  * with urls of type: protocol://<string>/.../..?<querystring>
49
50
  * @param url - This is the IResolvedUrl.url part of the resolved url.
50
51
  * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported
52
+ * @legacy
51
53
  * @alpha
52
54
  */
53
55
  export declare function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined;
@@ -77,7 +79,7 @@ export declare function convertSnapshotInfoToSnapshot(snapshotInfo: ISnapshotInf
77
79
  export declare const getSnapshotTreeAndBlobsFromSerializedContainer: (detachedContainerSnapshot: ISummaryTree) => SnapshotWithBlobs;
78
80
  export declare function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree;
79
81
  export declare const combineSnapshotTreeAndSnapshotBlobs: (baseSnapshot: ISnapshotTree, snapshotBlobs: ISerializableBlobContents) => ISnapshotTreeWithBlobContents;
80
- export declare function isDeltaStreamConnectionForbiddenError(error: any): error is DeltaStreamConnectionForbiddenError;
82
+ export declare function isDeltaStreamConnectionForbiddenError(error: unknown): error is DeltaStreamConnectionForbiddenError;
81
83
  /**
82
84
  * Parses the given string into {@link IPendingDetachedContainerState} format,
83
85
  * with validation (if invalid, throws a UsageError).
@@ -93,6 +95,6 @@ export declare function getAttachedContainerStateFromSerializedContainer(seriali
93
95
  * Ensures only a single instance of the provided async function is running.
94
96
  * If there are multiple calls they will all get the same promise to wait on.
95
97
  */
96
- export declare const runSingle: <A extends any[], R>(func: (...args: A) => Promise<R>) => (...args: A) => Promise<R>;
98
+ export declare const runSingle: <A extends any[], R>(func: (...args: A) => Promise<R>) => ((...args: A) => Promise<R>);
97
99
  export declare function getDocumentAttributes(storage: Pick<IDocumentStorageService, "readBlob">, tree: ISnapshotTree | undefined): Promise<IDocumentAttributes>;
98
100
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,YAAY,EAAe,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAEN,mBAAmB,EACnB,aAAa,EACb,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,uBAAuB,EACvB,KAAK,SAAS,EACd,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,6BAA6B,EAC7B,mCAAmC,EAGnC,MAAM,uCAAuC,CAAC;AAI/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EACX,sBAAsB,EACtB,8BAA8B,EAC9B,aAAa,EACb,iBAAiB,EACjB,MAAM,6BAA6B,CAAC;AAIrC,MA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