@fluidframework/container-runtime 2.4.0-299374 → 2.4.0

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 (87) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/container-runtime.test-files.tar +0 -0
  3. package/dist/blobManager/blobManager.d.ts.map +1 -1
  4. package/dist/blobManager/blobManager.js +10 -4
  5. package/dist/blobManager/blobManager.js.map +1 -1
  6. package/dist/containerRuntime.d.ts +6 -0
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +44 -69
  9. package/dist/containerRuntime.js.map +1 -1
  10. package/dist/gc/garbageCollection.d.ts +1 -1
  11. package/dist/gc/garbageCollection.d.ts.map +1 -1
  12. package/dist/gc/garbageCollection.js +2 -6
  13. package/dist/gc/garbageCollection.js.map +1 -1
  14. package/dist/opLifecycle/batchManager.d.ts +2 -0
  15. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  16. package/dist/opLifecycle/batchManager.js.map +1 -1
  17. package/dist/opLifecycle/index.d.ts +1 -1
  18. package/dist/opLifecycle/index.d.ts.map +1 -1
  19. package/dist/opLifecycle/index.js +2 -1
  20. package/dist/opLifecycle/index.js.map +1 -1
  21. package/dist/opLifecycle/outbox.d.ts +6 -0
  22. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  23. package/dist/opLifecycle/outbox.js +25 -11
  24. package/dist/opLifecycle/outbox.js.map +1 -1
  25. package/dist/opLifecycle/remoteMessageProcessor.d.ts +4 -4
  26. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  27. package/dist/opLifecycle/remoteMessageProcessor.js +6 -18
  28. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  29. package/dist/packageVersion.d.ts +1 -1
  30. package/dist/packageVersion.d.ts.map +1 -1
  31. package/dist/packageVersion.js +1 -1
  32. package/dist/packageVersion.js.map +1 -1
  33. package/dist/pendingStateManager.d.ts +8 -2
  34. package/dist/pendingStateManager.d.ts.map +1 -1
  35. package/dist/pendingStateManager.js +14 -7
  36. package/dist/pendingStateManager.js.map +1 -1
  37. package/dist/summary/summaryCollection.d.ts.map +1 -1
  38. package/dist/summary/summaryCollection.js +3 -4
  39. package/dist/summary/summaryCollection.js.map +1 -1
  40. package/lib/blobManager/blobManager.d.ts.map +1 -1
  41. package/lib/blobManager/blobManager.js +10 -4
  42. package/lib/blobManager/blobManager.js.map +1 -1
  43. package/lib/containerRuntime.d.ts +6 -0
  44. package/lib/containerRuntime.d.ts.map +1 -1
  45. package/lib/containerRuntime.js +42 -68
  46. package/lib/containerRuntime.js.map +1 -1
  47. package/lib/gc/garbageCollection.d.ts +1 -1
  48. package/lib/gc/garbageCollection.d.ts.map +1 -1
  49. package/lib/gc/garbageCollection.js +3 -7
  50. package/lib/gc/garbageCollection.js.map +1 -1
  51. package/lib/opLifecycle/batchManager.d.ts +2 -0
  52. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  53. package/lib/opLifecycle/batchManager.js.map +1 -1
  54. package/lib/opLifecycle/index.d.ts +1 -1
  55. package/lib/opLifecycle/index.d.ts.map +1 -1
  56. package/lib/opLifecycle/index.js +1 -1
  57. package/lib/opLifecycle/index.js.map +1 -1
  58. package/lib/opLifecycle/outbox.d.ts +6 -0
  59. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  60. package/lib/opLifecycle/outbox.js +23 -10
  61. package/lib/opLifecycle/outbox.js.map +1 -1
  62. package/lib/opLifecycle/remoteMessageProcessor.d.ts +4 -4
  63. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  64. package/lib/opLifecycle/remoteMessageProcessor.js +6 -18
  65. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  66. package/lib/packageVersion.d.ts +1 -1
  67. package/lib/packageVersion.d.ts.map +1 -1
  68. package/lib/packageVersion.js +1 -1
  69. package/lib/packageVersion.js.map +1 -1
  70. package/lib/pendingStateManager.d.ts +8 -2
  71. package/lib/pendingStateManager.d.ts.map +1 -1
  72. package/lib/pendingStateManager.js +14 -7
  73. package/lib/pendingStateManager.js.map +1 -1
  74. package/lib/summary/summaryCollection.d.ts.map +1 -1
  75. package/lib/summary/summaryCollection.js +3 -4
  76. package/lib/summary/summaryCollection.js.map +1 -1
  77. package/package.json +20 -18
  78. package/src/blobManager/blobManager.ts +10 -4
  79. package/src/containerRuntime.ts +67 -85
  80. package/src/gc/garbageCollection.ts +5 -12
  81. package/src/opLifecycle/batchManager.ts +3 -0
  82. package/src/opLifecycle/index.ts +1 -1
  83. package/src/opLifecycle/outbox.ts +32 -10
  84. package/src/opLifecycle/remoteMessageProcessor.ts +8 -22
  85. package/src/packageVersion.ts +1 -1
  86. package/src/pendingStateManager.ts +26 -8
  87. package/src/summary/summaryCollection.ts +3 -4
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ContainerRuntime = exports.loadContainerRuntime = exports.makeLegacySendBatchFn = exports.getDeviceSpec = exports.agentSchedulerId = exports.isUnpackedRuntimeMessage = exports.defaultPendingOpsRetryDelayMs = exports.defaultPendingOpsWaitTimeoutMs = exports.disabledCompressionConfig = exports.CompressionAlgorithms = exports.defaultRuntimeHeaderData = exports.InactiveResponseHeaderKey = exports.TombstoneResponseHeaderKey = exports.DeletedResponseHeaderKey = exports.DefaultSummaryConfiguration = void 0;
7
+ exports.ContainerRuntime = exports.loadContainerRuntime = exports.getSingleUseLegacyLogCallback = exports.makeLegacySendBatchFn = exports.getDeviceSpec = exports.agentSchedulerId = exports.isUnpackedRuntimeMessage = exports.defaultPendingOpsRetryDelayMs = exports.defaultPendingOpsWaitTimeoutMs = exports.disabledCompressionConfig = exports.CompressionAlgorithms = exports.defaultRuntimeHeaderData = exports.InactiveResponseHeaderKey = exports.TombstoneResponseHeaderKey = exports.DeletedResponseHeaderKey = exports.DefaultSummaryConfiguration = void 0;
8
8
  const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const container_definitions_1 = require("@fluidframework/container-definitions");
10
10
  const internal_1 = require("@fluidframework/container-definitions/internal");
@@ -33,16 +33,23 @@ const scheduleManager_js_1 = require("./scheduleManager.js");
33
33
  const index_js_4 = require("./summary/index.js");
34
34
  const throttler_js_1 = require("./throttler.js");
35
35
  /**
36
- * Utility to implement compat behaviors given an unknown message type
36
+ * Creates an error object to be thrown / passed to Container's close fn in case of an unknown message type.
37
37
  * The parameters are typed to support compile-time enforcement of handling all known types/behaviors
38
38
  *
39
- * @param _unknownContainerRuntimeMessageType - Typed as something unexpected, to ensure all known types have been
39
+ * @param unknownContainerRuntimeMessageType - Typed as something unexpected, to ensure all known types have been
40
40
  * handled before calling this function (e.g. in a switch statement).
41
- * @param compatBehavior - Typed redundantly with CompatModeBehavior to ensure handling is added when updating that type
41
+ *
42
+ * @param codePath - The code path where the unexpected message type was encountered.
43
+ *
44
+ * @param sequencedMessage - The sequenced message that contained the unexpected message type.
45
+ *
42
46
  */
43
- function compatBehaviorAllowsMessageType(_unknownContainerRuntimeMessageType, compatBehavior) {
44
- // undefined defaults to same behavior as "FailToProcess"
45
- return compatBehavior === "Ignore";
47
+ function getUnknownMessageTypeError(unknownContainerRuntimeMessageType, codePath, sequencedMessage) {
48
+ return internal_7.DataProcessingError.create("Runtime message of unknown type", codePath, sequencedMessage, {
49
+ messageDetails: {
50
+ type: unknownContainerRuntimeMessageType,
51
+ },
52
+ });
46
53
  }
47
54
  /**
48
55
  * @legacy
@@ -236,9 +243,10 @@ let getSingleUseLegacyLogCallback = (logger, type) => {
236
243
  details: { codePath, type },
237
244
  });
238
245
  // Now that we've logged, prevent future logging (globally).
239
- getSingleUseLegacyLogCallback = () => () => { };
246
+ exports.getSingleUseLegacyLogCallback = () => () => { };
240
247
  };
241
248
  };
249
+ exports.getSingleUseLegacyLogCallback = getSingleUseLegacyLogCallback;
242
250
  /**
243
251
  * This is meant to be used by a {@link @fluidframework/container-definitions#IRuntimeFactory} to instantiate a container runtime.
244
252
  * @param params - An object which specifies all required and optional params necessary to instantiate a runtime.
@@ -1394,22 +1402,9 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1394
1402
  // GC op is only sent in summarizer which should never have stashed ops.
1395
1403
  throw new internal_7.LoggingError("GC op not expected to be stashed in summarizer");
1396
1404
  default: {
1397
- // This should be extremely rare for stashed ops.
1398
- // It would require a newer runtime stashing ops and then an older one applying them,
1399
- // e.g. if an app rolled back its container version
1400
- const compatBehavior = opContents.compatDetails?.behavior;
1401
- if (!compatBehaviorAllowsMessageType(opContents.type, compatBehavior)) {
1402
- const error = internal_7.DataProcessingError.create("Stashed runtime message of unexpected type", "applyStashedOp", undefined /* sequencedMessage */, {
1403
- messageDetails: JSON.stringify({
1404
- type: opContents.type,
1405
- compatBehavior,
1406
- }),
1407
- });
1408
- this.closeFn(error);
1409
- throw error;
1410
- }
1411
- // Note: Even if its compat behavior allows it, we don't know how to apply this stashed op.
1412
- // All we can do is ignore it (similar to on process).
1405
+ const error = getUnknownMessageTypeError(opContents.type, "applyStashedOp" /* codePath */);
1406
+ this.closeFn(error);
1407
+ throw error;
1413
1408
  }
1414
1409
  }
1415
1410
  }
@@ -1529,9 +1524,12 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1529
1524
  // or something different, like a system message.
1530
1525
  const hasModernRuntimeMessageEnvelope = messageCopy.type === internal_3.MessageType.Operation;
1531
1526
  const savedOp = messageCopy.metadata?.savedOp;
1532
- const logLegacyCase = getSingleUseLegacyLogCallback(this.logger, messageCopy.type);
1533
- // We expect runtime messages to have JSON contents - deserialize it in place.
1534
- (0, index_js_3.ensureContentsDeserialized)(messageCopy, hasModernRuntimeMessageEnvelope, logLegacyCase);
1527
+ const logLegacyCase = (0, exports.getSingleUseLegacyLogCallback)(this.logger, messageCopy.type);
1528
+ let runtimeBatch = hasModernRuntimeMessageEnvelope || isUnpackedRuntimeMessage(messageCopy);
1529
+ if (runtimeBatch) {
1530
+ // We expect runtime messages to have JSON contents - deserialize it in place.
1531
+ (0, index_js_3.ensureContentsDeserialized)(messageCopy);
1532
+ }
1535
1533
  if (hasModernRuntimeMessageEnvelope) {
1536
1534
  // If the message has the modern message envelope, then process it here.
1537
1535
  // Here we unpack the message (decompress, unchunk, and/or ungroup) into a batch of messages with ContainerMessageType
@@ -1560,7 +1558,6 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1560
1558
  throw error;
1561
1559
  }
1562
1560
  }
1563
- let runtimeBatch = true;
1564
1561
  // Reach out to PendingStateManager, either to zip localOpMetadata into the *local* message list,
1565
1562
  // or to check to ensure the *remote* messages don't match the batchId of a pending local batch.
1566
1563
  // This latter case would indicate that the container has forked - two copies are trying to persist the same local changes.
@@ -1599,8 +1596,17 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1599
1596
  this.processInboundMessages(messagesWithPendingState, locationInBatch, local, savedOp, runtimeBatch);
1600
1597
  }
1601
1598
  else {
1599
+ if (!runtimeBatch) {
1600
+ // The DeltaManager used to do this, but doesn't anymore as of Loader v2.4
1601
+ // Anyone listening to our "op" event would expect the contents to be parsed per this same logic
1602
+ if (typeof messageCopy.contents === "string" &&
1603
+ messageCopy.contents !== "" &&
1604
+ messageCopy.type !== internal_3.MessageType.ClientLeave) {
1605
+ messageCopy.contents = JSON.parse(messageCopy.contents);
1606
+ }
1607
+ }
1602
1608
  this.processInboundMessages([{ message: messageCopy, localOpMetadata: undefined }], { batchStart: true, batchEnd: true }, // Single message
1603
- local, savedOp, isUnpackedRuntimeMessage(messageCopy) /* runtimeBatch */);
1609
+ local, savedOp, runtimeBatch);
1604
1610
  }
1605
1611
  if (local) {
1606
1612
  // If we have processed a local op, this means that the container is
@@ -1729,23 +1735,9 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1729
1735
  this.documentsSchemaController.processDocumentSchemaOp(message.contents, local, message.sequenceNumber);
1730
1736
  break;
1731
1737
  default: {
1732
- const compatBehavior = message.compatDetails?.behavior;
1733
- if (!compatBehaviorAllowsMessageType(message.type, compatBehavior)) {
1734
- const error = internal_7.DataProcessingError.create(
1735
- // Former assert 0x3ce
1736
- "Runtime message of unknown type", "OpProcessing", message, {
1737
- local,
1738
- messageDetails: JSON.stringify({
1739
- type: message.type,
1740
- contentType: typeof message.contents,
1741
- compatBehavior,
1742
- batch: message.metadata?.batch,
1743
- compression: message.compression,
1744
- }),
1745
- });
1746
- this.closeFn(error);
1747
- throw error;
1748
- }
1738
+ const error = getUnknownMessageTypeError(message.type, "validateAndProcessRuntimeMessage" /* codePath */, message);
1739
+ this.closeFn(error);
1740
+ throw error;
1749
1741
  }
1750
1742
  }
1751
1743
  this.emit("op", message, true /* runtimeMessage */);
@@ -2661,7 +2653,7 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
2661
2653
  contents: idRange,
2662
2654
  };
2663
2655
  const idAllocationBatchMessage = {
2664
- contents: JSON.stringify(idAllocationMessage),
2656
+ contents: (0, index_js_3.serializeOpContents)(idAllocationMessage),
2665
2657
  referenceSequenceNumber: this.deltaManager.lastSequenceNumber,
2666
2658
  };
2667
2659
  this.outbox.submitIdAllocation(idAllocationBatchMessage);
@@ -2704,12 +2696,12 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
2704
2696
  contents: schemaChangeMessage,
2705
2697
  };
2706
2698
  this.outbox.submit({
2707
- contents: JSON.stringify(msg),
2699
+ contents: (0, index_js_3.serializeOpContents)(msg),
2708
2700
  referenceSequenceNumber: this.deltaManager.lastSequenceNumber,
2709
2701
  });
2710
2702
  }
2711
2703
  const message = {
2712
- contents: JSON.stringify(containerRuntimeMessage) /* serialized content */,
2704
+ contents: (0, index_js_3.serializeOpContents)(containerRuntimeMessage),
2713
2705
  metadata,
2714
2706
  localOpMetadata,
2715
2707
  referenceSequenceNumber: this.deltaManager.lastSequenceNumber,
@@ -2853,26 +2845,9 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
2853
2845
  // send any ops, as some other client already changed schema.
2854
2846
  break;
2855
2847
  default: {
2856
- // This case should be very rare - it would imply an op was stashed from a
2857
- // future version of runtime code and now is being applied on an older version.
2858
- const compatBehavior = message.compatDetails?.behavior;
2859
- if (compatBehaviorAllowsMessageType(message.type, compatBehavior)) {
2860
- // We do not ultimately resubmit it, to be consistent with this version of the code.
2861
- this.logger.sendTelemetryEvent({
2862
- eventName: "resubmitUnrecognizedMessageTypeAllowed",
2863
- messageDetails: { type: message.type, compatBehavior },
2864
- });
2865
- }
2866
- else {
2867
- const error = internal_7.DataProcessingError.create("Resubmitting runtime message of unexpected type", "reSubmitCore", undefined /* sequencedMessage */, {
2868
- messageDetails: JSON.stringify({
2869
- type: message.type,
2870
- compatBehavior,
2871
- }),
2872
- });
2873
- this.closeFn(error);
2874
- throw error;
2875
- }
2848
+ const error = getUnknownMessageTypeError(message.type, "reSubmitCore" /* codePath */);
2849
+ this.closeFn(error);
2850
+ throw error;
2876
2851
  }
2877
2852
  }
2878
2853
  }