@fluidframework/container-loader 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.203917

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 (146) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/api-extractor.json +9 -1
  3. package/api-report/container-loader.api.md +153 -0
  4. package/dist/catchUpMonitor.d.ts +2 -2
  5. package/dist/catchUpMonitor.d.ts.map +1 -1
  6. package/dist/connectionManager.d.ts +2 -15
  7. package/dist/connectionManager.d.ts.map +1 -1
  8. package/dist/connectionManager.js +110 -98
  9. package/dist/connectionManager.js.map +1 -1
  10. package/dist/connectionState.js +1 -1
  11. package/dist/connectionState.js.map +1 -1
  12. package/dist/connectionStateHandler.js +9 -9
  13. package/dist/connectionStateHandler.js.map +1 -1
  14. package/dist/container-loader-alpha.d.ts +333 -0
  15. package/dist/container-loader-beta.d.ts +333 -0
  16. package/dist/container-loader-public.d.ts +333 -0
  17. package/dist/container-loader-untrimmed.d.ts +333 -0
  18. package/dist/container.d.ts +22 -2
  19. package/dist/container.d.ts.map +1 -1
  20. package/dist/container.js +235 -222
  21. package/dist/container.js.map +1 -1
  22. package/dist/containerContext.js +16 -16
  23. package/dist/containerContext.js.map +1 -1
  24. package/dist/containerStorageAdapter.d.ts +1 -1
  25. package/dist/containerStorageAdapter.d.ts.map +1 -1
  26. package/dist/containerStorageAdapter.js +9 -11
  27. package/dist/containerStorageAdapter.js.map +1 -1
  28. package/dist/contracts.d.ts +5 -4
  29. package/dist/contracts.d.ts.map +1 -1
  30. package/dist/contracts.js +1 -1
  31. package/dist/contracts.js.map +1 -1
  32. package/dist/debugLogger.d.ts.map +1 -1
  33. package/dist/debugLogger.js +5 -4
  34. package/dist/debugLogger.js.map +1 -1
  35. package/dist/deltaManager.d.ts.map +1 -1
  36. package/dist/deltaManager.js +92 -96
  37. package/dist/deltaManager.js.map +1 -1
  38. package/dist/deltaQueue.js +14 -14
  39. package/dist/deltaQueue.js.map +1 -1
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +6 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/loader.d.ts +6 -9
  45. package/dist/loader.d.ts.map +1 -1
  46. package/dist/loader.js +26 -91
  47. package/dist/loader.js.map +1 -1
  48. package/dist/location-redirection-utilities/index.d.ts +6 -0
  49. package/dist/location-redirection-utilities/index.d.ts.map +1 -0
  50. package/dist/location-redirection-utilities/index.js +11 -0
  51. package/dist/location-redirection-utilities/index.js.map +1 -0
  52. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +22 -0
  53. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
  54. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +51 -0
  55. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  56. package/dist/packageVersion.d.ts +1 -1
  57. package/dist/packageVersion.js +1 -1
  58. package/dist/packageVersion.js.map +1 -1
  59. package/dist/protocol.d.ts +1 -2
  60. package/dist/protocol.d.ts.map +1 -1
  61. package/dist/protocol.js +3 -5
  62. package/dist/protocol.js.map +1 -1
  63. package/dist/retriableDocumentStorageService.d.ts +3 -2
  64. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  65. package/dist/retriableDocumentStorageService.js +18 -11
  66. package/dist/retriableDocumentStorageService.js.map +1 -1
  67. package/dist/tsdoc-metadata.json +1 -1
  68. package/dist/utils.d.ts +23 -1
  69. package/dist/utils.d.ts.map +1 -1
  70. package/dist/utils.js +11 -3
  71. package/dist/utils.js.map +1 -1
  72. package/lib/catchUpMonitor.d.ts +2 -2
  73. package/lib/catchUpMonitor.d.ts.map +1 -1
  74. package/lib/connectionManager.d.ts +2 -15
  75. package/lib/connectionManager.d.ts.map +1 -1
  76. package/lib/connectionManager.js +113 -99
  77. package/lib/connectionManager.js.map +1 -1
  78. package/lib/connectionStateHandler.js +9 -9
  79. package/lib/connectionStateHandler.js.map +1 -1
  80. package/lib/container.d.ts +22 -2
  81. package/lib/container.d.ts.map +1 -1
  82. package/lib/container.js +236 -223
  83. package/lib/container.js.map +1 -1
  84. package/lib/containerContext.js +16 -16
  85. package/lib/containerContext.js.map +1 -1
  86. package/lib/containerStorageAdapter.d.ts +1 -1
  87. package/lib/containerStorageAdapter.d.ts.map +1 -1
  88. package/lib/containerStorageAdapter.js +9 -11
  89. package/lib/containerStorageAdapter.js.map +1 -1
  90. package/lib/contracts.d.ts +5 -4
  91. package/lib/contracts.d.ts.map +1 -1
  92. package/lib/contracts.js.map +1 -1
  93. package/lib/debugLogger.d.ts.map +1 -1
  94. package/lib/debugLogger.js +5 -4
  95. package/lib/debugLogger.js.map +1 -1
  96. package/lib/deltaManager.d.ts.map +1 -1
  97. package/lib/deltaManager.js +92 -96
  98. package/lib/deltaManager.js.map +1 -1
  99. package/lib/deltaQueue.js +14 -14
  100. package/lib/deltaQueue.js.map +1 -1
  101. package/lib/index.d.ts +2 -0
  102. package/lib/index.d.ts.map +1 -1
  103. package/lib/index.js +2 -0
  104. package/lib/index.js.map +1 -1
  105. package/lib/loader.d.ts +6 -9
  106. package/lib/loader.d.ts.map +1 -1
  107. package/lib/loader.js +27 -92
  108. package/lib/loader.js.map +1 -1
  109. package/lib/location-redirection-utilities/index.d.ts +6 -0
  110. package/lib/location-redirection-utilities/index.d.ts.map +1 -0
  111. package/lib/location-redirection-utilities/index.js +6 -0
  112. package/lib/location-redirection-utilities/index.js.map +1 -0
  113. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +22 -0
  114. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
  115. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +46 -0
  116. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  117. package/lib/packageVersion.d.ts +1 -1
  118. package/lib/packageVersion.js +1 -1
  119. package/lib/packageVersion.js.map +1 -1
  120. package/lib/protocol.d.ts +1 -2
  121. package/lib/protocol.d.ts.map +1 -1
  122. package/lib/protocol.js +1 -3
  123. package/lib/protocol.js.map +1 -1
  124. package/lib/retriableDocumentStorageService.d.ts +3 -2
  125. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  126. package/lib/retriableDocumentStorageService.js +18 -11
  127. package/lib/retriableDocumentStorageService.js.map +1 -1
  128. package/lib/utils.d.ts +23 -1
  129. package/lib/utils.d.ts.map +1 -1
  130. package/lib/utils.js +9 -1
  131. package/lib/utils.js.map +1 -1
  132. package/package.json +24 -26
  133. package/src/connectionManager.ts +58 -31
  134. package/src/container.ts +48 -30
  135. package/src/containerStorageAdapter.ts +3 -9
  136. package/src/contracts.ts +8 -4
  137. package/src/debugLogger.ts +5 -1
  138. package/src/deltaManager.ts +16 -31
  139. package/src/index.ts +5 -0
  140. package/src/loader.ts +31 -99
  141. package/src/location-redirection-utilities/index.ts +9 -0
  142. package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +59 -0
  143. package/src/packageVersion.ts +1 -1
  144. package/src/protocol.ts +2 -6
  145. package/src/retriableDocumentStorageService.ts +29 -15
  146. package/src/utils.ts +23 -1
@@ -136,7 +136,6 @@ export interface IPendingContainerState {
136
136
  */
137
137
  savedOps: ISequencedDocumentMessage[];
138
138
  url: string;
139
- term: number;
140
139
  clientId?: string;
141
140
  }
142
141
  export declare class Container extends EventEmitterWithErrorHandling<IContainerEvents> implements IContainer, IContainerExperimental {
@@ -207,6 +206,7 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
207
206
  private readonly savedOps;
208
207
  private baseSnapshot?;
209
208
  private baseSnapshotBlobs?;
209
+ private readonly _containerId;
210
210
  private lastVisible;
211
211
  private readonly visibilityEventHandler;
212
212
  private readonly connectionStateHandler;
@@ -214,11 +214,28 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
214
214
  private setAutoReconnectTime;
215
215
  private noopHeuristic;
216
216
  private get connectionMode();
217
+ /**
218
+ * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
219
+ */
217
220
  get IFluidRouter(): IFluidRouter;
218
221
  get resolvedUrl(): IResolvedUrl | undefined;
219
222
  get readOnlyInfo(): ReadOnlyInfo;
220
223
  /**
221
- * Tracks host requiring read-only mode.
224
+ * Sends signal to runtime (and data stores) to be read-only.
225
+ * Hosts may have read only views, indicating to data stores that no edits are allowed.
226
+ * This is independent from this._readonlyPermissions (permissions) and this.connectionMode
227
+ * (server can return "write" mode even when asked for "read")
228
+ * Leveraging same "readonly" event as runtime & data stores should behave the same in such case
229
+ * as in read-only permissions.
230
+ * But this.active can be used by some DDSes to figure out if ops can be sent
231
+ * (for example, read-only view still participates in code proposals / upgrades decisions)
232
+ *
233
+ * Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour
234
+ * the readonly flag. If ops are generated, they will accumulate locally and not be sent. If
235
+ * there are pending in the outbound queue, it will stop sending until force readonly is
236
+ * cleared.
237
+ *
238
+ * @param readonly - set or clear force readonly.
222
239
  */
223
240
  forceReadonly(readonly: boolean): void;
224
241
  get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
@@ -281,6 +298,9 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
281
298
  attach(request: IRequest, attachProps?: {
282
299
  deltaConnection?: "none" | "delayed";
283
300
  }): Promise<void>;
301
+ /**
302
+ * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
303
+ */
284
304
  request(path: IRequest): Promise<IResponse>;
285
305
  private setAutoReconnectInternal;
286
306
  connect(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAEN,oBAAoB,EAEpB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EAEX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,WAAW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YACW,SAAS;YAsCT,UAAU;IAKxB,OAAO,CAAC,oBAAoB;IAS5B;;;;OAIG;YACW,IAAI;YAiPJ,cAAc;YAwBd,6BAA6B;YAqC7B,qBAAqB;YAsBrB,mCAAmC;IAiCjD,OAAO,CAAC,uBAAuB;IA+C/B,OAAO,CAAC,sBAAsB;IA2B9B,OAAO,CAAC,wBAAwB;IAQhC,OAAO,KAAK,MAAM,GAuBjB;IAED;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,kBAAkB;YAwEZ,2BAA2B;IAiBzC,OAAO,CAAC,iCAAiC;IAkEzC,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,sBAAsB;IAuB9B,+DAA+D;IAC/D,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,oBAAoB;IAkD5B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAUrB;;;;OAIG;YACW,iBAAiB;YAqBjB,kBAAkB;IAiFhC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAMxC;IAEF;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,wBAAwB;CA2BhC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACzD;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC;;;;;OAKG;IACH,4BAA4B,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD"}
package/lib/container.js CHANGED
@@ -25,11 +25,12 @@ import { initQuorumValuesFromCodeDetails } from "./quorum";
25
25
  import { NoopHeuristic } from "./noopHeuristic";
26
26
  import { ConnectionManager } from "./connectionManager";
27
27
  import { ConnectionState } from "./connectionState";
28
- import { OnlyValidTermValue, ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol";
28
+ import { ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol";
29
29
  const detachedContainerRefSeqNumber = 0;
30
30
  const dirtyContainerEvent = "dirty";
31
31
  const savedContainerEvent = "saved";
32
32
  const packageNotFactoryError = "Code package does not implement IRuntimeFactory";
33
+ const hasBlobsSummaryTree = ".hasAttachmentBlobs";
33
34
  /**
34
35
  * Waits until container connects to delta storage and gets up-to-date.
35
36
  *
@@ -121,6 +122,222 @@ export async function ReportIfTooLong(logger, eventName, action) {
121
122
  }
122
123
  const summarizerClientType = "summarizer";
123
124
  export class Container extends EventEmitterWithErrorHandling {
125
+ /**
126
+ * Load an existing container.
127
+ * @internal
128
+ */
129
+ static async load(loadProps, createProps) {
130
+ const { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } = loadProps;
131
+ const container = new Container(createProps, loadProps);
132
+ const disableRecordHeapSize = container.mc.config.getBoolean("Fluid.Loader.DisableRecordHeapSize");
133
+ return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "Load" }, async (event) => new Promise((resolve, reject) => {
134
+ const defaultMode = { opsBeforeReturn: "cached" };
135
+ // if we have pendingLocalState, anything we cached is not useful and we shouldn't wait for connection
136
+ // to return container, so ignore this value and use undefined for opsBeforeReturn
137
+ const mode = pendingLocalState
138
+ ? { ...(loadMode ?? defaultMode), opsBeforeReturn: undefined }
139
+ : loadMode ?? defaultMode;
140
+ const onClosed = (err) => {
141
+ // pre-0.58 error message: containerClosedWithoutErrorDuringLoad
142
+ reject(err ?? new GenericError("Container closed without error during load"));
143
+ };
144
+ container.on("closed", onClosed);
145
+ container
146
+ .load(version, mode, resolvedUrl, pendingLocalState, loadToSequenceNumber)
147
+ .finally(() => {
148
+ container.removeListener("closed", onClosed);
149
+ })
150
+ .then((props) => {
151
+ event.end({ ...props, ...loadMode });
152
+ resolve(container);
153
+ }, (error) => {
154
+ const err = normalizeError(error);
155
+ // Depending where error happens, we can be attempting to connect to web socket
156
+ // and continuously retrying (consider offline mode)
157
+ // Host has no container to close, so it's prudent to do it here
158
+ // Note: We could only dispose the container instead of just close but that would
159
+ // the telemetry where users sometimes search for ContainerClose event to look
160
+ // for load failures. So not removing this at this time.
161
+ container.close(err);
162
+ container.dispose(err);
163
+ onClosed(err);
164
+ });
165
+ }), { start: true, end: true, cancel: "generic" }, disableRecordHeapSize !== true /* recordHeapSize */);
166
+ }
167
+ /**
168
+ * Create a new container in a detached state.
169
+ */
170
+ static async createDetached(createProps, codeDetails) {
171
+ const container = new Container(createProps);
172
+ return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "CreateDetached" }, async (_event) => {
173
+ await container.createDetached(codeDetails);
174
+ return container;
175
+ }, { start: true, end: true, cancel: "generic" });
176
+ }
177
+ /**
178
+ * Create a new container in a detached state that is initialized with a
179
+ * snapshot from a previous detached container.
180
+ */
181
+ static async rehydrateDetachedFromSnapshot(createProps, snapshot) {
182
+ const container = new Container(createProps);
183
+ return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
184
+ const deserializedSummary = JSON.parse(snapshot);
185
+ if (!isCombinedAppAndProtocolSummary(deserializedSummary, hasBlobsSummaryTree)) {
186
+ throw new UsageError("Cannot rehydrate detached container. Incorrect format");
187
+ }
188
+ await container.rehydrateDetachedFromSnapshot(deserializedSummary);
189
+ return container;
190
+ }, { start: true, end: true, cancel: "generic" });
191
+ }
192
+ setLoaded() {
193
+ // It's conceivable the container could be closed when this is called
194
+ // Only transition states if currently loading
195
+ if (this._lifecycleState === "loading") {
196
+ // Propagate current connection state through the system.
197
+ this.propagateConnectionState(true /* initial transition */);
198
+ this._lifecycleState = "loaded";
199
+ }
200
+ }
201
+ get closed() {
202
+ return (this._lifecycleState === "closing" || this._lifecycleState === "closed" || this.disposed);
203
+ }
204
+ get disposed() {
205
+ return this._lifecycleState === "disposing" || this._lifecycleState === "disposed";
206
+ }
207
+ get runtime() {
208
+ if (this._runtime === undefined) {
209
+ throw new Error("Attempted to access runtime before it was defined");
210
+ }
211
+ return this._runtime;
212
+ }
213
+ get protocolHandler() {
214
+ if (this._protocolHandler === undefined) {
215
+ throw new Error("Attempted to access protocolHandler before it was defined");
216
+ }
217
+ return this._protocolHandler;
218
+ }
219
+ get connectionMode() {
220
+ return this._deltaManager.connectionManager.connectionMode;
221
+ }
222
+ /**
223
+ * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
224
+ */
225
+ // eslint-disable-next-line import/no-deprecated
226
+ get IFluidRouter() {
227
+ return this;
228
+ }
229
+ get resolvedUrl() {
230
+ /**
231
+ * All attached containers will have a document service,
232
+ * this is required, as attached containers are attached to
233
+ * a service. Detached containers will neither have a document
234
+ * service or a resolved url as they only exist locally.
235
+ * in order to create a document service a resolved url must
236
+ * first be obtained, this is how the container is identified.
237
+ * Because of this, the document service's resolved url
238
+ * is always the same as the containers, as we had to
239
+ * obtain the resolved url, and then create the service from it.
240
+ */
241
+ return this.service?.resolvedUrl;
242
+ }
243
+ get readOnlyInfo() {
244
+ return this._deltaManager.readOnlyInfo;
245
+ }
246
+ /**
247
+ * Sends signal to runtime (and data stores) to be read-only.
248
+ * Hosts may have read only views, indicating to data stores that no edits are allowed.
249
+ * This is independent from this._readonlyPermissions (permissions) and this.connectionMode
250
+ * (server can return "write" mode even when asked for "read")
251
+ * Leveraging same "readonly" event as runtime & data stores should behave the same in such case
252
+ * as in read-only permissions.
253
+ * But this.active can be used by some DDSes to figure out if ops can be sent
254
+ * (for example, read-only view still participates in code proposals / upgrades decisions)
255
+ *
256
+ * Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour
257
+ * the readonly flag. If ops are generated, they will accumulate locally and not be sent. If
258
+ * there are pending in the outbound queue, it will stop sending until force readonly is
259
+ * cleared.
260
+ *
261
+ * @param readonly - set or clear force readonly.
262
+ */
263
+ forceReadonly(readonly) {
264
+ this._deltaManager.connectionManager.forceReadonly(readonly);
265
+ }
266
+ get deltaManager() {
267
+ return this._deltaManager;
268
+ }
269
+ get connectionState() {
270
+ return this.connectionStateHandler.connectionState;
271
+ }
272
+ get connected() {
273
+ return this.connectionStateHandler.connectionState === ConnectionState.Connected;
274
+ }
275
+ /**
276
+ * The server provided id of the client.
277
+ * Set once this.connected is true, otherwise undefined
278
+ */
279
+ get clientId() {
280
+ return this._clientId;
281
+ }
282
+ get offlineLoadEnabled() {
283
+ const enabled = this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad") ??
284
+ this.options?.enableOfflineLoad === true;
285
+ // summarizer will not have any pending state we want to save
286
+ return enabled && this.deltaManager.clientDetails.capabilities.interactive;
287
+ }
288
+ /**
289
+ * Get the code details that are currently specified for the container.
290
+ * @returns The current code details if any are specified, undefined if none are specified.
291
+ */
292
+ getSpecifiedCodeDetails() {
293
+ return this.getCodeDetailsFromQuorum();
294
+ }
295
+ /**
296
+ * Get the code details that were used to load the container.
297
+ * @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
298
+ * loaded.
299
+ */
300
+ getLoadedCodeDetails() {
301
+ return this._loadedCodeDetails;
302
+ }
303
+ /**
304
+ * Retrieves the audience associated with the document
305
+ */
306
+ get audience() {
307
+ return this.protocolHandler.audience;
308
+ }
309
+ /**
310
+ * Returns true if container is dirty.
311
+ * Which means data loss if container is closed at that same moment
312
+ * Most likely that happens when there is no network connection to Relay Service
313
+ */
314
+ get isDirty() {
315
+ return this._dirtyContainer;
316
+ }
317
+ /**
318
+ * {@inheritDoc @fluidframework/container-definitions#IContainer.entryPoint}
319
+ */
320
+ async getEntryPoint() {
321
+ if (this._disposed) {
322
+ throw new UsageError("The context is already disposed");
323
+ }
324
+ if (this._runtime !== undefined) {
325
+ return this._runtime.getEntryPoint?.();
326
+ }
327
+ return new Promise((resolve, reject) => {
328
+ const runtimeInstantiatedHandler = () => {
329
+ assert(this._runtime !== undefined, 0x5a3 /* runtimeInstantiated fired but runtime is still undefined */);
330
+ resolve(this._runtime.getEntryPoint?.());
331
+ this._lifecycleEvents.off("disposed", disposedHandler);
332
+ };
333
+ const disposedHandler = () => {
334
+ reject(new Error("ContainerContext was disposed"));
335
+ this._lifecycleEvents.off("runtimeInstantiated", runtimeInstantiatedHandler);
336
+ };
337
+ this._lifecycleEvents.once("runtimeInstantiated", runtimeInstantiatedHandler);
338
+ this._lifecycleEvents.once("disposed", disposedHandler);
339
+ });
340
+ }
124
341
  /**
125
342
  * @internal
126
343
  */
@@ -201,6 +418,7 @@ export class Container extends EventEmitterWithErrorHandling {
201
418
  const type = this.client.details.type;
202
419
  const interactive = this.client.details.capabilities.interactive;
203
420
  const clientType = `${interactive ? "interactive" : "noninteractive"}${type !== undefined && type !== "" ? `/${type}` : ""}`;
421
+ this._containerId = uuid();
204
422
  // Need to use the property getter for docId because for detached flow we don't have the docId initially.
205
423
  // We assign the id later so property getter is used.
206
424
  this.subLogger = createChildLogger({
@@ -208,7 +426,7 @@ export class Container extends EventEmitterWithErrorHandling {
208
426
  properties: {
209
427
  all: {
210
428
  clientType,
211
- containerId: uuid(),
429
+ containerId: this._containerId,
212
430
  docId: () => this.resolvedUrl?.id,
213
431
  containerAttachState: () => this._attachState,
214
432
  containerLifecycleState: () => this._lifecycleState,
@@ -323,201 +541,6 @@ export class Container extends EventEmitterWithErrorHandling {
323
541
  document.addEventListener("visibilitychange", this.visibilityEventHandler);
324
542
  }
325
543
  }
326
- /**
327
- * Load an existing container.
328
- * @internal
329
- */
330
- static async load(loadProps, createProps) {
331
- const { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } = loadProps;
332
- const container = new Container(createProps, loadProps);
333
- const disableRecordHeapSize = container.mc.config.getBoolean("Fluid.Loader.DisableRecordHeapSize");
334
- return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "Load" }, async (event) => new Promise((resolve, reject) => {
335
- const defaultMode = { opsBeforeReturn: "cached" };
336
- // if we have pendingLocalState, anything we cached is not useful and we shouldn't wait for connection
337
- // to return container, so ignore this value and use undefined for opsBeforeReturn
338
- const mode = pendingLocalState
339
- ? { ...(loadMode ?? defaultMode), opsBeforeReturn: undefined }
340
- : loadMode ?? defaultMode;
341
- const onClosed = (err) => {
342
- // pre-0.58 error message: containerClosedWithoutErrorDuringLoad
343
- reject(err ?? new GenericError("Container closed without error during load"));
344
- };
345
- container.on("closed", onClosed);
346
- container
347
- .load(version, mode, resolvedUrl, pendingLocalState, loadToSequenceNumber)
348
- .finally(() => {
349
- container.removeListener("closed", onClosed);
350
- })
351
- .then((props) => {
352
- event.end({ ...props, ...loadMode });
353
- resolve(container);
354
- }, (error) => {
355
- const err = normalizeError(error);
356
- // Depending where error happens, we can be attempting to connect to web socket
357
- // and continuously retrying (consider offline mode)
358
- // Host has no container to close, so it's prudent to do it here
359
- // Note: We could only dispose the container instead of just close but that would
360
- // the telemetry where users sometimes search for ContainerClose event to look
361
- // for load failures. So not removing this at this time.
362
- container.close(err);
363
- container.dispose(err);
364
- onClosed(err);
365
- });
366
- }), { start: true, end: true, cancel: "generic" }, disableRecordHeapSize !== true /* recordHeapSize */);
367
- }
368
- /**
369
- * Create a new container in a detached state.
370
- */
371
- static async createDetached(createProps, codeDetails) {
372
- const container = new Container(createProps);
373
- return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "CreateDetached" }, async (_event) => {
374
- await container.createDetached(codeDetails);
375
- return container;
376
- }, { start: true, end: true, cancel: "generic" });
377
- }
378
- /**
379
- * Create a new container in a detached state that is initialized with a
380
- * snapshot from a previous detached container.
381
- */
382
- static async rehydrateDetachedFromSnapshot(createProps, snapshot) {
383
- const container = new Container(createProps);
384
- return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
385
- const deserializedSummary = JSON.parse(snapshot);
386
- await container.rehydrateDetachedFromSnapshot(deserializedSummary);
387
- return container;
388
- }, { start: true, end: true, cancel: "generic" });
389
- }
390
- setLoaded() {
391
- // It's conceivable the container could be closed when this is called
392
- // Only transition states if currently loading
393
- if (this._lifecycleState === "loading") {
394
- // Propagate current connection state through the system.
395
- this.propagateConnectionState(true /* initial transition */);
396
- this._lifecycleState = "loaded";
397
- }
398
- }
399
- get closed() {
400
- return (this._lifecycleState === "closing" || this._lifecycleState === "closed" || this.disposed);
401
- }
402
- get disposed() {
403
- return this._lifecycleState === "disposing" || this._lifecycleState === "disposed";
404
- }
405
- get runtime() {
406
- if (this._runtime === undefined) {
407
- throw new Error("Attempted to access runtime before it was defined");
408
- }
409
- return this._runtime;
410
- }
411
- get protocolHandler() {
412
- if (this._protocolHandler === undefined) {
413
- throw new Error("Attempted to access protocolHandler before it was defined");
414
- }
415
- return this._protocolHandler;
416
- }
417
- get connectionMode() {
418
- return this._deltaManager.connectionManager.connectionMode;
419
- }
420
- get IFluidRouter() {
421
- return this;
422
- }
423
- get resolvedUrl() {
424
- /**
425
- * All attached containers will have a document service,
426
- * this is required, as attached containers are attached to
427
- * a service. Detached containers will neither have a document
428
- * service or a resolved url as they only exist locally.
429
- * in order to create a document service a resolved url must
430
- * first be obtained, this is how the container is identified.
431
- * Because of this, the document service's resolved url
432
- * is always the same as the containers, as we had to
433
- * obtain the resolved url, and then create the service from it.
434
- */
435
- return this.service?.resolvedUrl;
436
- }
437
- get readOnlyInfo() {
438
- return this._deltaManager.readOnlyInfo;
439
- }
440
- /**
441
- * Tracks host requiring read-only mode.
442
- */
443
- forceReadonly(readonly) {
444
- this._deltaManager.connectionManager.forceReadonly(readonly);
445
- }
446
- get deltaManager() {
447
- return this._deltaManager;
448
- }
449
- get connectionState() {
450
- return this.connectionStateHandler.connectionState;
451
- }
452
- get connected() {
453
- return this.connectionStateHandler.connectionState === ConnectionState.Connected;
454
- }
455
- /**
456
- * The server provided id of the client.
457
- * Set once this.connected is true, otherwise undefined
458
- */
459
- get clientId() {
460
- return this._clientId;
461
- }
462
- get offlineLoadEnabled() {
463
- const enabled = this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad") ??
464
- this.options?.enableOfflineLoad === true;
465
- // summarizer will not have any pending state we want to save
466
- return enabled && this.deltaManager.clientDetails.capabilities.interactive;
467
- }
468
- /**
469
- * Get the code details that are currently specified for the container.
470
- * @returns The current code details if any are specified, undefined if none are specified.
471
- */
472
- getSpecifiedCodeDetails() {
473
- return this.getCodeDetailsFromQuorum();
474
- }
475
- /**
476
- * Get the code details that were used to load the container.
477
- * @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
478
- * loaded.
479
- */
480
- getLoadedCodeDetails() {
481
- return this._loadedCodeDetails;
482
- }
483
- /**
484
- * Retrieves the audience associated with the document
485
- */
486
- get audience() {
487
- return this.protocolHandler.audience;
488
- }
489
- /**
490
- * Returns true if container is dirty.
491
- * Which means data loss if container is closed at that same moment
492
- * Most likely that happens when there is no network connection to Relay Service
493
- */
494
- get isDirty() {
495
- return this._dirtyContainer;
496
- }
497
- /**
498
- * {@inheritDoc @fluidframework/container-definitions#IContainer.entryPoint}
499
- */
500
- async getEntryPoint() {
501
- if (this._disposed) {
502
- throw new UsageError("The context is already disposed");
503
- }
504
- if (this._runtime !== undefined) {
505
- return this._runtime.getEntryPoint?.();
506
- }
507
- return new Promise((resolve, reject) => {
508
- const runtimeInstantiatedHandler = () => {
509
- assert(this._runtime !== undefined, 0x5a3 /* runtimeInstantiated fired but runtime is still undefined */);
510
- resolve(this._runtime.getEntryPoint?.());
511
- this._lifecycleEvents.off("disposed", disposedHandler);
512
- };
513
- const disposedHandler = () => {
514
- reject(new Error("ContainerContext was disposed"));
515
- this._lifecycleEvents.off("runtimeInstantiated", runtimeInstantiatedHandler);
516
- };
517
- this._lifecycleEvents.once("runtimeInstantiated", runtimeInstantiatedHandler);
518
- this._lifecycleEvents.once("disposed", disposedHandler);
519
- });
520
- }
521
544
  /**
522
545
  * Retrieves the quorum associated with the document
523
546
  */
@@ -652,7 +675,6 @@ export class Container extends EventEmitterWithErrorHandling {
652
675
  snapshotBlobs: this.baseSnapshotBlobs,
653
676
  savedOps: this.savedOps,
654
677
  url: this.resolvedUrl.url,
655
- term: OnlyValidTermValue,
656
678
  // no need to save this if there is no pending runtime state
657
679
  clientId: pendingRuntimeState !== undefined ? this.clientId : undefined,
658
680
  };
@@ -668,7 +690,7 @@ export class Container extends EventEmitterWithErrorHandling {
668
690
  const protocolSummary = this.captureProtocolSummary();
669
691
  const combinedSummary = combineAppAndProtocolSummary(appSummary, protocolSummary);
670
692
  if (this.detachedBlobStorage && this.detachedBlobStorage.size > 0) {
671
- combinedSummary.tree[".hasAttachmentBlobs"] = {
693
+ combinedSummary.tree[hasBlobsSummaryTree] = {
672
694
  type: SummaryType.Blob,
673
695
  content: "true",
674
696
  };
@@ -718,7 +740,7 @@ export class Container extends EventEmitterWithErrorHandling {
718
740
  cancel: this._deltaManager.closeAbortController.signal,
719
741
  });
720
742
  }
721
- await this.storageAdapter.connectToService(this.service);
743
+ this.storageAdapter.connectToService(this.service);
722
744
  if (hasAttachmentBlobs) {
723
745
  // upload blobs to storage
724
746
  assert(!!this.detachedBlobStorage, 0x24e /* "assertion for type narrowing" */);
@@ -774,6 +796,9 @@ export class Container extends EventEmitterWithErrorHandling {
774
796
  }
775
797
  }, { start: true, end: true, cancel: "generic" });
776
798
  }
799
+ /**
800
+ * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
801
+ */
777
802
  async request(path) {
778
803
  return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "Request" }, async () => this.runtime.request(path), { end: true, cancel: "error" });
779
804
  }
@@ -924,18 +949,14 @@ export class Container extends EventEmitterWithErrorHandling {
924
949
  async load(specifiedVersion, loadMode, resolvedUrl, pendingLocalState, loadToSequenceNumber) {
925
950
  const timings = { phase1: performance.now() };
926
951
  this.service = await this.serviceFactory.createDocumentService(resolvedUrl, this.subLogger, this.client.details.type === summarizerClientType);
927
- // Ideally we always connect as "read" by default.
928
- // Currently that works with SPO & r11s, because we get "write" connection when connecting to non-existing file.
929
- // We should not rely on it by (one of them will address the issue, but we need to address both)
930
- // 1) switching create new flow to one where we create file by posting snapshot
931
- // 2) Fixing quorum workflows (have retry logic)
932
- // That all said, "read" does not work with memorylicious workflows (that opens two simultaneous
933
- // connections to same file) in two ways:
934
- // A) creation flow breaks (as one of the clients "sees" file as existing, and hits #2 above)
935
- // B) Once file is created, transition from view-only connection to write does not work - some bugs to be fixed.
952
+ // Except in cases where it has stashed ops or requested by feature gate, the container will connect in "read" mode
953
+ const mode = this.mc.config.getBoolean("Fluid.Container.ForceWriteConnection") === true ||
954
+ (pendingLocalState?.savedOps.length ?? 0) > 0
955
+ ? "write"
956
+ : "read";
936
957
  const connectionArgs = {
937
958
  reason: { text: "DocumentOpen" },
938
- mode: "write",
959
+ mode,
939
960
  fetchOpsFromStorage: false,
940
961
  };
941
962
  // Start websocket connection as soon as possible. Note that there is no op handler attached yet, but the
@@ -943,15 +964,7 @@ export class Container extends EventEmitterWithErrorHandling {
943
964
  if (loadMode.deltaConnection === undefined && !pendingLocalState) {
944
965
  this.connectToDeltaStream(connectionArgs);
945
966
  }
946
- if (!pendingLocalState) {
947
- await this.storageAdapter.connectToService(this.service);
948
- }
949
- else {
950
- // if we have pendingLocalState we can load without storage; don't wait for connection
951
- this.storageAdapter.connectToService(this.service).catch((error) => {
952
- this.close(error);
953
- });
954
- }
967
+ this.storageAdapter.connectToService(this.service);
955
968
  this._attachState = AttachState.Attached;
956
969
  timings.phase2 = performance.now();
957
970
  // Fetch specified snapshot.
@@ -1100,7 +1113,6 @@ export class Container extends EventEmitterWithErrorHandling {
1100
1113
  async createDetached(codeDetails) {
1101
1114
  const attributes = {
1102
1115
  sequenceNumber: detachedContainerRefSeqNumber,
1103
- term: OnlyValidTermValue,
1104
1116
  minimumSequenceNumber: 0,
1105
1117
  };
1106
1118
  await this.attachDeltaManagerOpHandler(attributes);
@@ -1115,9 +1127,10 @@ export class Container extends EventEmitterWithErrorHandling {
1115
1127
  this.setLoaded();
1116
1128
  }
1117
1129
  async rehydrateDetachedFromSnapshot(detachedContainerSnapshot) {
1118
- if (detachedContainerSnapshot.tree[".hasAttachmentBlobs"] !== undefined) {
1130
+ if (detachedContainerSnapshot.tree[hasBlobsSummaryTree] !== undefined) {
1119
1131
  assert(!!this.detachedBlobStorage && this.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
1120
- delete detachedContainerSnapshot.tree[".hasAttachmentBlobs"];
1132
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
1133
+ delete detachedContainerSnapshot.tree[hasBlobsSummaryTree];
1121
1134
  }
1122
1135
  const snapshotTree = getSnapshotTreeFromSerializedContainer(detachedContainerSnapshot);
1123
1136
  this.storageAdapter.loadSnapshotForRehydratingContainer(snapshotTree);
@@ -1140,7 +1153,6 @@ export class Container extends EventEmitterWithErrorHandling {
1140
1153
  return {
1141
1154
  minimumSequenceNumber: 0,
1142
1155
  sequenceNumber: 0,
1143
- term: OnlyValidTermValue,
1144
1156
  };
1145
1157
  }
1146
1158
  // Backward compatibility: old docs would have ".attributes" instead of "attributes"
@@ -1251,6 +1263,7 @@ export class Container extends EventEmitterWithErrorHandling {
1251
1263
  client.details.environment = [
1252
1264
  client.details.environment,
1253
1265
  ` loaderVersion:${pkgVersion}`,
1266
+ ` containerId:${this._containerId}`,
1254
1267
  ].join(";");
1255
1268
  return client;
1256
1269
  }