@fluidframework/container-loader 0.47.0-36699 → 0.48.0-38142

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.
@@ -166,8 +166,7 @@ export declare class DeltaManager extends TypedEventEmitter<IDeltaManagerInterna
166
166
  /**
167
167
  * Sets the sequence number from which inbound messages should be returned
168
168
  */
169
- attachOpHandler(minSequenceNumber: number, sequenceNumber: number, term: number, handler: IDeltaHandlerStrategy): void;
170
- preFetchOps(cacheOnly: boolean): Promise<void>;
169
+ attachOpHandler(minSequenceNumber: number, sequenceNumber: number, term: number, handler: IDeltaHandlerStrategy, prefetchType?: "cached" | "all" | "none"): Promise<void>;
171
170
  private static detailsFromConnection;
172
171
  connect(args: IConnectionArgs): Promise<IConnectionDetails>;
173
172
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"deltaManager.d.ts","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEH,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAuB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtF,OAAO,EAEH,gBAAgB,EAKnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAGhB,yBAAyB,EAEzB,cAAc,EAGd,WAAW,EAEd,MAAM,sCAAsC,CAAC;AAsC9C,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAClB;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W,CAE1B;IAEF;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IA+HpC;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IA2CjC;;;;;;OAMG;YACW,gBAAgB;IA2C9B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,eAAe;IAmIvB,OAAO,CAAC,qBAAqB;IA0F7B;;OAEG;IACF,OAAO,CAAC,kBAAkB;IAM1B;;MAEE;YACW,sBAAsB;IA2DpC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAsCzB,OAAO,CAAC,4BAA4B;CAKvC"}
@@ -138,14 +138,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
138
138
  // check message.content for Back-compat with old service.
139
139
  const reconnectInfo = message.content !== undefined
140
140
  ? getNackReconnectInfo(message.content) :
141
- driver_utils_1.createGenericNetworkError(`Nack: unknown reason`, true);
142
- if (this.reconnectMode !== ReconnectMode.Enabled) {
143
- this.logger.sendErrorEvent({
144
- eventName: "NackWithNoReconnect",
145
- reason: reconnectInfo.message,
146
- mode: this.connectionMode,
147
- });
148
- }
141
+ driver_utils_1.createGenericNetworkError("nack:UnknownReason", true);
149
142
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
150
143
  this.reconnectOnError("write", reconnectInfo);
151
144
  };
@@ -327,17 +320,16 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
327
320
  * about current or last connection (if there is no connection at the moment)
328
321
  */
329
322
  connectionProps() {
323
+ const common = {
324
+ sequenceNumber: this.lastSequenceNumber,
325
+ };
330
326
  if (this.connection !== undefined) {
331
- return {
332
- sequenceNumber: this.lastSequenceNumber,
333
- connectionMode: this.connectionMode,
334
- };
327
+ return Object.assign(Object.assign({}, common), { connectionMode: this.connectionMode });
335
328
  }
336
329
  else {
337
- return {
330
+ return Object.assign(Object.assign({}, common), {
338
331
  // Report how many ops this client sent in last disconnected session
339
- sentOps: this.clientSequenceNumber,
340
- };
332
+ sentOps: this.clientSequenceNumber });
341
333
  }
342
334
  }
343
335
  /**
@@ -424,7 +416,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
424
416
  /**
425
417
  * Sets the sequence number from which inbound messages should be returned
426
418
  */
427
- attachOpHandler(minSequenceNumber, sequenceNumber, term, handler) {
419
+ async attachOpHandler(minSequenceNumber, sequenceNumber, term, handler, prefetchType = "none") {
428
420
  this.initSequenceNumber = sequenceNumber;
429
421
  this.lastProcessedSequenceNumber = sequenceNumber;
430
422
  this.baseTerm = term;
@@ -436,22 +428,31 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
436
428
  this.handler = handler;
437
429
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
438
430
  common_utils_1.assert(!!this.handler, 0x0e3 /* "Newly set op handler is null/undefined!" */);
431
+ // There should be no pending fetch!
432
+ // This API is called right after attachOpHandler by Container.load().
433
+ // We might have connection already and it might have called fetchMissingDeltas() from
434
+ // setupNewSuccessfulConnection. But it should do nothing, because there is no way to fetch ops before
435
+ // we know snapshot sequence number that is set in attachOpHandler. So all such calls should be noop.
436
+ common_utils_1.assert(this.fetchReason === undefined, "There can't be pending fetch that early in boot sequence!");
437
+ if (this.closed) {
438
+ return;
439
+ }
439
440
  this._inbound.resume();
440
441
  this._inboundSignal.resume();
441
- // We could have connected to delta stream before getting here
442
- // If so, it's time to process any accumulated ops, as there might be no other event that
443
- // will force these pending ops to be processed.
444
- // Or request OPs from snapshot / or point zero (if we have no ops at all)
445
- if (this.pending.length > 0) {
446
- this.processPendingOps("DocumentOpen");
447
- }
448
- }
449
- async preFetchOps(cacheOnly) {
450
- // Note that might already got connected to delta stream by now.
451
- // If we did, then we proactively fetch ops at the end of setupNewSuccessfulConnection to ensure
452
- if (this.connection === undefined) {
453
- return this.fetchMissingDeltasCore("DocumentOpen", cacheOnly, this.lastQueuedSequenceNumber, undefined);
442
+ if (prefetchType !== "none") {
443
+ const cacheOnly = prefetchType === "cached";
444
+ await this.fetchMissingDeltasCore("DocumentOpen", cacheOnly, this.lastQueuedSequenceNumber);
445
+ // Keep going with fetching ops from storage once we have all cached ops in.
446
+ // But do not block load and make this request async / not blocking this api.
447
+ // Ops processing will start once cached ops are in and and will stop when queue is empty
448
+ // (which in most cases will happen when we are done processing cached ops)
449
+ if (cacheOnly) {
450
+ // fire and forget
451
+ this.fetchMissingDeltas("DocumentOpen", this.lastQueuedSequenceNumber);
452
+ }
454
453
  }
454
+ // Ensure there is no need to call this.processPendingOps() at the end of boot sequence
455
+ common_utils_1.assert(this.fetchReason !== undefined || this.pending.length === 0, "pending ops are not dropped");
455
456
  }
456
457
  static detailsFromConnection(connection) {
457
458
  return {
@@ -490,6 +491,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
490
491
  }
491
492
  async connectCore(args) {
492
493
  var _a, _b, _c;
494
+ common_utils_1.assert(!this.closed, "not closed");
493
495
  if (this.connection !== undefined) {
494
496
  return this.connection;
495
497
  }
@@ -517,7 +519,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
517
519
  // on the wire, we might be always behind.
518
520
  // See comment at the end of setupNewSuccessfulConnection()
519
521
  telemetry_utils_1.logIfFalse(this.handler !== undefined || !fetchOpsFromStorage, this.logger, "CantFetchWithoutBaseline"); // can't fetch if no baseline
520
- if (fetchOpsFromStorage && this.handler !== undefined) {
522
+ if (fetchOpsFromStorage) {
521
523
  this.fetchMissingDeltas(args.reason, this.lastQueuedSequenceNumber);
522
524
  }
523
525
  const docService = this.serviceProvider();
@@ -1071,7 +1073,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
1071
1073
  const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);
1072
1074
  const message2 = this.comparableMessagePayload(message);
1073
1075
  if (message1 !== message2) {
1074
- const error = new driver_utils_1.NonRetryableError("Two messages with same seq# and different payload!", driver_definitions_1.DriverErrorType.fileOverwrittenInStorage, {
1076
+ const error = new driver_utils_1.NonRetryableError("twoMessagesWithSameSeqNumAndDifferentPayload", driver_definitions_1.DriverErrorType.fileOverwrittenInStorage, {
1075
1077
  clientId: (_c = this.connection) === null || _c === void 0 ? void 0 : _c.clientId,
1076
1078
  sequenceNumber: message.sequenceNumber,
1077
1079
  message1,
@@ -1140,6 +1142,8 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
1140
1142
  throw new container_utils_1.DataCorruptionError("nonSequentialSequenceNumber", Object.assign(Object.assign({}, extractLogSafeMessageProperties(message)), { clientId: (_b = this.connection) === null || _b === void 0 ? void 0 : _b.clientId }));
1141
1143
  }
1142
1144
  this.lastProcessedSequenceNumber = message.sequenceNumber;
1145
+ // a bunch of code assumes that this is true
1146
+ common_utils_1.assert(this.lastProcessedSequenceNumber <= this.lastObservedSeqNumber, 0x267 /* "lastObservedSeqNumber should be updated first" */);
1143
1147
  // Back-compat for older server with no term
1144
1148
  if (message.term === undefined) {
1145
1149
  message.term = 1;
@@ -1150,14 +1154,17 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
1150
1154
  }
1151
1155
  this.handler.process(message);
1152
1156
  const endTime = Date.now();
1157
+ // Should be last, after changing this.lastProcessedSequenceNumber above, as many callers
1158
+ // test this.lastProcessedSequenceNumber instead of using op.sequenceNumber itself.
1153
1159
  this.emit("op", message, endTime - startTime);
1154
1160
  }
1155
1161
  /**
1156
1162
  * Retrieves the missing deltas between the given sequence numbers
1157
1163
  */
1158
1164
  fetchMissingDeltas(reasonArg, lastKnowOp, to) {
1159
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
1160
- this.fetchMissingDeltasCore(reasonArg, false /* cacheOnly */, lastKnowOp, to);
1165
+ this.fetchMissingDeltasCore(reasonArg, false /* cacheOnly */, lastKnowOp, to).catch((error) => {
1166
+ this.logger.sendErrorEvent({ eventName: "fetchMissingDeltasException" }, error);
1167
+ });
1161
1168
  }
1162
1169
  /**
1163
1170
  * Retrieves the missing deltas between the given sequence numbers
@@ -1172,6 +1179,11 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
1172
1179
  this.logger.sendTelemetryEvent({ eventName: "fetchMissingDeltasClosedConnection", reason });
1173
1180
  return;
1174
1181
  }
1182
+ if (this.handler === undefined) {
1183
+ // We do not poses yet any information
1184
+ common_utils_1.assert(lastKnowOp === 0, "initial state");
1185
+ return;
1186
+ }
1175
1187
  try {
1176
1188
  common_utils_1.assert(lastKnowOp === this.lastQueuedSequenceNumber, 0x0f1 /* "from arg" */);
1177
1189
  let from = lastKnowOp + 1;
@@ -1207,12 +1219,37 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
1207
1219
  * Sorts pending ops and attempts to apply them
1208
1220
  */
1209
1221
  processPendingOps(reason) {
1210
- if (this.handler !== undefined) {
1211
- const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);
1212
- this.pending = [];
1213
- // Given that we do not track where these ops came from any more, it's not very
1214
- // actionably to report gaps in this range.
1215
- this.enqueueMessages(pendingSorted, `${reason}_pending`, true /* allowGaps */);
1222
+ if (this.closed) {
1223
+ return;
1224
+ }
1225
+ common_utils_1.assert(this.handler !== undefined, "handler should be installed");
1226
+ const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);
1227
+ this.pending = [];
1228
+ // Given that we do not track where these ops came from any more, it's not very
1229
+ // actionably to report gaps in this range.
1230
+ this.enqueueMessages(pendingSorted, `${reason}_pending`, true /* allowGaps */);
1231
+ // Re-entrancy is ignored by fetchMissingDeltas, execution will come here when it's over
1232
+ if (this.fetchReason === undefined) {
1233
+ // See issue #7312 for more details
1234
+ // We observe cases where client gets into situation where it is not aware of missing ops
1235
+ // (i.e. client being behind), and as such, does not attempt to fetch them.
1236
+ // In some cases client may not have enough signal (example - "read" connection that is silent -
1237
+ // there is no easy way for client to realize it's behind, see a bit of commentary / logic at the
1238
+ // end of setupNewSuccessfulConnection). In other cases it should be able to learn that info ("write"
1239
+ // connection, learn by receiving its own join op), but data suggest it does not happen.
1240
+ // In 50% of these cases we do know we are behind through checkpointSequenceNumber on connection object
1241
+ // and thus can leverage that to trigger recovery. But this is not going to solve all the problems
1242
+ // (the other 50%), and thus these errors below should be looked at even if code below results in
1243
+ // recovery.
1244
+ if (this.lastQueuedSequenceNumber < this.lastObservedSeqNumber) {
1245
+ // connectionMode === "read" case is too noisy, so not log it.
1246
+ // It happens because fetch in setupNewSuccessfulConnection get cancelled due to other fetch, and we
1247
+ // never retry (other than here)
1248
+ if (this.connectionMode === "write") {
1249
+ this.logConnectionIssue({ eventName: "OpsBehind" });
1250
+ }
1251
+ this.fetchMissingDeltas("OpsBehind", this.lastQueuedSequenceNumber);
1252
+ }
1216
1253
  }
1217
1254
  }
1218
1255
  updateLatestKnownOpSeqNumber(seq) {