@fluidframework/container-runtime 2.0.0-internal.5.1.1 → 2.0.0-internal.5.2.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 (138) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/containerRuntime.d.ts +16 -0
  3. package/dist/containerRuntime.d.ts.map +1 -1
  4. package/dist/containerRuntime.js +22 -7
  5. package/dist/containerRuntime.js.map +1 -1
  6. package/dist/dataStoreContext.d.ts +1 -2
  7. package/dist/dataStoreContext.d.ts.map +1 -1
  8. package/dist/dataStoreContext.js.map +1 -1
  9. package/dist/dataStoreContexts.d.ts +2 -1
  10. package/dist/dataStoreContexts.d.ts.map +1 -1
  11. package/dist/dataStoreContexts.js.map +1 -1
  12. package/dist/dataStores.d.ts +2 -1
  13. package/dist/dataStores.d.ts.map +1 -1
  14. package/dist/dataStores.js.map +1 -1
  15. package/dist/gc/gcDefinitions.d.ts +0 -1
  16. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  17. package/dist/gc/gcDefinitions.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/opLifecycle/batchManager.d.ts +2 -1
  22. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  23. package/dist/opLifecycle/batchManager.js +5 -1
  24. package/dist/opLifecycle/batchManager.js.map +1 -1
  25. package/dist/opLifecycle/definitions.d.ts +11 -0
  26. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  27. package/dist/opLifecycle/definitions.js.map +1 -1
  28. package/dist/opLifecycle/index.d.ts +1 -1
  29. package/dist/opLifecycle/index.d.ts.map +1 -1
  30. package/dist/opLifecycle/index.js +2 -1
  31. package/dist/opLifecycle/index.js.map +1 -1
  32. package/dist/opLifecycle/outbox.d.ts +29 -2
  33. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  34. package/dist/opLifecycle/outbox.js +87 -19
  35. package/dist/opLifecycle/outbox.js.map +1 -1
  36. package/dist/packageVersion.d.ts +1 -1
  37. package/dist/packageVersion.js +1 -1
  38. package/dist/packageVersion.js.map +1 -1
  39. package/dist/pendingStateManager.d.ts +8 -3
  40. package/dist/pendingStateManager.d.ts.map +1 -1
  41. package/dist/pendingStateManager.js +23 -16
  42. package/dist/pendingStateManager.js.map +1 -1
  43. package/dist/summary/index.d.ts +1 -1
  44. package/dist/summary/index.d.ts.map +1 -1
  45. package/dist/summary/index.js.map +1 -1
  46. package/dist/summary/runningSummarizer.d.ts +1 -1
  47. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  48. package/dist/summary/runningSummarizer.js.map +1 -1
  49. package/dist/summary/summarizerNode/summarizerNode.js +3 -3
  50. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  51. package/dist/summary/summaryCollection.d.ts +2 -1
  52. package/dist/summary/summaryCollection.d.ts.map +1 -1
  53. package/dist/summary/summaryCollection.js.map +1 -1
  54. package/dist/summary/summaryFormat.d.ts +1 -0
  55. package/dist/summary/summaryFormat.d.ts.map +1 -1
  56. package/dist/summary/summaryFormat.js +2 -1
  57. package/dist/summary/summaryFormat.js.map +1 -1
  58. package/dist/summary/summaryManager.d.ts +2 -1
  59. package/dist/summary/summaryManager.d.ts.map +1 -1
  60. package/dist/summary/summaryManager.js.map +1 -1
  61. package/lib/containerRuntime.d.ts +16 -0
  62. package/lib/containerRuntime.d.ts.map +1 -1
  63. package/lib/containerRuntime.js +24 -9
  64. package/lib/containerRuntime.js.map +1 -1
  65. package/lib/dataStoreContext.d.ts +1 -2
  66. package/lib/dataStoreContext.d.ts.map +1 -1
  67. package/lib/dataStoreContext.js.map +1 -1
  68. package/lib/dataStoreContexts.d.ts +2 -1
  69. package/lib/dataStoreContexts.d.ts.map +1 -1
  70. package/lib/dataStoreContexts.js.map +1 -1
  71. package/lib/dataStores.d.ts +2 -1
  72. package/lib/dataStores.d.ts.map +1 -1
  73. package/lib/dataStores.js.map +1 -1
  74. package/lib/gc/gcDefinitions.d.ts +0 -1
  75. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  76. package/lib/gc/gcDefinitions.js.map +1 -1
  77. package/lib/index.d.ts +1 -1
  78. package/lib/index.d.ts.map +1 -1
  79. package/lib/index.js.map +1 -1
  80. package/lib/opLifecycle/batchManager.d.ts +2 -1
  81. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  82. package/lib/opLifecycle/batchManager.js +5 -1
  83. package/lib/opLifecycle/batchManager.js.map +1 -1
  84. package/lib/opLifecycle/definitions.d.ts +11 -0
  85. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  86. package/lib/opLifecycle/definitions.js.map +1 -1
  87. package/lib/opLifecycle/index.d.ts +1 -1
  88. package/lib/opLifecycle/index.d.ts.map +1 -1
  89. package/lib/opLifecycle/index.js +1 -1
  90. package/lib/opLifecycle/index.js.map +1 -1
  91. package/lib/opLifecycle/outbox.d.ts +29 -2
  92. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  93. package/lib/opLifecycle/outbox.js +85 -18
  94. package/lib/opLifecycle/outbox.js.map +1 -1
  95. package/lib/packageVersion.d.ts +1 -1
  96. package/lib/packageVersion.js +1 -1
  97. package/lib/packageVersion.js.map +1 -1
  98. package/lib/pendingStateManager.d.ts +8 -3
  99. package/lib/pendingStateManager.d.ts.map +1 -1
  100. package/lib/pendingStateManager.js +23 -16
  101. package/lib/pendingStateManager.js.map +1 -1
  102. package/lib/summary/index.d.ts +1 -1
  103. package/lib/summary/index.d.ts.map +1 -1
  104. package/lib/summary/index.js.map +1 -1
  105. package/lib/summary/runningSummarizer.d.ts +1 -1
  106. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  107. package/lib/summary/runningSummarizer.js.map +1 -1
  108. package/lib/summary/summarizerNode/summarizerNode.js +3 -3
  109. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  110. package/lib/summary/summaryCollection.d.ts +2 -1
  111. package/lib/summary/summaryCollection.d.ts.map +1 -1
  112. package/lib/summary/summaryCollection.js.map +1 -1
  113. package/lib/summary/summaryFormat.d.ts +1 -0
  114. package/lib/summary/summaryFormat.d.ts.map +1 -1
  115. package/lib/summary/summaryFormat.js +2 -1
  116. package/lib/summary/summaryFormat.js.map +1 -1
  117. package/lib/summary/summaryManager.d.ts +2 -1
  118. package/lib/summary/summaryManager.d.ts.map +1 -1
  119. package/lib/summary/summaryManager.js.map +1 -1
  120. package/package.json +17 -17
  121. package/src/containerRuntime.ts +45 -11
  122. package/src/dataStoreContext.ts +8 -2
  123. package/src/dataStoreContexts.ts +2 -1
  124. package/src/dataStores.ts +2 -2
  125. package/src/gc/gcDefinitions.ts +0 -1
  126. package/src/index.ts +1 -0
  127. package/src/opLifecycle/batchManager.ts +9 -1
  128. package/src/opLifecycle/definitions.ts +11 -0
  129. package/src/opLifecycle/index.ts +1 -1
  130. package/src/opLifecycle/outbox.ts +107 -16
  131. package/src/packageVersion.ts +1 -1
  132. package/src/pendingStateManager.ts +38 -34
  133. package/src/summary/index.ts +1 -0
  134. package/src/summary/runningSummarizer.ts +1 -1
  135. package/src/summary/summarizerNode/summarizerNode.ts +3 -3
  136. package/src/summary/summaryCollection.ts +2 -1
  137. package/src/summary/summaryFormat.ts +5 -1
  138. package/src/summary/summaryManager.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/opLifecycle/definitions.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IBatchMessage } from \"@fluidframework/container-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { CompressionAlgorithms, ContainerMessageType } from \"..\";\n\n/**\n * Batch message type used internally by the runtime\n */\nexport type BatchMessage = IBatchMessage & {\n\tlocalOpMetadata: unknown;\n\ttype: ContainerMessageType;\n\treferenceSequenceNumber: number;\n\tcompression?: CompressionAlgorithms;\n};\n\n/**\n * Batch interface used internally by the runtime.\n */\nexport interface IBatch {\n\t/**\n\t * Sum of the in-memory content sizes of all messages in the batch.\n\t * If the batch is compressed, this number reflects the post-compression size.\n\t */\n\treadonly contentSizeInBytes: number;\n\t/**\n\t * All the messages in the batch\n\t */\n\treadonly content: BatchMessage[];\n\t/**\n\t * The reference sequence number for the batch\n\t */\n\treadonly referenceSequenceNumber: number | undefined;\n}\n\nexport interface IBatchCheckpoint {\n\trollback: (action: (message: BatchMessage) => void) => void;\n}\n\nexport interface IChunkedOp {\n\tchunkId: number;\n\ttotalChunks: number;\n\tcontents: string;\n\toriginalType: MessageType | ContainerMessageType;\n\toriginalMetadata?: Record<string, unknown>;\n\toriginalCompression?: string;\n}\n\n/**\n * The state of remote message processing:\n * `Processed` - the message can be considered processed\n * `Skipped` - the message was ignored by the processor\n * `Accepted` - the message was processed partially. Eventually, a message\n * will make the processor return `Processed`.\n */\nexport type ProcessingState = \"Processed\" | \"Skipped\" | \"Accepted\";\n\n/**\n * Return type for functions which process remote messages\n */\nexport interface IMessageProcessingResult {\n\t/**\n\t * A shallow copy of the input message if processing happened, or\n\t * the original message otherwise\n\t */\n\treadonly message: ISequencedDocumentMessage;\n\t/**\n\t * Processing result of the input message.\n\t */\n\treadonly state: ProcessingState;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/opLifecycle/definitions.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IBatchMessage } from \"@fluidframework/container-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { CompressionAlgorithms, ContainerMessageType } from \"..\";\n\n/**\n * Batch message type used internally by the runtime\n */\nexport type BatchMessage = IBatchMessage & {\n\tlocalOpMetadata: unknown;\n\ttype: ContainerMessageType;\n\treferenceSequenceNumber: number;\n\tcompression?: CompressionAlgorithms;\n};\n\n/**\n * Batch interface used internally by the runtime.\n */\nexport interface IBatch {\n\t/**\n\t * Sum of the in-memory content sizes of all messages in the batch.\n\t * If the batch is compressed, this number reflects the post-compression size.\n\t */\n\treadonly contentSizeInBytes: number;\n\t/**\n\t * All the messages in the batch\n\t */\n\treadonly content: BatchMessage[];\n\t/**\n\t * The reference sequence number for the batch\n\t */\n\treadonly referenceSequenceNumber: number | undefined;\n\t/**\n\t * Wether or not the batch contains at least one op which was produced as the result\n\t * of processing another op. This means that the batch must be rebased before\n\t * submitted, to ensure that all ops have the same reference sequence numbers and a\n\t * consistent view of the data model. This happens when the op is created within a\n\t * 'changed' event handler of a DDS and will have a different reference sequence number\n\t * than the rest of the ops in the batch, meaning that it has a different view of the\n\t * state of the data model, therefore all ops must be resubmitted and rebased to the current\n\t * reference sequence number to be in agreement about the data model state.\n\t */\n\treadonly hasReentrantOps?: boolean;\n}\n\nexport interface IBatchCheckpoint {\n\trollback: (action: (message: BatchMessage) => void) => void;\n}\n\nexport interface IChunkedOp {\n\tchunkId: number;\n\ttotalChunks: number;\n\tcontents: string;\n\toriginalType: MessageType | ContainerMessageType;\n\toriginalMetadata?: Record<string, unknown>;\n\toriginalCompression?: string;\n}\n\n/**\n * The state of remote message processing:\n * `Processed` - the message can be considered processed\n * `Skipped` - the message was ignored by the processor\n * `Accepted` - the message was processed partially. Eventually, a message\n * will make the processor return `Processed`.\n */\nexport type ProcessingState = \"Processed\" | \"Skipped\" | \"Accepted\";\n\n/**\n * Return type for functions which process remote messages\n */\nexport interface IMessageProcessingResult {\n\t/**\n\t * A shallow copy of the input message if processing happened, or\n\t * the original message otherwise\n\t */\n\treadonly message: ISequencedDocumentMessage;\n\t/**\n\t * Processing result of the input message.\n\t */\n\treadonly state: ProcessingState;\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export { BatchManager, estimateSocketSize, BatchSequenceNumbers } from "./batchManager";
6
6
  export { BatchMessage, IBatch, IBatchCheckpoint, IChunkedOp, IMessageProcessingResult, } from "./definitions";
7
- export { Outbox } from "./outbox";
7
+ export { Outbox, getLongStack } from "./outbox";
8
8
  export { OpCompressor } from "./opCompressor";
9
9
  export { OpDecompressor } from "./opDecompressor";
10
10
  export { OpSplitter, splitOp } from "./opSplitter";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EACN,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,wBAAwB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EACN,YAAY,EACZ,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,wBAAwB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -4,12 +4,13 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.OpGroupingManager = exports.unpackRuntimeMessage = exports.RemoteMessageProcessor = exports.splitOp = exports.OpSplitter = exports.OpDecompressor = exports.OpCompressor = exports.Outbox = exports.estimateSocketSize = exports.BatchManager = void 0;
7
+ exports.OpGroupingManager = exports.unpackRuntimeMessage = exports.RemoteMessageProcessor = exports.splitOp = exports.OpSplitter = exports.OpDecompressor = exports.OpCompressor = exports.getLongStack = exports.Outbox = exports.estimateSocketSize = exports.BatchManager = void 0;
8
8
  var batchManager_1 = require("./batchManager");
9
9
  Object.defineProperty(exports, "BatchManager", { enumerable: true, get: function () { return batchManager_1.BatchManager; } });
10
10
  Object.defineProperty(exports, "estimateSocketSize", { enumerable: true, get: function () { return batchManager_1.estimateSocketSize; } });
11
11
  var outbox_1 = require("./outbox");
12
12
  Object.defineProperty(exports, "Outbox", { enumerable: true, get: function () { return outbox_1.Outbox; } });
13
+ Object.defineProperty(exports, "getLongStack", { enumerable: true, get: function () { return outbox_1.getLongStack; } });
13
14
  var opCompressor_1 = require("./opCompressor");
14
15
  Object.defineProperty(exports, "OpCompressor", { enumerable: true, get: function () { return opCompressor_1.OpCompressor; } });
15
16
  var opDecompressor_1 = require("./opDecompressor");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/opLifecycle/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAwF;AAA/E,4GAAA,YAAY,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAQzC,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAAmD;AAA1C,wGAAA,UAAU,OAAA;AAAE,qGAAA,OAAO,OAAA;AAC5B,mEAAwF;AAA/E,gIAAA,sBAAsB,OAAA;AAAE,8HAAA,oBAAoB,OAAA;AACrD,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { BatchManager, estimateSocketSize, BatchSequenceNumbers } from \"./batchManager\";\nexport {\n\tBatchMessage,\n\tIBatch,\n\tIBatchCheckpoint,\n\tIChunkedOp,\n\tIMessageProcessingResult,\n} from \"./definitions\";\nexport { Outbox } from \"./outbox\";\nexport { OpCompressor } from \"./opCompressor\";\nexport { OpDecompressor } from \"./opDecompressor\";\nexport { OpSplitter, splitOp } from \"./opSplitter\";\nexport { RemoteMessageProcessor, unpackRuntimeMessage } from \"./remoteMessageProcessor\";\nexport { OpGroupingManager } from \"./opGroupingManager\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/opLifecycle/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAwF;AAA/E,4GAAA,YAAY,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAQzC,mCAAgD;AAAvC,gGAAA,MAAM,OAAA;AAAE,sGAAA,YAAY,OAAA;AAC7B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAAmD;AAA1C,wGAAA,UAAU,OAAA;AAAE,qGAAA,OAAO,OAAA;AAC5B,mEAAwF;AAA/E,gIAAA,sBAAsB,OAAA;AAAE,8HAAA,oBAAoB,OAAA;AACrD,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { BatchManager, estimateSocketSize, BatchSequenceNumbers } from \"./batchManager\";\nexport {\n\tBatchMessage,\n\tIBatch,\n\tIBatchCheckpoint,\n\tIChunkedOp,\n\tIMessageProcessingResult,\n} from \"./definitions\";\nexport { Outbox, getLongStack } from \"./outbox\";\nexport { OpCompressor } from \"./opCompressor\";\nexport { OpDecompressor } from \"./opDecompressor\";\nexport { OpSplitter, splitOp } from \"./opSplitter\";\nexport { RemoteMessageProcessor, unpackRuntimeMessage } from \"./remoteMessageProcessor\";\nexport { OpGroupingManager } from \"./opGroupingManager\";\n"]}
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
6
- import { IContainerContext } from "@fluidframework/container-definitions";
6
+ import { IContainerContext, ICriticalContainerError } from "@fluidframework/container-definitions";
7
7
  import { ICompressionRuntimeOptions } from "../containerRuntime";
8
- import { PendingStateManager } from "../pendingStateManager";
8
+ import { IPendingBatchMessage, PendingStateManager } from "../pendingStateManager";
9
9
  import { BatchSequenceNumbers } from "./batchManager";
10
10
  import { BatchMessage } from "./definitions";
11
11
  import { OpCompressor } from "./opCompressor";
@@ -15,6 +15,7 @@ export interface IOutboxConfig {
15
15
  readonly compressionOptions: ICompressionRuntimeOptions;
16
16
  readonly maxBatchSizeInBytes: number;
17
17
  readonly disablePartialFlush: boolean;
18
+ readonly enableBatchRebasing: boolean;
18
19
  }
19
20
  export interface IOutboxParameters {
20
21
  readonly shouldSend: () => boolean;
@@ -26,13 +27,30 @@ export interface IOutboxParameters {
26
27
  readonly logger: ITelemetryLoggerExt;
27
28
  readonly groupingManager: OpGroupingManager;
28
29
  readonly getCurrentSequenceNumbers: () => BatchSequenceNumbers;
30
+ readonly reSubmit: (message: IPendingBatchMessage) => void;
31
+ readonly opReentrancy: () => boolean;
32
+ readonly closeContainer: (error?: ICriticalContainerError) => void;
29
33
  }
34
+ /**
35
+ * Temporarily increase the stack limit while executing the provided action.
36
+ * If a negative value is provided for `length`, no stack frames will be collected.
37
+ * If Infinity is provided, all frames will be collected.
38
+ *
39
+ * ADO:4663 - add this to the common packages.
40
+ *
41
+ * @param action - action which returns an error
42
+ * @param length - number of stack frames to collect, 50 if unspecified.
43
+ * @returns the result of the action provided
44
+ */
45
+ export declare function getLongStack<T>(action: () => T, length?: number): T;
30
46
  export declare class Outbox {
31
47
  private readonly params;
32
48
  private readonly mc;
33
49
  private readonly attachFlowBatch;
34
50
  private readonly mainBatch;
35
51
  private readonly defaultAttachFlowSoftLimitInBytes;
52
+ private batchRebasesToReport;
53
+ private rebasing;
36
54
  /**
37
55
  * Track the number of ops which were detected to have a mismatched
38
56
  * reference sequence number, in order to self-throttle the telemetry events.
@@ -53,7 +71,16 @@ export declare class Outbox {
53
71
  submit(message: BatchMessage): void;
54
72
  submitAttach(message: BatchMessage): void;
55
73
  flush(): void;
74
+ private flushAll;
56
75
  private flushInternal;
76
+ /**
77
+ * Rebases a batch. All the ops in the batch are resubmitted to the runtime and
78
+ * they will end up back in the same batch manager they were flushed from and subsequently flushed.
79
+ *
80
+ * @param rawBatch - the batch to be rebased
81
+ */
82
+ private rebase;
83
+ private isContextReentrant;
57
84
  private compressBatch;
58
85
  /**
59
86
  * Sends the batch object to the container context to be sent over the wire.
@@ -1 +1 @@
1
- {"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/outbox.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EAInB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAEN,oBAAoB,EAGpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAU,MAAM,eAAe,CAAC;AACrD,OA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a;IAqBrB;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IA6Bd,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,aAAa;IAqCrB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAuDjB,OAAO,CAAC,YAAY;IAcb,UAAU;;;;CAMjB"}
@@ -4,29 +4,46 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.Outbox = void 0;
7
+ exports.Outbox = exports.getLongStack = void 0;
8
8
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
9
9
  const common_utils_1 = require("@fluidframework/common-utils");
10
10
  const container_utils_1 = require("@fluidframework/container-utils");
11
11
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
12
12
  const batchManager_1 = require("./batchManager");
13
- function getLongStack(action) {
14
- // Increase the stack trace limit temporarily, so as to debug better in case it occurs.
15
- try {
16
- const originalStackTraceLimit = Error.stackTraceLimit;
17
- Error.stackTraceLimit = 50;
18
- const result = action();
19
- Error.stackTraceLimit = originalStackTraceLimit;
20
- return result;
13
+ /**
14
+ * Temporarily increase the stack limit while executing the provided action.
15
+ * If a negative value is provided for `length`, no stack frames will be collected.
16
+ * If Infinity is provided, all frames will be collected.
17
+ *
18
+ * ADO:4663 - add this to the common packages.
19
+ *
20
+ * @param action - action which returns an error
21
+ * @param length - number of stack frames to collect, 50 if unspecified.
22
+ * @returns the result of the action provided
23
+ */
24
+ function getLongStack(action, length = 50) {
25
+ const errorObj = Error;
26
+ if ((Object.getOwnPropertyDescriptor(errorObj, "stackTraceLimit") ||
27
+ Object.getOwnPropertyDescriptor(Object.getPrototypeOf(errorObj), "stackTraceLimit") ||
28
+ {}).writable !== true) {
29
+ return action();
21
30
  }
22
- catch (error) {
31
+ const originalStackTraceLimit = errorObj.stackTraceLimit;
32
+ try {
33
+ errorObj.stackTraceLimit = length;
23
34
  return action();
24
35
  }
36
+ finally {
37
+ errorObj.stackTraceLimit = originalStackTraceLimit;
38
+ }
25
39
  }
40
+ exports.getLongStack = getLongStack;
26
41
  class Outbox {
27
42
  constructor(params) {
28
43
  this.params = params;
29
44
  this.defaultAttachFlowSoftLimitInBytes = 320 * 1024;
45
+ this.batchRebasesToReport = 5;
46
+ this.rebasing = false;
30
47
  /**
31
48
  * Track the number of ops which were detected to have a mismatched
32
49
  * reference sequence number, in order to self-throttle the telemetry events.
@@ -77,13 +94,13 @@ class Outbox {
77
94
  }, getLongStack(() => new container_utils_1.UsageError("Submission of an out of order message")));
78
95
  }
79
96
  if (!this.params.config.disablePartialFlush) {
80
- this.flush();
97
+ this.flushAll();
81
98
  }
82
99
  }
83
100
  submit(message) {
84
101
  var _a, _b;
85
102
  this.maybeFlushPartialBatch();
86
- if (!this.mainBatch.push(message, this.params.getCurrentSequenceNumbers().clientSequenceNumber)) {
103
+ if (!this.mainBatch.push(message, this.isContextReentrant(), this.params.getCurrentSequenceNumbers().clientSequenceNumber)) {
87
104
  throw new container_utils_1.GenericError("BatchTooLarge", /* error */ undefined, {
88
105
  opSize: (_b = (_a = message.contents) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
89
106
  batchSize: this.mainBatch.contentSizeInBytes,
@@ -95,12 +112,12 @@ class Outbox {
95
112
  submitAttach(message) {
96
113
  var _a, _b;
97
114
  this.maybeFlushPartialBatch();
98
- if (!this.attachFlowBatch.push(message, this.params.getCurrentSequenceNumbers().clientSequenceNumber)) {
115
+ if (!this.attachFlowBatch.push(message, this.isContextReentrant(), this.params.getCurrentSequenceNumbers().clientSequenceNumber)) {
99
116
  // BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged
100
117
  // when queue is not empty.
101
118
  // Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit
102
- this.flushInternal(this.attachFlowBatch.popBatch());
103
- if (!this.attachFlowBatch.push(message, this.params.getCurrentSequenceNumbers().clientSequenceNumber)) {
119
+ this.flushInternal(this.attachFlowBatch);
120
+ if (!this.attachFlowBatch.push(message, this.isContextReentrant(), this.params.getCurrentSequenceNumbers().clientSequenceNumber)) {
104
121
  throw new container_utils_1.GenericError("BatchTooLarge", /* error */ undefined, {
105
122
  opSize: (_b = (_a = message.contents) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
106
123
  batchSize: this.attachFlowBatch.contentSizeInBytes,
@@ -116,18 +133,69 @@ class Outbox {
116
133
  // after they reach a size which would benefit from compression.
117
134
  if (this.attachFlowBatch.contentSizeInBytes >=
118
135
  this.params.config.compressionOptions.minimumBatchSizeInBytes) {
119
- this.flushInternal(this.attachFlowBatch.popBatch());
136
+ this.flushInternal(this.attachFlowBatch);
120
137
  }
121
138
  }
122
139
  flush() {
123
- this.flushInternal(this.attachFlowBatch.popBatch());
124
- this.flushInternal(this.mainBatch.popBatch());
140
+ if (this.isContextReentrant()) {
141
+ const error = new container_utils_1.UsageError("Flushing is not supported inside DDS event handlers");
142
+ this.params.closeContainer(error);
143
+ throw error;
144
+ }
145
+ this.flushAll();
146
+ }
147
+ flushAll() {
148
+ this.flushInternal(this.attachFlowBatch);
149
+ this.flushInternal(this.mainBatch);
125
150
  }
126
- flushInternal(rawBatch) {
151
+ flushInternal(batchManager) {
152
+ if (batchManager.empty) {
153
+ return;
154
+ }
155
+ const rawBatch = batchManager.popBatch();
156
+ if (rawBatch.hasReentrantOps === true && this.params.config.enableBatchRebasing) {
157
+ (0, common_utils_1.assert)(!this.rebasing, 0x6fa /* A rebased batch should never have reentrant ops */);
158
+ // If a batch contains reentrant ops (ops created as a result from processing another op)
159
+ // it needs to be rebased so that we can ensure consistent reference sequence numbers
160
+ // and eventual consistency at the DDS level.
161
+ this.rebase(rawBatch, batchManager);
162
+ return;
163
+ }
127
164
  const processedBatch = this.compressBatch(rawBatch);
128
165
  this.sendBatch(processedBatch);
129
166
  this.persistBatch(rawBatch.content);
130
167
  }
168
+ /**
169
+ * Rebases a batch. All the ops in the batch are resubmitted to the runtime and
170
+ * they will end up back in the same batch manager they were flushed from and subsequently flushed.
171
+ *
172
+ * @param rawBatch - the batch to be rebased
173
+ */
174
+ rebase(rawBatch, batchManager) {
175
+ (0, common_utils_1.assert)(!this.rebasing, 0x6fb /* Reentrancy */);
176
+ this.rebasing = true;
177
+ for (const message of rawBatch.content) {
178
+ this.params.reSubmit({
179
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
180
+ content: message.contents,
181
+ localOpMetadata: message.localOpMetadata,
182
+ opMetadata: message.metadata,
183
+ });
184
+ }
185
+ if (this.batchRebasesToReport > 0) {
186
+ this.mc.logger.sendTelemetryEvent({
187
+ eventName: "BatchRebase",
188
+ length: rawBatch.content.length,
189
+ referenceSequenceNumber: rawBatch.referenceSequenceNumber,
190
+ }, new container_utils_1.UsageError("BatchRebase"));
191
+ this.batchRebasesToReport--;
192
+ }
193
+ this.flushInternal(batchManager);
194
+ this.rebasing = false;
195
+ }
196
+ isContextReentrant() {
197
+ return this.params.opReentrancy() && !this.rebasing;
198
+ }
131
199
  compressBatch(batch) {
132
200
  if (batch.content.length === 0 ||
133
201
  this.params.config.compressionOptions === undefined ||
@@ -1 +1 @@
1
- {"version":3,"file":"outbox.js","sourceRoot":"","sources":["../../src/opLifecycle/outbox.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAKyC;AACzC,+DAAsD;AAEtD,qEAA2E;AAC3E,+EAAmE;AAGnE,iDAKwB;AAyBxB,SAAS,YAAY,CAAC,MAAmB;IACxC,uFAAuF;IACvF,IAAI;QACH,MAAM,uBAAuB,GAAI,KAAa,CAAC,eAAe,CAAC;QAC9D,KAAa,CAAC,eAAe,GAAG,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACvB,KAAa,CAAC,eAAe,GAAG,uBAAuB,CAAC;QACzD,OAAO,MAAM,CAAC;KACd;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,MAAM,EAAE,CAAC;KAChB;AACF,CAAC;AAED,MAAa,MAAM;IAelB,Y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AC7B,CAAC;SACF;IACF,CAAC;IAEO,YAAY,CAAC,KAAqB;QACzC,iEAAiE;QACjE,4DAA4D;QAC5D,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,eAAe;YAC9C,oEAAoE;YACpE,OAAO,CAAC,QAAS,EACjB,OAAO,CAAC,uBAAuB,EAC/B,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,QAAQ,CAChB,CAAC;SACF;IACF,CAAC;IAEM,UAAU;QAChB,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;YACtC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;SAClD,CAAC;IACH,CAAC;CACD;AA1QD,wBA0QC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tChildLogger,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IContainerContext } from \"@fluidframework/container-definitions\";\nimport { GenericError, UsageError } from \"@fluidframework/container-utils\";\nimport { MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ICompressionRuntimeOptions } from \"../containerRuntime\";\nimport { PendingStateManager } from \"../pendingStateManager\";\nimport {\n\tBatchManager,\n\tBatchSequenceNumbers,\n\testimateSocketSize,\n\tsequenceNumbersMatch,\n} from \"./batchManager\";\nimport { BatchMessage, IBatch } from \"./definitions\";\nimport { OpCompressor } from \"./opCompressor\";\nimport { OpGroupingManager } from \"./opGroupingManager\";\nimport { OpSplitter } from \"./opSplitter\";\n\nexport interface IOutboxConfig {\n\treadonly compressionOptions: ICompressionRuntimeOptions;\n\t// The maximum size of a batch that we can send over the wire.\n\treadonly maxBatchSizeInBytes: number;\n\treadonly disablePartialFlush: boolean;\n}\n\nexport interface IOutboxParameters {\n\treadonly shouldSend: () => boolean;\n\treadonly pendingStateManager: PendingStateManager;\n\treadonly containerContext: IContainerContext;\n\treadonly config: IOutboxConfig;\n\treadonly compressor: OpCompressor;\n\treadonly splitter: OpSplitter;\n\treadonly logger: ITelemetryLoggerExt;\n\treadonly groupingManager: OpGroupingManager;\n\treadonly getCurrentSequenceNumbers: () => BatchSequenceNumbers;\n}\n\nfunction getLongStack(action: () => Error): Error {\n\t// Increase the stack trace limit temporarily, so as to debug better in case it occurs.\n\ttry {\n\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\t(Error as any).stackTraceLimit = 50;\n\t\tconst result = action();\n\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\treturn result;\n\t} catch (error) {\n\t\treturn action();\n\t}\n}\n\nexport class Outbox {\n\tprivate readonly mc: MonitoringContext;\n\tprivate readonly attachFlowBatch: BatchManager;\n\tprivate readonly mainBatch: BatchManager;\n\tprivate readonly defaultAttachFlowSoftLimitInBytes = 320 * 1024;\n\n\t/**\n\t * Track the number of ops which were detected to have a mismatched\n\t * reference sequence number, in order to self-throttle the telemetry events.\n\t *\n\t * This should be removed as part of ADO:2322\n\t */\n\tprivate readonly maxMismatchedOpsToReport = 3;\n\tprivate mismatchedOpsReported = 0;\n\n\tconstructor(private readonly params: IOutboxParameters) {\n\t\tthis.mc = loggerToMonitoringContext(ChildLogger.create(params.logger, \"Outbox\"));\n\t\tconst isCompressionEnabled =\n\t\t\tthis.params.config.compressionOptions.minimumBatchSizeInBytes !==\n\t\t\tNumber.POSITIVE_INFINITY;\n\t\t// We need to allow infinite size batches if we enable compression\n\t\tconst hardLimit = isCompressionEnabled ? Infinity : this.params.config.maxBatchSizeInBytes;\n\t\tconst softLimit = isCompressionEnabled ? Infinity : this.defaultAttachFlowSoftLimitInBytes;\n\n\t\tthis.attachFlowBatch = new BatchManager({ hardLimit, softLimit });\n\t\tthis.mainBatch = new BatchManager({ hardLimit });\n\t}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.attachFlowBatch.length === 0 && this.mainBatch.length === 0;\n\t}\n\n\t/**\n\t * If we detect that the reference sequence number of the incoming message does not match\n\t * what was already in the batch managers, this means that batching has been interrupted so\n\t * we will flush the accumulated messages to account for that and create a new batch with the new\n\t * message as the first message.\n\t */\n\tprivate maybeFlushPartialBatch() {\n\t\tconst mainBatchSeqNums = this.mainBatch.sequenceNumbers;\n\t\tconst attachFlowBatchSeqNums = this.attachFlowBatch.sequenceNumbers;\n\t\tassert(\n\t\t\tthis.params.config.disablePartialFlush ||\n\t\t\t\tsequenceNumbersMatch(mainBatchSeqNums, attachFlowBatchSeqNums),\n\t\t\t0x58d /* Reference sequence numbers from both batches must be in sync */,\n\t\t);\n\n\t\tconst currentSequenceNumbers = this.params.getCurrentSequenceNumbers();\n\n\t\tif (\n\t\t\tsequenceNumbersMatch(mainBatchSeqNums, currentSequenceNumbers) &&\n\t\t\tsequenceNumbersMatch(attachFlowBatchSeqNums, currentSequenceNumbers)\n\t\t) {\n\t\t\t// The reference sequence numbers are stable, there is nothing to do\n\t\t\treturn;\n\t\t}\n\n\t\tif (++this.mismatchedOpsReported <= this.maxMismatchedOpsToReport) {\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\tcategory: this.params.config.disablePartialFlush ? \"error\" : \"generic\",\n\t\t\t\t\teventName: \"ReferenceSequenceNumberMismatch\",\n\t\t\t\t\tmainReferenceSequenceNumber: mainBatchSeqNums.referenceSequenceNumber,\n\t\t\t\t\tmainClientSequenceNumber: mainBatchSeqNums.clientSequenceNumber,\n\t\t\t\t\tattachReferenceSequenceNumber: attachFlowBatchSeqNums.referenceSequenceNumber,\n\t\t\t\t\tattachClientSequenceNumber: attachFlowBatchSeqNums.clientSequenceNumber,\n\t\t\t\t\tcurrentReferenceSequenceNumber: currentSequenceNumbers.referenceSequenceNumber,\n\t\t\t\t\tcurrentClientSequenceNumber: currentSequenceNumbers.clientSequenceNumber,\n\t\t\t\t},\n\t\t\t\tgetLongStack(() => new UsageError(\"Submission of an out of order message\")),\n\t\t\t);\n\t\t}\n\n\t\tif (!this.params.config.disablePartialFlush) {\n\t\t\tthis.flush();\n\t\t}\n\t}\n\n\tpublic submit(message: BatchMessage) {\n\t\tthis.maybeFlushPartialBatch();\n\n\t\tif (\n\t\t\t!this.mainBatch.push(\n\t\t\t\tmessage,\n\t\t\t\tthis.params.getCurrentSequenceNumbers().clientSequenceNumber,\n\t\t\t)\n\t\t) {\n\t\t\tthrow new GenericError(\"BatchTooLarge\", /* error */ undefined, {\n\t\t\t\topSize: message.contents?.length ?? 0,\n\t\t\t\tbatchSize: this.mainBatch.contentSizeInBytes,\n\t\t\t\tcount: this.mainBatch.length,\n\t\t\t\tlimit: this.mainBatch.options.hardLimit,\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic submitAttach(message: BatchMessage) {\n\t\tthis.maybeFlushPartialBatch();\n\n\t\tif (\n\t\t\t!this.attachFlowBatch.push(\n\t\t\t\tmessage,\n\t\t\t\tthis.params.getCurrentSequenceNumbers().clientSequenceNumber,\n\t\t\t)\n\t\t) {\n\t\t\t// BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged\n\t\t\t// when queue is not empty.\n\t\t\t// Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit\n\t\t\tthis.flushInternal(this.attachFlowBatch.popBatch());\n\t\t\tif (\n\t\t\t\t!this.attachFlowBatch.push(\n\t\t\t\t\tmessage,\n\t\t\t\t\tthis.params.getCurrentSequenceNumbers().clientSequenceNumber,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new GenericError(\"BatchTooLarge\", /* error */ undefined, {\n\t\t\t\t\topSize: message.contents?.length ?? 0,\n\t\t\t\t\tbatchSize: this.attachFlowBatch.contentSizeInBytes,\n\t\t\t\t\tcount: this.attachFlowBatch.length,\n\t\t\t\t\tlimit: this.attachFlowBatch.options.hardLimit,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// If compression is enabled, we will always successfully receive\n\t\t// attach ops and compress then send them at the next JS turn, regardless\n\t\t// of the overall size of the accumulated ops in the batch.\n\t\t// However, it is more efficient to flush these ops faster, preferably\n\t\t// after they reach a size which would benefit from compression.\n\t\tif (\n\t\t\tthis.attachFlowBatch.contentSizeInBytes >=\n\t\t\tthis.params.config.compressionOptions.minimumBatchSizeInBytes\n\t\t) {\n\t\t\tthis.flushInternal(this.attachFlowBatch.popBatch());\n\t\t}\n\t}\n\n\tpublic flush() {\n\t\tthis.flushInternal(this.attachFlowBatch.popBatch());\n\t\tthis.flushInternal(this.mainBatch.popBatch());\n\t}\n\n\tprivate flushInternal(rawBatch: IBatch) {\n\t\tconst processedBatch = this.compressBatch(rawBatch);\n\t\tthis.sendBatch(processedBatch);\n\n\t\tthis.persistBatch(rawBatch.content);\n\t}\n\n\tprivate compressBatch(batch: IBatch): IBatch {\n\t\tif (\n\t\t\tbatch.content.length === 0 ||\n\t\t\tthis.params.config.compressionOptions === undefined ||\n\t\t\tthis.params.config.compressionOptions.minimumBatchSizeInBytes >\n\t\t\t\tbatch.contentSizeInBytes ||\n\t\t\tthis.params.containerContext.submitBatchFn === undefined\n\t\t) {\n\t\t\t// Nothing to do if the batch is empty or if compression is disabled or not supported, or if we don't need to compress\n\t\t\treturn this.params.groupingManager.groupBatch(batch);\n\t\t}\n\n\t\tconst compressedBatch = this.params.compressor.compressBatch(\n\t\t\tthis.params.groupingManager.groupBatch(batch),\n\t\t);\n\n\t\tif (this.params.splitter.isBatchChunkingEnabled) {\n\t\t\treturn compressedBatch.contentSizeInBytes <= this.params.splitter.chunkSizeInBytes\n\t\t\t\t? compressedBatch\n\t\t\t\t: this.params.splitter.splitFirstBatchMessage(compressedBatch);\n\t\t}\n\n\t\tif (compressedBatch.contentSizeInBytes >= this.params.config.maxBatchSizeInBytes) {\n\t\t\tthrow new GenericError(\"BatchTooLarge\", /* error */ undefined, {\n\t\t\t\tbatchSize: batch.contentSizeInBytes,\n\t\t\t\tcompressedBatchSize: compressedBatch.contentSizeInBytes,\n\t\t\t\tcount: compressedBatch.content.length,\n\t\t\t\tlimit: this.params.config.maxBatchSizeInBytes,\n\t\t\t\tchunkingEnabled: this.params.splitter.isBatchChunkingEnabled,\n\t\t\t\tcompressionOptions: JSON.stringify(this.params.config.compressionOptions),\n\t\t\t\tsocketSize: estimateSocketSize(batch),\n\t\t\t});\n\t\t}\n\n\t\treturn compressedBatch;\n\t}\n\n\t/**\n\t * Sends the batch object to the container context to be sent over the wire.\n\t *\n\t * @param batch - batch to be sent\n\t */\n\tprivate sendBatch(batch: IBatch) {\n\t\tconst length = batch.content.length;\n\n\t\t// Did we disconnect in the middle of turn-based batch?\n\t\t// If so, do nothing, as pending state manager will resubmit it correctly on reconnect.\n\t\tif (length === 0 || !this.params.shouldSend()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst socketSize = estimateSocketSize(batch);\n\t\tif (socketSize >= this.params.config.maxBatchSizeInBytes) {\n\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"LargeBatch\",\n\t\t\t\tlength: batch.content.length,\n\t\t\t\tsizeInBytes: batch.contentSizeInBytes,\n\t\t\t\tsocketSize,\n\t\t\t});\n\t\t}\n\n\t\tif (this.params.containerContext.submitBatchFn === undefined) {\n\t\t\t// Legacy path - supporting old loader versions. Can be removed only when LTS moves above\n\t\t\t// version that has support for batches (submitBatchFn)\n\t\t\tassert(\n\t\t\t\tbatch.content[0].compression === undefined,\n\t\t\t\t0x5a6 /* Compression should not have happened if the loader does not support it */,\n\t\t\t);\n\n\t\t\tfor (const message of batch.content) {\n\t\t\t\tthis.params.containerContext.submitFn(\n\t\t\t\t\tMessageType.Operation,\n\t\t\t\t\t// For back-compat (submitFn only works on deserialized content)\n\t\t\t\t\tmessage.contents === undefined ? undefined : JSON.parse(message.contents),\n\t\t\t\t\ttrue, // batch\n\t\t\t\t\tmessage.metadata,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.params.containerContext.deltaManager.flush();\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tbatch.referenceSequenceNumber !== undefined,\n\t\t\t\t0x58e /* Batch must not be empty */,\n\t\t\t);\n\t\t\tthis.params.containerContext.submitBatchFn(\n\t\t\t\tbatch.content.map((message) => ({\n\t\t\t\t\tcontents: message.contents,\n\t\t\t\t\tmetadata: message.metadata,\n\t\t\t\t\tcompression: message.compression,\n\t\t\t\t\treferenceSequenceNumber: message.referenceSequenceNumber,\n\t\t\t\t})),\n\t\t\t\tbatch.referenceSequenceNumber,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate persistBatch(batch: BatchMessage[]) {\n\t\t// Let the PendingStateManager know that a message was submitted.\n\t\t// In future, need to shift toward keeping batch as a whole!\n\t\tfor (const message of batch) {\n\t\t\tthis.params.pendingStateManager.onSubmitMessage(\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tmessage.contents!,\n\t\t\t\tmessage.referenceSequenceNumber,\n\t\t\t\tmessage.localOpMetadata,\n\t\t\t\tmessage.metadata,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic checkpoint() {\n\t\treturn {\n\t\t\tmainBatch: this.mainBatch.checkpoint(),\n\t\t\tattachFlowBatch: this.attachFlowBatch.checkpoint(),\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"outbox.js","sourceRoot":"","sources":["../../src/opLifecycle/outbox.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAKyC;AACzC,+DAAsD;AAEtD,qEAA2E;AAC3E,+EAAmE;AAGnE,iDAKwB;AA6BxB;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAAI,MAAe,EAAE,SAAiB,EAAE;IACnE,MAAM,QAAQ,GAAG,KAAY,CAAC;IAC9B,IACC,CACC,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,CAAC;QAC5D,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ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AE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;YACtC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;SAClD,CAAC;IACH,CAAC;CACD;AA9UD,wBA8UC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tChildLogger,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IContainerContext, ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { GenericError, UsageError } from \"@fluidframework/container-utils\";\nimport { MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ICompressionRuntimeOptions } from \"../containerRuntime\";\nimport { IPendingBatchMessage, PendingStateManager } from \"../pendingStateManager\";\nimport {\n\tBatchManager,\n\tBatchSequenceNumbers,\n\testimateSocketSize,\n\tsequenceNumbersMatch,\n} from \"./batchManager\";\nimport { BatchMessage, IBatch } from \"./definitions\";\nimport { OpCompressor } from \"./opCompressor\";\nimport { OpGroupingManager } from \"./opGroupingManager\";\nimport { OpSplitter } from \"./opSplitter\";\n\nexport interface IOutboxConfig {\n\treadonly compressionOptions: ICompressionRuntimeOptions;\n\t// The maximum size of a batch that we can send over the wire.\n\treadonly maxBatchSizeInBytes: number;\n\treadonly disablePartialFlush: boolean;\n\treadonly enableBatchRebasing: boolean;\n}\n\nexport interface IOutboxParameters {\n\treadonly shouldSend: () => boolean;\n\treadonly pendingStateManager: PendingStateManager;\n\treadonly containerContext: IContainerContext;\n\treadonly config: IOutboxConfig;\n\treadonly compressor: OpCompressor;\n\treadonly splitter: OpSplitter;\n\treadonly logger: ITelemetryLoggerExt;\n\treadonly groupingManager: OpGroupingManager;\n\treadonly getCurrentSequenceNumbers: () => BatchSequenceNumbers;\n\treadonly reSubmit: (message: IPendingBatchMessage) => void;\n\treadonly opReentrancy: () => boolean;\n\treadonly closeContainer: (error?: ICriticalContainerError) => void;\n}\n\n/**\n * Temporarily increase the stack limit while executing the provided action.\n * If a negative value is provided for `length`, no stack frames will be collected.\n * If Infinity is provided, all frames will be collected.\n *\n * ADO:4663 - add this to the common packages.\n *\n * @param action - action which returns an error\n * @param length - number of stack frames to collect, 50 if unspecified.\n * @returns the result of the action provided\n */\nexport function getLongStack<T>(action: () => T, length: number = 50): T {\n\tconst errorObj = Error as any;\n\tif (\n\t\t(\n\t\t\tObject.getOwnPropertyDescriptor(errorObj, \"stackTraceLimit\") ||\n\t\t\tObject.getOwnPropertyDescriptor(Object.getPrototypeOf(errorObj), \"stackTraceLimit\") ||\n\t\t\t{}\n\t\t).writable !== true\n\t) {\n\t\treturn action();\n\t}\n\n\tconst originalStackTraceLimit = errorObj.stackTraceLimit;\n\ttry {\n\t\terrorObj.stackTraceLimit = length;\n\t\treturn action();\n\t} finally {\n\t\terrorObj.stackTraceLimit = originalStackTraceLimit;\n\t}\n}\n\nexport class Outbox {\n\tprivate readonly mc: MonitoringContext;\n\tprivate readonly attachFlowBatch: BatchManager;\n\tprivate readonly mainBatch: BatchManager;\n\tprivate readonly defaultAttachFlowSoftLimitInBytes = 320 * 1024;\n\tprivate batchRebasesToReport = 5;\n\tprivate rebasing = false;\n\n\t/**\n\t * Track the number of ops which were detected to have a mismatched\n\t * reference sequence number, in order to self-throttle the telemetry events.\n\t *\n\t * This should be removed as part of ADO:2322\n\t */\n\tprivate readonly maxMismatchedOpsToReport = 3;\n\tprivate mismatchedOpsReported = 0;\n\n\tconstructor(private readonly params: IOutboxParameters) {\n\t\tthis.mc = loggerToMonitoringContext(ChildLogger.create(params.logger, \"Outbox\"));\n\t\tconst isCompressionEnabled =\n\t\t\tthis.params.config.compressionOptions.minimumBatchSizeInBytes !==\n\t\t\tNumber.POSITIVE_INFINITY;\n\t\t// We need to allow infinite size batches if we enable compression\n\t\tconst hardLimit = isCompressionEnabled ? Infinity : this.params.config.maxBatchSizeInBytes;\n\t\tconst softLimit = isCompressionEnabled ? Infinity : this.defaultAttachFlowSoftLimitInBytes;\n\n\t\tthis.attachFlowBatch = new BatchManager({ hardLimit, softLimit });\n\t\tthis.mainBatch = new BatchManager({ hardLimit });\n\t}\n\n\tpublic get isEmpty(): boolean {\n\t\treturn this.attachFlowBatch.length === 0 && this.mainBatch.length === 0;\n\t}\n\n\t/**\n\t * If we detect that the reference sequence number of the incoming message does not match\n\t * what was already in the batch managers, this means that batching has been interrupted so\n\t * we will flush the accumulated messages to account for that and create a new batch with the new\n\t * message as the first message.\n\t */\n\tprivate maybeFlushPartialBatch() {\n\t\tconst mainBatchSeqNums = this.mainBatch.sequenceNumbers;\n\t\tconst attachFlowBatchSeqNums = this.attachFlowBatch.sequenceNumbers;\n\t\tassert(\n\t\t\tthis.params.config.disablePartialFlush ||\n\t\t\t\tsequenceNumbersMatch(mainBatchSeqNums, attachFlowBatchSeqNums),\n\t\t\t0x58d /* Reference sequence numbers from both batches must be in sync */,\n\t\t);\n\n\t\tconst currentSequenceNumbers = this.params.getCurrentSequenceNumbers();\n\n\t\tif (\n\t\t\tsequenceNumbersMatch(mainBatchSeqNums, currentSequenceNumbers) &&\n\t\t\tsequenceNumbersMatch(attachFlowBatchSeqNums, currentSequenceNumbers)\n\t\t) {\n\t\t\t// The reference sequence numbers are stable, there is nothing to do\n\t\t\treturn;\n\t\t}\n\n\t\tif (++this.mismatchedOpsReported <= this.maxMismatchedOpsToReport) {\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\tcategory: this.params.config.disablePartialFlush ? \"error\" : \"generic\",\n\t\t\t\t\teventName: \"ReferenceSequenceNumberMismatch\",\n\t\t\t\t\tmainReferenceSequenceNumber: mainBatchSeqNums.referenceSequenceNumber,\n\t\t\t\t\tmainClientSequenceNumber: mainBatchSeqNums.clientSequenceNumber,\n\t\t\t\t\tattachReferenceSequenceNumber: attachFlowBatchSeqNums.referenceSequenceNumber,\n\t\t\t\t\tattachClientSequenceNumber: attachFlowBatchSeqNums.clientSequenceNumber,\n\t\t\t\t\tcurrentReferenceSequenceNumber: currentSequenceNumbers.referenceSequenceNumber,\n\t\t\t\t\tcurrentClientSequenceNumber: currentSequenceNumbers.clientSequenceNumber,\n\t\t\t\t},\n\t\t\t\tgetLongStack(() => new UsageError(\"Submission of an out of order message\")),\n\t\t\t);\n\t\t}\n\n\t\tif (!this.params.config.disablePartialFlush) {\n\t\t\tthis.flushAll();\n\t\t}\n\t}\n\n\tpublic submit(message: BatchMessage) {\n\t\tthis.maybeFlushPartialBatch();\n\n\t\tif (\n\t\t\t!this.mainBatch.push(\n\t\t\t\tmessage,\n\t\t\t\tthis.isContextReentrant(),\n\t\t\t\tthis.params.getCurrentSequenceNumbers().clientSequenceNumber,\n\t\t\t)\n\t\t) {\n\t\t\tthrow new GenericError(\"BatchTooLarge\", /* error */ undefined, {\n\t\t\t\topSize: message.contents?.length ?? 0,\n\t\t\t\tbatchSize: this.mainBatch.contentSizeInBytes,\n\t\t\t\tcount: this.mainBatch.length,\n\t\t\t\tlimit: this.mainBatch.options.hardLimit,\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic submitAttach(message: BatchMessage) {\n\t\tthis.maybeFlushPartialBatch();\n\n\t\tif (\n\t\t\t!this.attachFlowBatch.push(\n\t\t\t\tmessage,\n\t\t\t\tthis.isContextReentrant(),\n\t\t\t\tthis.params.getCurrentSequenceNumbers().clientSequenceNumber,\n\t\t\t)\n\t\t) {\n\t\t\t// BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged\n\t\t\t// when queue is not empty.\n\t\t\t// Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit\n\t\t\tthis.flushInternal(this.attachFlowBatch);\n\t\t\tif (\n\t\t\t\t!this.attachFlowBatch.push(\n\t\t\t\t\tmessage,\n\t\t\t\t\tthis.isContextReentrant(),\n\t\t\t\t\tthis.params.getCurrentSequenceNumbers().clientSequenceNumber,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new GenericError(\"BatchTooLarge\", /* error */ undefined, {\n\t\t\t\t\topSize: message.contents?.length ?? 0,\n\t\t\t\t\tbatchSize: this.attachFlowBatch.contentSizeInBytes,\n\t\t\t\t\tcount: this.attachFlowBatch.length,\n\t\t\t\t\tlimit: this.attachFlowBatch.options.hardLimit,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// If compression is enabled, we will always successfully receive\n\t\t// attach ops and compress then send them at the next JS turn, regardless\n\t\t// of the overall size of the accumulated ops in the batch.\n\t\t// However, it is more efficient to flush these ops faster, preferably\n\t\t// after they reach a size which would benefit from compression.\n\t\tif (\n\t\t\tthis.attachFlowBatch.contentSizeInBytes >=\n\t\t\tthis.params.config.compressionOptions.minimumBatchSizeInBytes\n\t\t) {\n\t\t\tthis.flushInternal(this.attachFlowBatch);\n\t\t}\n\t}\n\n\tpublic flush() {\n\t\tif (this.isContextReentrant()) {\n\t\t\tconst error = new UsageError(\"Flushing is not supported inside DDS event handlers\");\n\t\t\tthis.params.closeContainer(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.flushAll();\n\t}\n\n\tprivate flushAll() {\n\t\tthis.flushInternal(this.attachFlowBatch);\n\t\tthis.flushInternal(this.mainBatch);\n\t}\n\n\tprivate flushInternal(batchManager: BatchManager) {\n\t\tif (batchManager.empty) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst rawBatch = batchManager.popBatch();\n\t\tif (rawBatch.hasReentrantOps === true && this.params.config.enableBatchRebasing) {\n\t\t\tassert(!this.rebasing, 0x6fa /* A rebased batch should never have reentrant ops */);\n\t\t\t// If a batch contains reentrant ops (ops created as a result from processing another op)\n\t\t\t// it needs to be rebased so that we can ensure consistent reference sequence numbers\n\t\t\t// and eventual consistency at the DDS level.\n\t\t\tthis.rebase(rawBatch, batchManager);\n\t\t\treturn;\n\t\t}\n\n\t\tconst processedBatch = this.compressBatch(rawBatch);\n\t\tthis.sendBatch(processedBatch);\n\n\t\tthis.persistBatch(rawBatch.content);\n\t}\n\n\t/**\n\t * Rebases a batch. All the ops in the batch are resubmitted to the runtime and\n\t * they will end up back in the same batch manager they were flushed from and subsequently flushed.\n\t *\n\t * @param rawBatch - the batch to be rebased\n\t */\n\tprivate rebase(rawBatch: IBatch, batchManager: BatchManager) {\n\t\tassert(!this.rebasing, 0x6fb /* Reentrancy */);\n\n\t\tthis.rebasing = true;\n\t\tfor (const message of rawBatch.content) {\n\t\t\tthis.params.reSubmit({\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tcontent: message.contents!,\n\t\t\t\tlocalOpMetadata: message.localOpMetadata,\n\t\t\t\topMetadata: message.metadata,\n\t\t\t});\n\t\t}\n\n\t\tif (this.batchRebasesToReport > 0) {\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"BatchRebase\",\n\t\t\t\t\tlength: rawBatch.content.length,\n\t\t\t\t\treferenceSequenceNumber: rawBatch.referenceSequenceNumber,\n\t\t\t\t},\n\t\t\t\tnew UsageError(\"BatchRebase\"),\n\t\t\t);\n\t\t\tthis.batchRebasesToReport--;\n\t\t}\n\n\t\tthis.flushInternal(batchManager);\n\t\tthis.rebasing = false;\n\t}\n\n\tprivate isContextReentrant(): boolean {\n\t\treturn this.params.opReentrancy() && !this.rebasing;\n\t}\n\n\tprivate compressBatch(batch: IBatch): IBatch {\n\t\tif (\n\t\t\tbatch.content.length === 0 ||\n\t\t\tthis.params.config.compressionOptions === undefined ||\n\t\t\tthis.params.config.compressionOptions.minimumBatchSizeInBytes >\n\t\t\t\tbatch.contentSizeInBytes ||\n\t\t\tthis.params.containerContext.submitBatchFn === undefined\n\t\t) {\n\t\t\t// Nothing to do if the batch is empty or if compression is disabled or not supported, or if we don't need to compress\n\t\t\treturn this.params.groupingManager.groupBatch(batch);\n\t\t}\n\n\t\tconst compressedBatch = this.params.compressor.compressBatch(\n\t\t\tthis.params.groupingManager.groupBatch(batch),\n\t\t);\n\n\t\tif (this.params.splitter.isBatchChunkingEnabled) {\n\t\t\treturn compressedBatch.contentSizeInBytes <= this.params.splitter.chunkSizeInBytes\n\t\t\t\t? compressedBatch\n\t\t\t\t: this.params.splitter.splitFirstBatchMessage(compressedBatch);\n\t\t}\n\n\t\tif (compressedBatch.contentSizeInBytes >= this.params.config.maxBatchSizeInBytes) {\n\t\t\tthrow new GenericError(\"BatchTooLarge\", /* error */ undefined, {\n\t\t\t\tbatchSize: batch.contentSizeInBytes,\n\t\t\t\tcompressedBatchSize: compressedBatch.contentSizeInBytes,\n\t\t\t\tcount: compressedBatch.content.length,\n\t\t\t\tlimit: this.params.config.maxBatchSizeInBytes,\n\t\t\t\tchunkingEnabled: this.params.splitter.isBatchChunkingEnabled,\n\t\t\t\tcompressionOptions: JSON.stringify(this.params.config.compressionOptions),\n\t\t\t\tsocketSize: estimateSocketSize(batch),\n\t\t\t});\n\t\t}\n\n\t\treturn compressedBatch;\n\t}\n\n\t/**\n\t * Sends the batch object to the container context to be sent over the wire.\n\t *\n\t * @param batch - batch to be sent\n\t */\n\tprivate sendBatch(batch: IBatch) {\n\t\tconst length = batch.content.length;\n\n\t\t// Did we disconnect in the middle of turn-based batch?\n\t\t// If so, do nothing, as pending state manager will resubmit it correctly on reconnect.\n\t\tif (length === 0 || !this.params.shouldSend()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst socketSize = estimateSocketSize(batch);\n\t\tif (socketSize >= this.params.config.maxBatchSizeInBytes) {\n\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"LargeBatch\",\n\t\t\t\tlength: batch.content.length,\n\t\t\t\tsizeInBytes: batch.contentSizeInBytes,\n\t\t\t\tsocketSize,\n\t\t\t});\n\t\t}\n\n\t\tif (this.params.containerContext.submitBatchFn === undefined) {\n\t\t\t// Legacy path - supporting old loader versions. Can be removed only when LTS moves above\n\t\t\t// version that has support for batches (submitBatchFn)\n\t\t\tassert(\n\t\t\t\tbatch.content[0].compression === undefined,\n\t\t\t\t0x5a6 /* Compression should not have happened if the loader does not support it */,\n\t\t\t);\n\n\t\t\tfor (const message of batch.content) {\n\t\t\t\tthis.params.containerContext.submitFn(\n\t\t\t\t\tMessageType.Operation,\n\t\t\t\t\t// For back-compat (submitFn only works on deserialized content)\n\t\t\t\t\tmessage.contents === undefined ? undefined : JSON.parse(message.contents),\n\t\t\t\t\ttrue, // batch\n\t\t\t\t\tmessage.metadata,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.params.containerContext.deltaManager.flush();\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tbatch.referenceSequenceNumber !== undefined,\n\t\t\t\t0x58e /* Batch must not be empty */,\n\t\t\t);\n\t\t\tthis.params.containerContext.submitBatchFn(\n\t\t\t\tbatch.content.map((message) => ({\n\t\t\t\t\tcontents: message.contents,\n\t\t\t\t\tmetadata: message.metadata,\n\t\t\t\t\tcompression: message.compression,\n\t\t\t\t\treferenceSequenceNumber: message.referenceSequenceNumber,\n\t\t\t\t})),\n\t\t\t\tbatch.referenceSequenceNumber,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate persistBatch(batch: BatchMessage[]) {\n\t\t// Let the PendingStateManager know that a message was submitted.\n\t\t// In future, need to shift toward keeping batch as a whole!\n\t\tfor (const message of batch) {\n\t\t\tthis.params.pendingStateManager.onSubmitMessage(\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tmessage.contents!,\n\t\t\t\tmessage.referenceSequenceNumber,\n\t\t\t\tmessage.localOpMetadata,\n\t\t\t\tmessage.metadata,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic checkpoint() {\n\t\treturn {\n\t\t\tmainBatch: this.mainBatch.checkpoint(),\n\t\t\tattachFlowBatch: this.attachFlowBatch.checkpoint(),\n\t\t};\n\t}\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-runtime";
8
- export declare const pkgVersion = "2.0.0-internal.5.1.1";
8
+ export declare const pkgVersion = "2.0.0-internal.5.2.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/container-runtime";
11
- exports.pkgVersion = "2.0.0-internal.5.1.1";
11
+ exports.pkgVersion = "2.0.0-internal.5.2.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-internal.5.1.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-internal.5.2.0\";\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDisposable } from "@fluidframework/common-definitions";
5
+ import { IDisposable } from "@fluidframework/core-interfaces";
6
6
  import { ICriticalContainerError } from "@fluidframework/container-definitions";
7
7
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import { ContainerMessageType } from "./containerRuntime";
@@ -40,13 +40,18 @@ export interface IPendingLocalState {
40
40
  */
41
41
  pendingStates: IPendingState[];
42
42
  }
43
+ export interface IPendingBatchMessage {
44
+ content: string;
45
+ localOpMetadata: unknown;
46
+ opMetadata: Record<string, unknown> | undefined;
47
+ }
43
48
  export interface IRuntimeStateHandler {
44
49
  connected(): boolean;
45
50
  clientId(): string | undefined;
46
51
  close(error?: ICriticalContainerError): void;
47
52
  applyStashedOp(content: string): Promise<unknown>;
48
- reSubmit(content: string | undefined, localOpMetadata: unknown, opMetadata: Record<string, unknown> | undefined): void;
49
- orderSequentially(callback: () => void): void;
53
+ reSubmit(message: IPendingBatchMessage): void;
54
+ reSubmitBatch(batch: IPendingBatchMessage[]): void;
50
55
  }
51
56
  /**
52
57
  * PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been
@@ -1 +1 @@
1
- {"version":3,"file":"pendingStateManager.d.ts","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,oBAAoB,CAAC;IAClC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,OAAO,EAAE,GAAG,CAAC;IACb,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,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AO,CAAC,QAAQ,CAAC,WAAW,CAGzB;IAEH,IAAW,oBAAoB,IAAI,MAAM,CAExC;IAGD,OAAO,CAAC,iBAAiB,CAAkB;IAI3C,OAAO,CAAC,wBAAwB,CAAwC;IAExE,OAAO,CAAC,QAAQ,CAAqB;IAErC;;;OAGG;IACI,kBAAkB,IAAI,OAAO;IAI7B,aAAa,IAAI,kBAAkB,GAAG,SAAS;gBA6BpC,YAAY,EAAE,oBAAoB,EACnD,iBAAiB,EAAE,kBAAkB,GAAG,SAAS;IA4BlD,IAAW,QAAQ,YAElB;IACD,SAAgB,OAAO,aAAgC;IAEvD;;;;;;OAMG;IACI,eAAe,CACrB,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,MAAM,EAC/B,eAAe,EAAE,OAAO,EACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAchD;;;OAGG;IACU,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM;IAwB9C;;;;OAIG;IACI,0BAA0B,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO;IAkC9E;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAkD5B;;;OAGG;IACI,mBAAmB;CAgF1B"}
@@ -213,7 +213,7 @@ class PendingStateManager {
213
213
  * states in its queue. This includes triggering resubmission of unacked ops.
214
214
  */
215
215
  replayPendingStates() {
216
- var _a, _b;
216
+ var _a, _b, _c, _d;
217
217
  (0, common_utils_1.assert)(this.stateHandler.connected(), 0x172 /* "The connection state is not consistent with the runtime" */);
218
218
  // This assert suggests we are about to send same ops twice, which will result in data loss.
219
219
  (0, common_utils_1.assert)(this.clientId !== this.stateHandler.clientId(), 0x173 /* "replayPendingStates called twice for same clientId!" */);
@@ -238,24 +238,31 @@ class PendingStateManager {
238
238
  */
239
239
  if ((_b = pendingMessage.opMetadata) === null || _b === void 0 ? void 0 : _b.batch) {
240
240
  (0, common_utils_1.assert)(pendingMessagesCount > 0, 0x554 /* Last pending message cannot be a batch begin */);
241
- this.stateHandler.orderSequentially(() => {
242
- var _a, _b;
243
- while (pendingMessagesCount >= 0) {
244
- // check is >= because batch end may be last pending message
245
- this.stateHandler.reSubmit(pendingMessage.content, pendingMessage.localOpMetadata, pendingMessage.opMetadata);
246
- if (((_a = pendingMessage.opMetadata) === null || _a === void 0 ? void 0 : _a.batch) === false) {
247
- break;
248
- }
249
- (0, common_utils_1.assert)(pendingMessagesCount > 0, 0x555 /* No batch end found */);
250
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
251
- pendingMessage = this.pendingMessages.shift();
252
- pendingMessagesCount--;
253
- (0, common_utils_1.assert)(((_b = pendingMessage.opMetadata) === null || _b === void 0 ? void 0 : _b.batch) !== true, 0x556 /* Batch start needs a corresponding batch end */);
241
+ const batch = [];
242
+ // check is >= because batch end may be last pending message
243
+ while (pendingMessagesCount >= 0) {
244
+ batch.push({
245
+ content: pendingMessage.content,
246
+ localOpMetadata: pendingMessage.localOpMetadata,
247
+ opMetadata: pendingMessage.opMetadata,
248
+ });
249
+ if (((_c = pendingMessage.opMetadata) === null || _c === void 0 ? void 0 : _c.batch) === false) {
250
+ break;
254
251
  }
255
- });
252
+ (0, common_utils_1.assert)(pendingMessagesCount > 0, 0x555 /* No batch end found */);
253
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
254
+ pendingMessage = this.pendingMessages.shift();
255
+ pendingMessagesCount--;
256
+ (0, common_utils_1.assert)(((_d = pendingMessage.opMetadata) === null || _d === void 0 ? void 0 : _d.batch) !== true, 0x556 /* Batch start needs a corresponding batch end */);
257
+ }
258
+ this.stateHandler.reSubmitBatch(batch);
256
259
  }
257
260
  else {
258
- this.stateHandler.reSubmit(pendingMessage.content, pendingMessage.localOpMetadata, pendingMessage.opMetadata);
261
+ this.stateHandler.reSubmit({
262
+ content: pendingMessage.content,
263
+ localOpMetadata: pendingMessage.localOpMetadata,
264
+ opMetadata: pendingMessage.opMetadata,
265
+ });
259
266
  }
260
267
  }
261
268
  }