@fluidframework/container-loader 2.0.0-internal.5.3.4 → 2.0.0-internal.5.4.2

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 (78) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +6 -3
  3. package/dist/audience.d.ts +1 -0
  4. package/dist/audience.d.ts.map +1 -1
  5. package/dist/audience.js +3 -1
  6. package/dist/audience.js.map +1 -1
  7. package/dist/connectionManager.d.ts.map +1 -1
  8. package/dist/connectionManager.js +6 -11
  9. package/dist/connectionManager.js.map +1 -1
  10. package/dist/container.d.ts +2 -3
  11. package/dist/container.d.ts.map +1 -1
  12. package/dist/container.js +58 -93
  13. package/dist/container.js.map +1 -1
  14. package/dist/debugLogger.d.ts +30 -0
  15. package/dist/debugLogger.d.ts.map +1 -0
  16. package/dist/debugLogger.js +96 -0
  17. package/dist/debugLogger.js.map +1 -0
  18. package/dist/deltaManager.d.ts +0 -1
  19. package/dist/deltaManager.d.ts.map +1 -1
  20. package/dist/deltaManager.js +17 -9
  21. package/dist/deltaManager.js.map +1 -1
  22. package/dist/loader.d.ts.map +1 -1
  23. package/dist/loader.js +16 -5
  24. package/dist/loader.js.map +1 -1
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/protocol.d.ts +4 -2
  29. package/dist/protocol.d.ts.map +1 -1
  30. package/dist/protocol.js +23 -1
  31. package/dist/protocol.js.map +1 -1
  32. package/dist/quorum.d.ts +4 -1
  33. package/dist/quorum.d.ts.map +1 -1
  34. package/dist/quorum.js +1 -13
  35. package/dist/quorum.js.map +1 -1
  36. package/lib/audience.d.ts +1 -0
  37. package/lib/audience.d.ts.map +1 -1
  38. package/lib/audience.js +3 -1
  39. package/lib/audience.js.map +1 -1
  40. package/lib/connectionManager.d.ts.map +1 -1
  41. package/lib/connectionManager.js +7 -9
  42. package/lib/connectionManager.js.map +1 -1
  43. package/lib/container.d.ts +2 -3
  44. package/lib/container.d.ts.map +1 -1
  45. package/lib/container.js +61 -96
  46. package/lib/container.js.map +1 -1
  47. package/lib/debugLogger.d.ts +30 -0
  48. package/lib/debugLogger.d.ts.map +1 -0
  49. package/lib/debugLogger.js +92 -0
  50. package/lib/debugLogger.js.map +1 -0
  51. package/lib/deltaManager.d.ts +0 -1
  52. package/lib/deltaManager.d.ts.map +1 -1
  53. package/lib/deltaManager.js +15 -4
  54. package/lib/deltaManager.js.map +1 -1
  55. package/lib/loader.d.ts.map +1 -1
  56. package/lib/loader.js +16 -5
  57. package/lib/loader.js.map +1 -1
  58. package/lib/packageVersion.d.ts +1 -1
  59. package/lib/packageVersion.js +1 -1
  60. package/lib/packageVersion.js.map +1 -1
  61. package/lib/protocol.d.ts +4 -2
  62. package/lib/protocol.d.ts.map +1 -1
  63. package/lib/protocol.js +23 -1
  64. package/lib/protocol.js.map +1 -1
  65. package/lib/quorum.d.ts +4 -1
  66. package/lib/quorum.d.ts.map +1 -1
  67. package/lib/quorum.js +0 -11
  68. package/lib/quorum.js.map +1 -1
  69. package/package.json +12 -12
  70. package/src/audience.ts +6 -0
  71. package/src/connectionManager.ts +7 -12
  72. package/src/container.ts +78 -116
  73. package/src/debugLogger.ts +113 -0
  74. package/src/deltaManager.ts +28 -4
  75. package/src/loader.ts +16 -7
  76. package/src/packageVersion.ts +1 -1
  77. package/src/protocol.ts +33 -1
  78. package/src/quorum.ts +0 -10
package/lib/container.js CHANGED
@@ -8,9 +8,9 @@ import { v4 as uuid } from "uuid";
8
8
  import { TypedEventEmitter, assert, performance, unreachableCase, } from "@fluidframework/common-utils";
9
9
  import { AttachState, isFluidCodeDetails, } from "@fluidframework/container-definitions";
10
10
  import { GenericError, UsageError } from "@fluidframework/container-utils";
11
- import { readAndParse, OnlineStatus, isOnline, combineAppAndProtocolSummary, runWithRetry, isCombinedAppAndProtocolSummary, MessageType2, canBeCoalescedByService, } from "@fluidframework/driver-utils";
11
+ import { readAndParse, OnlineStatus, isOnline, combineAppAndProtocolSummary, runWithRetry, isCombinedAppAndProtocolSummary, MessageType2, } from "@fluidframework/driver-utils";
12
12
  import { MessageType, SummaryType, } from "@fluidframework/protocol-definitions";
13
- import { ChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, TelemetryLogger, connectedEventName, normalizeError, loggerToMonitoringContext, wrapError, } from "@fluidframework/telemetry-utils";
13
+ import { createChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, connectedEventName, normalizeError, createChildMonitoringContext, wrapError, formatTick, } from "@fluidframework/telemetry-utils";
14
14
  import { Audience } from "./audience";
15
15
  import { ContainerContext } from "./containerContext";
16
16
  import { ReconnectMode, getPackageName } from "./contracts";
@@ -20,7 +20,7 @@ import { pkgVersion } from "./packageVersion";
20
20
  import { ContainerStorageAdapter, getBlobContentsFromTree, getBlobContentsFromTreeWithBlobContents, } from "./containerStorageAdapter";
21
21
  import { createConnectionStateHandler } from "./connectionStateHandler";
22
22
  import { getProtocolSnapshotTree, getSnapshotTreeFromSerializedContainer } from "./utils";
23
- import { initQuorumValuesFromCodeDetails, getCodeDetailsFromQuorumValues } from "./quorum";
23
+ import { initQuorumValuesFromCodeDetails } from "./quorum";
24
24
  import { NoopHeuristic } from "./noopHeuristic";
25
25
  import { ConnectionManager } from "./connectionManager";
26
26
  import { ConnectionState } from "./connectionState";
@@ -152,7 +152,6 @@ export class Container extends EventEmitterWithErrorHandling {
152
152
  this.inboundQueuePausedFromInit = true;
153
153
  this.firstConnection = true;
154
154
  this.connectionTransitionTimes = [];
155
- this.messageCountAfterDisconnection = 0;
156
155
  this.attachStarted = false;
157
156
  this._dirtyContainer = false;
158
157
  this.savedOps = [];
@@ -188,7 +187,7 @@ export class Container extends EventEmitterWithErrorHandling {
188
187
  this.scope = scope;
189
188
  this.detachedBlobStorage = detachedBlobStorage;
190
189
  this.protocolHandlerBuilder =
191
- protocolHandlerBuilder !== null && protocolHandlerBuilder !== void 0 ? protocolHandlerBuilder : ((...args) => new ProtocolHandler(...args, new Audience()));
190
+ protocolHandlerBuilder !== null && protocolHandlerBuilder !== void 0 ? protocolHandlerBuilder : ((attributes, quorumSnapshot, sendProposal) => new ProtocolHandler(attributes, quorumSnapshot, sendProposal, new Audience(), (clientId) => this.clientsWhoShouldHaveLeft.has(clientId)));
192
191
  // Note that we capture the createProps here so we can replicate the creation call when we want to clone.
193
192
  this.clone = async (_loadProps, createParamOverrides) => {
194
193
  return Container.load(_loadProps, Object.assign(Object.assign({}, createProps), createParamOverrides));
@@ -199,42 +198,45 @@ export class Container extends EventEmitterWithErrorHandling {
199
198
  const clientType = `${interactive ? "interactive" : "noninteractive"}${type !== undefined && type !== "" ? `/${type}` : ""}`;
200
199
  // Need to use the property getter for docId because for detached flow we don't have the docId initially.
201
200
  // We assign the id later so property getter is used.
202
- this.subLogger = ChildLogger.create(subLogger, undefined, {
203
- all: {
204
- clientType,
205
- containerId: uuid(),
206
- docId: () => { var _a; return (_a = this.resolvedUrl) === null || _a === void 0 ? void 0 : _a.id; },
207
- containerAttachState: () => this._attachState,
208
- containerLifecycleState: () => this._lifecycleState,
209
- containerConnectionState: () => ConnectionState[this.connectionState],
210
- serializedContainer: pendingLocalState !== undefined,
211
- },
212
- // we need to be judicious with our logging here to avoid generating too much data
213
- // all data logged here should be broadly applicable, and not specific to a
214
- // specific error or class of errors
215
- error: {
216
- // load information to associate errors with the specific load point
217
- dmInitialSeqNumber: () => { var _a; return (_a = this._deltaManager) === null || _a === void 0 ? void 0 : _a.initialSequenceNumber; },
218
- dmLastProcessedSeqNumber: () => { var _a; return (_a = this._deltaManager) === null || _a === void 0 ? void 0 : _a.lastSequenceNumber; },
219
- dmLastKnownSeqNumber: () => { var _a; return (_a = this._deltaManager) === null || _a === void 0 ? void 0 : _a.lastKnownSeqNumber; },
220
- containerLoadedFromVersionId: () => { var _a; return (_a = this._loadedFromVersion) === null || _a === void 0 ? void 0 : _a.id; },
221
- containerLoadedFromVersionDate: () => { var _a; return (_a = this._loadedFromVersion) === null || _a === void 0 ? void 0 : _a.date; },
222
- // message information to associate errors with the specific execution state
223
- // dmLastMsqSeqNumber: if present, same as dmLastProcessedSeqNumber
224
- dmLastMsqSeqNumber: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.sequenceNumber; },
225
- dmLastMsqSeqTimestamp: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.timestamp; },
226
- dmLastMsqSeqClientId: () => {
227
- var _a, _b, _c, _d;
228
- return ((_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.clientId) === null
229
- ? "null"
230
- : (_d = (_c = this.deltaManager) === null || _c === void 0 ? void 0 : _c.lastMessage) === null || _d === void 0 ? void 0 : _d.clientId;
201
+ this.subLogger = createChildLogger({
202
+ logger: subLogger,
203
+ properties: {
204
+ all: {
205
+ clientType,
206
+ containerId: uuid(),
207
+ docId: () => { var _a; return (_a = this.resolvedUrl) === null || _a === void 0 ? void 0 : _a.id; },
208
+ containerAttachState: () => this._attachState,
209
+ containerLifecycleState: () => this._lifecycleState,
210
+ containerConnectionState: () => ConnectionState[this.connectionState],
211
+ serializedContainer: pendingLocalState !== undefined,
212
+ },
213
+ // we need to be judicious with our logging here to avoid generating too much data
214
+ // all data logged here should be broadly applicable, and not specific to a
215
+ // specific error or class of errors
216
+ error: {
217
+ // load information to associate errors with the specific load point
218
+ dmInitialSeqNumber: () => { var _a; return (_a = this._deltaManager) === null || _a === void 0 ? void 0 : _a.initialSequenceNumber; },
219
+ dmLastProcessedSeqNumber: () => { var _a; return (_a = this._deltaManager) === null || _a === void 0 ? void 0 : _a.lastSequenceNumber; },
220
+ dmLastKnownSeqNumber: () => { var _a; return (_a = this._deltaManager) === null || _a === void 0 ? void 0 : _a.lastKnownSeqNumber; },
221
+ containerLoadedFromVersionId: () => { var _a; return (_a = this._loadedFromVersion) === null || _a === void 0 ? void 0 : _a.id; },
222
+ containerLoadedFromVersionDate: () => { var _a; return (_a = this._loadedFromVersion) === null || _a === void 0 ? void 0 : _a.date; },
223
+ // message information to associate errors with the specific execution state
224
+ // dmLastMsqSeqNumber: if present, same as dmLastProcessedSeqNumber
225
+ dmLastMsqSeqNumber: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.sequenceNumber; },
226
+ dmLastMsqSeqTimestamp: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.timestamp; },
227
+ dmLastMsqSeqClientId: () => {
228
+ var _a, _b, _c, _d;
229
+ return ((_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.clientId) === null
230
+ ? "null"
231
+ : (_d = (_c = this.deltaManager) === null || _c === void 0 ? void 0 : _c.lastMessage) === null || _d === void 0 ? void 0 : _d.clientId;
232
+ },
233
+ dmLastMsgClientSeq: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.clientSequenceNumber; },
234
+ connectionStateDuration: () => performance.now() - this.connectionTransitionTimes[this.connectionState],
231
235
  },
232
- dmLastMsgClientSeq: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.clientSequenceNumber; },
233
- connectionStateDuration: () => performance.now() - this.connectionTransitionTimes[this.connectionState],
234
236
  },
235
237
  });
236
238
  // Prefix all events in this file with container-loader
237
- this.mc = loggerToMonitoringContext(ChildLogger.create(this.subLogger, "Container"));
239
+ this.mc = createChildMonitoringContext({ logger: this.subLogger, namespace: "Container" });
238
240
  this._deltaManager = this.createDeltaManager();
239
241
  this.connectionStateHandler = createConnectionStateHandler({
240
242
  logger: this.mc.logger,
@@ -295,8 +297,8 @@ export class Container extends EventEmitterWithErrorHandling {
295
297
  document !== null &&
296
298
  typeof document.addEventListener === "function" &&
297
299
  document.addEventListener !== null;
298
- // keep track of last time page was visible for telemetry
299
- if (isDomAvailable) {
300
+ // keep track of last time page was visible for telemetry (on interactive clients only)
301
+ if (isDomAvailable && interactive) {
300
302
  this.lastVisible = document.hidden ? performance.now() : undefined;
301
303
  this.visibilityEventHandler = () => {
302
304
  if (document.hidden) {
@@ -381,10 +383,10 @@ export class Container extends EventEmitterWithErrorHandling {
381
383
  }
382
384
  }
383
385
  get closed() {
384
- return (this._lifecycleState === "closing" ||
385
- this._lifecycleState === "closed" ||
386
- this._lifecycleState === "disposing" ||
387
- this._lifecycleState === "disposed");
386
+ return (this._lifecycleState === "closing" || this._lifecycleState === "closed" || this.disposed);
387
+ }
388
+ get disposed() {
389
+ return this._lifecycleState === "disposing" || this._lifecycleState === "disposed";
388
390
  }
389
391
  get runtime() {
390
392
  if (this._runtime === undefined) {
@@ -971,8 +973,7 @@ export class Container extends EventEmitterWithErrorHandling {
971
973
  // Initialize the protocol handler
972
974
  await this.initializeProtocolStateFromSnapshot(attributes, this.storageAdapter, snapshot);
973
975
  const codeDetails = this.getCodeDetailsFromQuorum();
974
- await this.instantiateContext(true, // existing
975
- codeDetails, snapshot, pendingLocalState === null || pendingLocalState === void 0 ? void 0 : pendingLocalState.pendingRuntimeState);
976
+ await this.instantiateRuntime(codeDetails, snapshot, pendingLocalState === null || pendingLocalState === void 0 ? void 0 : pendingLocalState.pendingRuntimeState);
976
977
  // replay saved ops
977
978
  if (pendingLocalState) {
978
979
  for (const message of pendingLocalState.savedOps) {
@@ -1031,7 +1032,7 @@ export class Container extends EventEmitterWithErrorHandling {
1031
1032
  dmLastKnownSeqNumber: this._deltaManager.lastKnownSeqNumber,
1032
1033
  };
1033
1034
  }
1034
- async createDetached(source) {
1035
+ async createDetached(codeDetails) {
1035
1036
  const attributes = {
1036
1037
  sequenceNumber: detachedContainerRefSeqNumber,
1037
1038
  term: OnlyValidTermValue,
@@ -1039,14 +1040,13 @@ export class Container extends EventEmitterWithErrorHandling {
1039
1040
  };
1040
1041
  await this.attachDeltaManagerOpHandler(attributes);
1041
1042
  // Need to just seed the source data in the code quorum. Quorum itself is empty
1042
- const qValues = initQuorumValuesFromCodeDetails(source);
1043
+ const qValues = initQuorumValuesFromCodeDetails(codeDetails);
1043
1044
  this.initializeProtocolState(attributes, {
1044
1045
  members: [],
1045
1046
  proposals: [],
1046
1047
  values: qValues,
1047
1048
  });
1048
- // The load context - given we seeded the quorum - will be great
1049
- await this.instantiateContextDetached(false);
1049
+ await this.instantiateRuntime(codeDetails, undefined);
1050
1050
  this.setLoaded();
1051
1051
  }
1052
1052
  async rehydrateDetachedFromSnapshot(detachedContainerSnapshot) {
@@ -1061,14 +1061,13 @@ export class Container extends EventEmitterWithErrorHandling {
1061
1061
  // Initialize the protocol handler
1062
1062
  const baseTree = getProtocolSnapshotTree(snapshotTree);
1063
1063
  const qValues = await readAndParse(this.storageAdapter, baseTree.blobs.quorumValues);
1064
- const codeDetails = getCodeDetailsFromQuorumValues(qValues);
1065
1064
  this.initializeProtocolState(attributes, {
1066
1065
  members: [],
1067
1066
  proposals: [],
1068
- values: codeDetails !== undefined ? initQuorumValuesFromCodeDetails(codeDetails) : [],
1067
+ values: qValues,
1069
1068
  });
1070
- await this.instantiateContextDetached(true, // existing
1071
- snapshotTree);
1069
+ const codeDetails = this.getCodeDetailsFromQuorum();
1070
+ await this.instantiateRuntime(codeDetails, snapshotTree);
1072
1071
  this.setLoaded();
1073
1072
  }
1074
1073
  async getDocumentAttributes(storage, tree) {
@@ -1105,7 +1104,10 @@ export class Container extends EventEmitterWithErrorHandling {
1105
1104
  }
1106
1105
  initializeProtocolState(attributes, quorumSnapshot) {
1107
1106
  const protocol = this.protocolHandlerBuilder(attributes, quorumSnapshot, (key, value) => this.submitMessage(MessageType.Propose, JSON.stringify({ key, value })));
1108
- const protocolLogger = ChildLogger.create(this.subLogger, "ProtocolHandler");
1107
+ const protocolLogger = createChildLogger({
1108
+ logger: this.subLogger,
1109
+ namespace: "ProtocolHandler",
1110
+ });
1109
1111
  protocol.quorum.on("error", (error) => {
1110
1112
  protocolLogger.sendErrorEvent(error);
1111
1113
  });
@@ -1199,7 +1201,7 @@ export class Container extends EventEmitterWithErrorHandling {
1199
1201
  }
1200
1202
  createDeltaManager() {
1201
1203
  const serviceProvider = () => this.service;
1202
- const deltaManager = new DeltaManager(serviceProvider, ChildLogger.create(this.subLogger, "DeltaManager"), () => this.activeConnection(), (props) => new ConnectionManager(serviceProvider, () => this.isDirty, this.client, this._canReconnect, ChildLogger.create(this.subLogger, "ConnectionManager"), props));
1204
+ const deltaManager = new DeltaManager(serviceProvider, createChildLogger({ logger: this.subLogger, namespace: "DeltaManager" }), () => this.activeConnection(), (props) => new ConnectionManager(serviceProvider, () => this.isDirty, this.client, this._canReconnect, createChildLogger({ logger: this.subLogger, namespace: "ConnectionManager" }), props));
1203
1205
  // Disable inbound queues as Container is not ready to accept any ops until we are fully loaded!
1204
1206
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
1205
1207
  deltaManager.inbound.pause();
@@ -1269,7 +1271,7 @@ export class Container extends EventEmitterWithErrorHandling {
1269
1271
  if (value === ConnectionState.Connected) {
1270
1272
  durationFromDisconnected =
1271
1273
  time - this.connectionTransitionTimes[ConnectionState.Disconnected];
1272
- durationFromDisconnected = TelemetryLogger.formatTick(durationFromDisconnected);
1274
+ durationFromDisconnected = formatTick(durationFromDisconnected);
1273
1275
  }
1274
1276
  else if (value === ConnectionState.CatchingUp) {
1275
1277
  // This info is of most interesting while Catching Up.
@@ -1288,7 +1290,7 @@ export class Container extends EventEmitterWithErrorHandling {
1288
1290
  connectionInitiationReason, pendingClientId: this.connectionStateHandler.pendingClientId, clientId: this.clientId, autoReconnect,
1289
1291
  opsBehind, online: OnlineStatus[isOnline()], lastVisible: this.lastVisible !== undefined
1290
1292
  ? performance.now() - this.lastVisible
1291
- : undefined, checkpointSequenceNumber, quorumSize: (_a = this._protocolHandler) === null || _a === void 0 ? void 0 : _a.quorum.getMembers().size }, this._deltaManager.connectionProps), error);
1293
+ : undefined, checkpointSequenceNumber, quorumSize: (_a = this._protocolHandler) === null || _a === void 0 ? void 0 : _a.quorum.getMembers().size, isDirty: this.isDirty }, this._deltaManager.connectionProps), error);
1292
1294
  if (value === ConnectionState.Connected) {
1293
1295
  this.firstConnection = false;
1294
1296
  }
@@ -1304,22 +1306,10 @@ export class Container extends EventEmitterWithErrorHandling {
1304
1306
  return;
1305
1307
  }
1306
1308
  const state = this.connectionState === ConnectionState.Connected;
1307
- const logOpsOnReconnect = this.connectionState === ConnectionState.Connected &&
1308
- !this.firstConnection &&
1309
- this.connectionMode === "write";
1310
- if (logOpsOnReconnect) {
1311
- this.messageCountAfterDisconnection = 0;
1312
- }
1313
1309
  // Both protocol and context should not be undefined if we got so far.
1314
1310
  this.setContextConnectedState(state, (_a = this.readOnlyInfo.readonly) !== null && _a !== void 0 ? _a : false);
1315
1311
  this.protocolHandler.setConnectionState(state, this.clientId);
1316
1312
  raiseConnectedEvent(this.mc.logger, this, state, this.clientId, disconnectedReason);
1317
- if (logOpsOnReconnect) {
1318
- this.mc.logger.sendTelemetryEvent({
1319
- eventName: "OpsSentOnReconnect",
1320
- count: this.messageCountAfterDisconnection,
1321
- });
1322
- }
1323
1313
  }
1324
1314
  // back-compat: ADO #1385: Remove in the future, summary op should come through submitSummaryMessage()
1325
1315
  submitContainerMessage(type, contents, batch, metadata) {
@@ -1362,7 +1352,6 @@ export class Container extends EventEmitterWithErrorHandling {
1362
1352
  this.mc.logger.sendErrorEvent({ eventName: "SubmitMessageWithNoConnection", type });
1363
1353
  return -1;
1364
1354
  }
1365
- this.messageCountAfterDisconnection += 1;
1366
1355
  (_a = this.noopHeuristic) === null || _a === void 0 ? void 0 : _a.notifyMessageSent();
1367
1356
  return this._deltaManager.submit(type, contents, batch, metadata, compression, referenceSequenceNumber);
1368
1357
  }
@@ -1371,23 +1360,6 @@ export class Container extends EventEmitterWithErrorHandling {
1371
1360
  this.savedOps.push(message);
1372
1361
  }
1373
1362
  const local = this.clientId === message.clientId;
1374
- // Check and report if we're getting messages from a clientId that we previously
1375
- // flagged should have left, or from a client that's not in the quorum but should be
1376
- if (message.clientId != null) {
1377
- const client = this.protocolHandler.quorum.getMember(message.clientId);
1378
- if (client === undefined && message.type !== MessageType.ClientJoin) {
1379
- // pre-0.58 error message: messageClientIdMissingFromQuorum
1380
- throw new Error("Remote message's clientId is missing from the quorum");
1381
- }
1382
- // Here checking canBeCoalescedByService is used as an approximation of "is benign to process despite being unexpected".
1383
- // It's still not good to see these messages from unexpected clientIds, but since they don't harm the integrity of the
1384
- // document we don't need to blow up aggressively.
1385
- if (this.clientsWhoShouldHaveLeft.has(message.clientId) &&
1386
- !canBeCoalescedByService(message)) {
1387
- // pre-0.58 error message: messageClientIdShouldHaveLeft
1388
- throw new Error("Remote message's clientId already should have left");
1389
- }
1390
- }
1391
1363
  // Allow the protocol handler to process the message
1392
1364
  const result = this.protocolHandler.processMessage(message, local);
1393
1365
  // Forward messages to the loaded runtime for processing
@@ -1454,14 +1426,7 @@ export class Container extends EventEmitterWithErrorHandling {
1454
1426
  }
1455
1427
  return { snapshot, versionId: version === null || version === void 0 ? void 0 : version.id };
1456
1428
  }
1457
- async instantiateContextDetached(existing, snapshot) {
1458
- const codeDetails = this.getCodeDetailsFromQuorum();
1459
- if (codeDetails === undefined) {
1460
- throw new Error("pkg should be provided in create flow!!");
1461
- }
1462
- await this.instantiateContext(existing, codeDetails, snapshot);
1463
- }
1464
- async instantiateContext(existing, codeDetails, snapshot, pendingLocalState) {
1429
+ async instantiateRuntime(codeDetails, snapshot, pendingLocalState) {
1465
1430
  var _a, _b;
1466
1431
  assert(((_a = this._runtime) === null || _a === void 0 ? void 0 : _a.disposed) !== false, 0x0dd /* "Existing runtime not disposed" */);
1467
1432
  // The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
@@ -1485,6 +1450,7 @@ export class Container extends EventEmitterWithErrorHandling {
1485
1450
  var _a;
1486
1451
  return ((_a = this.protocolHandler.quorum.get("code")) !== null && _a !== void 0 ? _a : this.protocolHandler.quorum.get("code2"));
1487
1452
  };
1453
+ const existing = snapshot !== undefined;
1488
1454
  const context = new ContainerContext(this.options, this.scope, snapshot, this._loadedFromVersion, this._deltaManager, this.storageAdapter, this.protocolHandler.quorum, this.protocolHandler.audience, loader, (type, contents, batch, metadata) => this.submitContainerMessage(type, contents, batch, metadata), (summaryOp, referenceSequenceNumber) => this.submitSummaryMessage(summaryOp, referenceSequenceNumber), (batch, referenceSequenceNumber) => this.submitBatch(batch, referenceSequenceNumber), (message) => this.submitSignal(message), (error) => this.dispose(error), (error) => this.close(error), this.updateDirtyContainerState, this.getAbsoluteUrl, () => { var _a; return (_a = this.resolvedUrl) === null || _a === void 0 ? void 0 : _a.id; }, () => this.clientId, () => this._deltaManager.serviceConfiguration, () => this.attachState, () => this.connected, getSpecifiedCodeDetails, this._deltaManager.clientDetails, existing, this.subLogger, pendingLocalState);
1489
1455
  this._lifecycleEvents.once("disposed", () => {
1490
1456
  context.dispose();
@@ -1492,7 +1458,6 @@ export class Container extends EventEmitterWithErrorHandling {
1492
1458
  this._runtime = await PerformanceEvent.timedExecAsync(this.subLogger, { eventName: "InstantiateRuntime" }, async () => runtimeFactory.instantiateRuntime(context, existing));
1493
1459
  this._lifecycleEvents.emit("runtimeInstantiated");
1494
1460
  this._loadedCodeDetails = codeDetails;
1495
- this.emit("contextChanged", codeDetails);
1496
1461
  }
1497
1462
  /**
1498
1463
  * Set the connected state of the ContainerContext