@fluidframework/container-runtime 2.0.0-internal.6.3.2 → 2.0.0-internal.6.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.
- package/CHANGELOG.md +8 -0
- package/dist/blobManager.d.ts +3 -2
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +29 -25
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +14 -69
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +155 -184
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +3 -1
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +1 -1
- package/dist/dataStores.js +3 -3
- package/dist/dataStores.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts +6 -3
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +13 -12
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.js +1 -1
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +17 -6
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +19 -20
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts +0 -9
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +1 -13
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +1 -4
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/gc/index.d.ts +2 -2
- package/dist/gc/index.d.ts.map +1 -1
- package/dist/gc/index.js +5 -6
- package/dist/gc/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/messageTypes.d.ts +134 -0
- package/dist/messageTypes.d.ts.map +1 -0
- package/dist/messageTypes.js +29 -0
- package/dist/messageTypes.js.map +1 -0
- package/dist/opLifecycle/definitions.d.ts +2 -1
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +0 -4
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +4 -2
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/opSplitter.js +3 -3
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts +17 -3
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +38 -25
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +2 -2
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +13 -6
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/summary/runningSummarizer.d.ts +1 -1
- package/dist/summary/runningSummarizer.d.ts.map +1 -1
- package/dist/summary/runningSummarizer.js +4 -2
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summarizer.d.ts +2 -2
- package/dist/summary/summarizer.js +2 -2
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.d.ts +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +2 -1
- package/dist/summary/summarizerTypes.d.ts.map +1 -1
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +3 -0
- package/dist/summary/summaryFormat.d.ts.map +1 -1
- package/dist/summary/summaryFormat.js +3 -0
- package/dist/summary/summaryFormat.js.map +1 -1
- package/lib/blobManager.d.ts +3 -2
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +30 -26
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +14 -69
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +121 -150
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +3 -1
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +1 -1
- package/lib/dataStores.js +4 -4
- package/lib/dataStores.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts +6 -3
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +13 -12
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.js +2 -2
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +17 -6
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +18 -19
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts +0 -9
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +0 -11
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +1 -4
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/gc/index.d.ts +2 -2
- package/lib/gc/index.d.ts.map +1 -1
- package/lib/gc/index.js +2 -2
- package/lib/gc/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/messageTypes.d.ts +134 -0
- package/lib/messageTypes.d.ts.map +1 -0
- package/lib/messageTypes.js +26 -0
- package/lib/messageTypes.js.map +1 -0
- package/lib/opLifecycle/definitions.d.ts +2 -1
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +0 -4
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +4 -2
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/opSplitter.js +1 -1
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts +17 -3
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +37 -24
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +2 -2
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +12 -5
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/summary/runningSummarizer.d.ts +1 -1
- package/lib/summary/runningSummarizer.d.ts.map +1 -1
- package/lib/summary/runningSummarizer.js +4 -2
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summarizer.d.ts +2 -2
- package/lib/summary/summarizer.js +2 -2
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.d.ts +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +2 -1
- package/lib/summary/summarizerTypes.d.ts.map +1 -1
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +3 -0
- package/lib/summary/summaryFormat.d.ts.map +1 -1
- package/lib/summary/summaryFormat.js +3 -0
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +16 -16
- package/src/blobManager.ts +38 -28
- package/src/containerRuntime.ts +181 -245
- package/src/dataStoreContext.ts +3 -1
- package/src/dataStores.ts +4 -4
- package/src/gc/garbageCollection.md +53 -5
- package/src/gc/garbageCollection.ts +13 -12
- package/src/gc/gcConfigs.ts +3 -3
- package/src/gc/gcDefinitions.ts +18 -19
- package/src/gc/gcEarlyAdoption.md +145 -0
- package/src/gc/gcHelpers.ts +0 -12
- package/src/gc/gcTelemetry.ts +1 -4
- package/src/gc/index.ts +4 -5
- package/src/index.ts +7 -4
- package/src/messageTypes.ts +225 -0
- package/src/opLifecycle/README.md +40 -40
- package/src/opLifecycle/definitions.ts +2 -1
- package/src/opLifecycle/opDecompressor.ts +0 -8
- package/src/opLifecycle/opGroupingManager.ts +7 -6
- package/src/opLifecycle/opSplitter.ts +2 -2
- package/src/opLifecycle/remoteMessageProcessor.ts +54 -33
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +23 -6
- package/src/summary/runningSummarizer.ts +4 -2
- package/src/summary/summarizer.ts +2 -2
- package/src/summary/summarizerNode/summarizerNode.ts +1 -1
- package/src/summary/summarizerTypes.ts +2 -1
- package/src/summary/summaryFormat.ts +3 -0
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.unpackRuntimeMessage = exports.RemoteMessageProcessor = void 0;
|
|
8
8
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
9
|
-
const
|
|
9
|
+
const messageTypes_1 = require("../messageTypes");
|
|
10
|
+
/**
|
|
11
|
+
* Stateful class for processing incoming remote messages as the virtualization measures are unwrapped,
|
|
12
|
+
* potentially across numerous inbound ops.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
10
16
|
class RemoteMessageProcessor {
|
|
11
17
|
constructor(opSplitter, opDecompressor, opGroupingManager) {
|
|
12
18
|
this.opSplitter = opSplitter;
|
|
@@ -21,13 +27,21 @@ class RemoteMessageProcessor {
|
|
|
21
27
|
}
|
|
22
28
|
/**
|
|
23
29
|
* Ungroups and Unchunks the runtime ops encapsulated by the single remoteMessage received over the wire
|
|
24
|
-
* @param
|
|
25
|
-
*
|
|
30
|
+
* @param remoteMessageCopy - A shallow copy of a message from another client, possibly virtualized
|
|
31
|
+
* (grouped, compressed, and/or chunked).
|
|
32
|
+
* Being a shallow copy, it's considered mutable, meaning no other Container or other parallel procedure
|
|
33
|
+
* depends on this object instance.
|
|
34
|
+
* Note remoteMessageCopy.contents (and other object props) MUST not be modified,
|
|
35
|
+
* but may be overwritten (as is the case with contents).
|
|
36
|
+
* @returns the unchunked, decompressed, ungrouped, unpacked SequencedContainerRuntimeMessages encapsulated in the remote message.
|
|
37
|
+
* For ops that weren't virtualized (e.g. System ops that the ContainerRuntime will ultimately ignore),
|
|
38
|
+
* a singleton array [remoteMessageCopy] is returned
|
|
26
39
|
*/
|
|
27
|
-
process(
|
|
40
|
+
process(remoteMessageCopy) {
|
|
28
41
|
const result = [];
|
|
42
|
+
ensureContentsDeserialized(remoteMessageCopy);
|
|
29
43
|
// Ungroup before and after decompression for back-compat (cleanup tracked by AB#4371)
|
|
30
|
-
for (const ungroupedMessage of this.opGroupingManager.ungroupOp(
|
|
44
|
+
for (const ungroupedMessage of this.opGroupingManager.ungroupOp(remoteMessageCopy)) {
|
|
31
45
|
const message = this.opDecompressor.processMessage(ungroupedMessage).message;
|
|
32
46
|
for (let ungroupedMessage2 of this.opGroupingManager.ungroupOp(message)) {
|
|
33
47
|
// unpack and unchunk the ungrouped message in place
|
|
@@ -61,34 +75,33 @@ class RemoteMessageProcessor {
|
|
|
61
75
|
}
|
|
62
76
|
}
|
|
63
77
|
exports.RemoteMessageProcessor = RemoteMessageProcessor;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// There might be multiple container instances receiving same message
|
|
67
|
-
// We do not need to make deep copy, as each layer will just replace message.content itself,
|
|
68
|
-
// but would not modify contents details
|
|
69
|
-
const message = { ...remoteMessage };
|
|
78
|
+
/** Takes an incoming message and if the contents is a string, JSON.parse's it in place */
|
|
79
|
+
function ensureContentsDeserialized(mutableMessage) {
|
|
70
80
|
// back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!
|
|
71
81
|
// System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.
|
|
72
82
|
// Old ops may contain empty string (I assume noops).
|
|
73
|
-
if (typeof
|
|
74
|
-
|
|
83
|
+
if (typeof mutableMessage.contents === "string" && mutableMessage.contents !== "") {
|
|
84
|
+
mutableMessage.contents = JSON.parse(mutableMessage.contents);
|
|
75
85
|
}
|
|
76
|
-
|
|
77
|
-
};
|
|
86
|
+
}
|
|
78
87
|
/**
|
|
79
|
-
* For a given message, it moves the nested
|
|
88
|
+
* For a given message, it moves the nested InboundContainerRuntimeMessage props one level up.
|
|
80
89
|
*
|
|
81
90
|
* The return type illustrates the assumption that the message param
|
|
82
|
-
* becomes a
|
|
83
|
-
* (but there is no runtime validation of the 'type' or 'compatDetails' values)
|
|
91
|
+
* becomes a InboundSequencedContainerRuntimeMessage by the time the function returns
|
|
92
|
+
* (but there is no runtime validation of the 'type' or 'compatDetails' values).
|
|
84
93
|
*/
|
|
85
94
|
function unpack(message) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
// We assume the contents is an InboundContainerRuntimeMessage (the message is "packed")
|
|
96
|
+
const contents = message.contents;
|
|
97
|
+
// We're going to unpack message in-place (promoting those properties of contents up to message itself)
|
|
98
|
+
const messageUnpacked = message;
|
|
99
|
+
messageUnpacked.type = contents.type;
|
|
100
|
+
messageUnpacked.contents = contents.contents;
|
|
101
|
+
if ("compatDetails" in contents) {
|
|
102
|
+
messageUnpacked.compatDetails =
|
|
103
|
+
contents.compatDetails;
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
106
|
/**
|
|
94
107
|
* Unpacks runtime messages.
|
|
@@ -111,7 +124,7 @@ function unpackRuntimeMessage(message) {
|
|
|
111
124
|
// TODO: Unsure if this is a real format we should be concerned with. There doesn't appear to be anything prepared to handle the address member.
|
|
112
125
|
if (message.contents.address !== undefined &&
|
|
113
126
|
message.contents.type === undefined) {
|
|
114
|
-
message.type =
|
|
127
|
+
message.type = messageTypes_1.ContainerMessageType.FluidDataStoreOp;
|
|
115
128
|
}
|
|
116
129
|
else {
|
|
117
130
|
// new format
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteMessageProcessor.js","sourceRoot":"","sources":["../../src/opLifecycle/remoteMessageProcessor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAA8F;AAC9F,0DAI6B;AAK7B,MAAa,sBAAsB;IAClC,YACkB,UAAsB,EACtB,cAA8B,EAC9B,iBAAoC;QAFpC,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACnD,CAAC;IAEJ,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC/B,CAAC;IAEM,uBAAuB,CAAC,QAAgB;QAC9C,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,aAAwC;QACtD,MAAM,MAAM,GAAgC,EAAE,CAAC;QAE/C,sFAAsF;QACtF,KAAK,MAAM,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE;YACrF,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;YA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CAAC;IAErC,iGAAiG;IACjG,+GAA+G;IAC/G,qDAAqD;IACrD,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,KAAK,EAAE,EAAE;QACpE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;KAChD;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,MAAM,CACd,OAAkC;IAElC,MAAM,aAAa,GAAG,OAAO,CAAC,QAAmC,CAAC;IAElE,+EAA+E;IAC/E,MAAM,gCAAgC,GAAG,OAA2C,CAAC;IACrF,gCAAgC,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;IAC3D,gCAAgC,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;IACnE,gCAAgC,CAAC,aAAa,GAAG,aAAa,CAAC,aAAa,CAAC;AAC9E,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAAC,OAAkC;IACtE,IAAI,OAAO,CAAC,IAAI,KAAK,kCAAW,CAAC,SAAS,EAAE;QAC3C,8CAA8C;QAC9C,sDAAsD;QACtD,+BAA+B;QAC/B,8BAA8B;QAC9B,OAAO,KAAK,CAAC;KACb;IAED,oBAAoB;IACpB,gJAAgJ;IAChJ,IACE,OAAO,CAAC,QAAkC,CAAC,OAAO,KAAK,SAAS;QAChE,OAAO,CAAC,QAA+B,CAAC,IAAI,KAAK,SAAS,EAC1D;QACD,OAAO,CAAC,IAAI,GAAG,uCAAoB,CAAC,gBAAgB,CAAC;KACrD;SAAM;QACN,aAAa;QACb,MAAM,CAAC,OAAO,CAAC,CAAC;KAChB;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAtBD,oDAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tContainerMessageType,\n\tContainerRuntimeMessage,\n\tSequencedContainerRuntimeMessage,\n} from \"../containerRuntime\";\nimport { OpDecompressor } from \"./opDecompressor\";\nimport { OpGroupingManager } from \"./opGroupingManager\";\nimport { OpSplitter } from \"./opSplitter\";\n\nexport class RemoteMessageProcessor {\n\tconstructor(\n\t\tprivate readonly opSplitter: OpSplitter,\n\t\tprivate readonly opDecompressor: OpDecompressor,\n\t\tprivate readonly opGroupingManager: OpGroupingManager,\n\t) {}\n\n\tpublic get partialMessages(): ReadonlyMap<string, string[]> {\n\t\treturn this.opSplitter.chunks;\n\t}\n\n\tpublic clearPartialMessagesFor(clientId: string) {\n\t\tthis.opSplitter.clearPartialChunks(clientId);\n\t}\n\n\t/**\n\t * Ungroups and Unchunks the runtime ops encapsulated by the single remoteMessage received over the wire\n\t * @param remoteMessage - A message from another client, likely a chunked/grouped op\n\t * @returns the ungrouped, unchunked, unpacked SequencedContainerRuntimeMessage encapsulated in the remote message\n\t */\n\tpublic process(remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage[] {\n\t\tconst result: ISequencedDocumentMessage[] = [];\n\n\t\t// Ungroup before and after decompression for back-compat (cleanup tracked by AB#4371)\n\t\tfor (const ungroupedMessage of this.opGroupingManager.ungroupOp(copy(remoteMessage))) {\n\t\t\tconst message = this.opDecompressor.processMessage(ungroupedMessage).message;\n\n\t\t\tfor (let ungroupedMessage2 of this.opGroupingManager.ungroupOp(message)) {\n\t\t\t\t// unpack and unchunk the ungrouped message in place\n\t\t\t\tunpackRuntimeMessage(ungroupedMessage2);\n\t\t\t\tconst chunkProcessingResult =\n\t\t\t\t\tthis.opSplitter.processRemoteMessage(ungroupedMessage2);\n\t\t\t\tungroupedMessage2 = chunkProcessingResult.message;\n\n\t\t\t\tif (chunkProcessingResult.state !== \"Processed\") {\n\t\t\t\t\t// If the message is not chunked or if the splitter is still rebuilding the original message,\n\t\t\t\t\t// there is no need to continue processing\n\t\t\t\t\tresult.push(ungroupedMessage2);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Ungroup before and after decompression for back-compat (cleanup tracked by AB#4371)\n\t\t\t\tfor (const ungroupedMessageAfterChunking of this.opGroupingManager.ungroupOp(\n\t\t\t\t\tungroupedMessage2,\n\t\t\t\t)) {\n\t\t\t\t\tconst decompressionAfterChunking = this.opDecompressor.processMessage(\n\t\t\t\t\t\tungroupedMessageAfterChunking,\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const ungroupedMessageAfterChunking2 of this.opGroupingManager.ungroupOp(\n\t\t\t\t\t\tdecompressionAfterChunking.message,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tif (decompressionAfterChunking.state === \"Skipped\") {\n\t\t\t\t\t\t\t// After chunking, if the original message was not compressed,\n\t\t\t\t\t\t\t// there is no need to continue processing\n\t\t\t\t\t\t\tresult.push(ungroupedMessageAfterChunking2);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The message needs to be unpacked after chunking + decompression\n\t\t\t\t\t\tunpack(ungroupedMessageAfterChunking2);\n\t\t\t\t\t\tresult.push(ungroupedMessageAfterChunking2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\nconst copy = (remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage => {\n\t// Do shallow copy of message, as the processing flow will modify it.\n\t// There might be multiple container instances receiving same message\n\t// We do not need to make deep copy, as each layer will just replace message.content itself,\n\t// but would not modify contents details\n\tconst message = { ...remoteMessage };\n\n\t// back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!\n\t// System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.\n\t// Old ops may contain empty string (I assume noops).\n\tif (typeof message.contents === \"string\" && message.contents !== \"\") {\n\t\tmessage.contents = JSON.parse(message.contents);\n\t}\n\n\treturn message;\n};\n\n/**\n * For a given message, it moves the nested ContainerRuntimeMessage props one level up.\n *\n * The return type illustrates the assumption that the message param\n * becomes a ContainerRuntimeMessage by the time the function returns\n * (but there is no runtime validation of the 'type' or 'compatDetails' values)\n */\nfunction unpack(\n\tmessage: ISequencedDocumentMessage,\n): asserts message is SequencedContainerRuntimeMessage {\n\tconst innerContents = message.contents as ContainerRuntimeMessage;\n\n\t// We're going to turn message into a SequencedContainerRuntimeMessage in-place\n\tconst sequencedContainerRuntimeMessage = message as SequencedContainerRuntimeMessage;\n\tsequencedContainerRuntimeMessage.type = innerContents.type;\n\tsequencedContainerRuntimeMessage.contents = innerContents.contents;\n\tsequencedContainerRuntimeMessage.compatDetails = innerContents.compatDetails;\n}\n\n/**\n * Unpacks runtime messages.\n *\n * @remarks This API makes no promises regarding backward-compatibility. This is internal API.\n * @param message - message (as it observed in storage / service)\n * @returns whether the given message was unpacked\n *\n * @internal\n */\nexport function unpackRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n\tif (message.type !== MessageType.Operation) {\n\t\t// Legacy format, but it's already \"unpacked\",\n\t\t// i.e. message.type is actually ContainerMessageType.\n\t\t// Or it's non-runtime message.\n\t\t// Nothing to do in such case.\n\t\treturn false;\n\t}\n\n\t// legacy op format?\n\t// TODO: Unsure if this is a real format we should be concerned with. There doesn't appear to be anything prepared to handle the address member.\n\tif (\n\t\t(message.contents as { address?: unknown }).address !== undefined &&\n\t\t(message.contents as { type?: unknown }).type === undefined\n\t) {\n\t\tmessage.type = ContainerMessageType.FluidDataStoreOp;\n\t} else {\n\t\t// new format\n\t\tunpack(message);\n\t}\n\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remoteMessageProcessor.js","sourceRoot":"","sources":["../../src/opLifecycle/remoteMessageProcessor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAA8F;AAC9F,kDAMyB;AAKzB;;;;;GAKG;AACH,MAAa,sBAAsB;IAClC,YACkB,UAAsB,EACtB,cAA8B,EAC9B,iBAAoC;QAF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KAAK,kCAAW,CAAC,SAAS,EAAE;QAC3C,8CAA8C;QAC9C,sDAAsD;QACtD,+BAA+B;QAC/B,8BAA8B;QAC9B,OAAO,KAAK,CAAC;KACb;IAED,oBAAoB;IACpB,gJAAgJ;IAChJ,IACE,OAAO,CAAC,QAAkC,CAAC,OAAO,KAAK,SAAS;QAChE,OAAO,CAAC,QAA+B,CAAC,IAAI,KAAK,SAAS,EAC1D;QACD,OAAO,CAAC,IAAI,GAAG,mCAAoB,CAAC,gBAAgB,CAAC;KACrD;SAAM;QACN,aAAa;QACb,MAAM,CAAC,OAAO,CAAC,CAAC;KAChB;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAtBD,oDAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tContainerMessageType,\n\ttype InboundContainerRuntimeMessage,\n\ttype InboundSequencedContainerRuntimeMessage,\n\ttype InboundSequencedContainerRuntimeMessageOrSystemMessage,\n\ttype InboundSequencedRecentlyAddedContainerRuntimeMessage,\n} from \"../messageTypes\";\nimport { OpDecompressor } from \"./opDecompressor\";\nimport { OpGroupingManager } from \"./opGroupingManager\";\nimport { OpSplitter } from \"./opSplitter\";\n\n/**\n * Stateful class for processing incoming remote messages as the virtualization measures are unwrapped,\n * potentially across numerous inbound ops.\n *\n * @internal\n */\nexport class RemoteMessageProcessor {\n\tconstructor(\n\t\tprivate readonly opSplitter: OpSplitter,\n\t\tprivate readonly opDecompressor: OpDecompressor,\n\t\tprivate readonly opGroupingManager: OpGroupingManager,\n\t) {}\n\n\tpublic get partialMessages(): ReadonlyMap<string, string[]> {\n\t\treturn this.opSplitter.chunks;\n\t}\n\n\tpublic clearPartialMessagesFor(clientId: string) {\n\t\tthis.opSplitter.clearPartialChunks(clientId);\n\t}\n\n\t/**\n\t * Ungroups and Unchunks the runtime ops encapsulated by the single remoteMessage received over the wire\n\t * @param remoteMessageCopy - A shallow copy of a message from another client, possibly virtualized\n\t * (grouped, compressed, and/or chunked).\n\t * Being a shallow copy, it's considered mutable, meaning no other Container or other parallel procedure\n\t * depends on this object instance.\n\t * Note remoteMessageCopy.contents (and other object props) MUST not be modified,\n\t * but may be overwritten (as is the case with contents).\n\t * @returns the unchunked, decompressed, ungrouped, unpacked SequencedContainerRuntimeMessages encapsulated in the remote message.\n\t * For ops that weren't virtualized (e.g. System ops that the ContainerRuntime will ultimately ignore),\n\t * a singleton array [remoteMessageCopy] is returned\n\t */\n\tpublic process(\n\t\tremoteMessageCopy: ISequencedDocumentMessage,\n\t): InboundSequencedContainerRuntimeMessageOrSystemMessage[] {\n\t\tconst result: InboundSequencedContainerRuntimeMessageOrSystemMessage[] = [];\n\n\t\tensureContentsDeserialized(remoteMessageCopy);\n\n\t\t// Ungroup before and after decompression for back-compat (cleanup tracked by AB#4371)\n\t\tfor (const ungroupedMessage of this.opGroupingManager.ungroupOp(remoteMessageCopy)) {\n\t\t\tconst message = this.opDecompressor.processMessage(ungroupedMessage).message;\n\n\t\t\tfor (let ungroupedMessage2 of this.opGroupingManager.ungroupOp(message)) {\n\t\t\t\t// unpack and unchunk the ungrouped message in place\n\t\t\t\tunpackRuntimeMessage(ungroupedMessage2);\n\t\t\t\tconst chunkProcessingResult =\n\t\t\t\t\tthis.opSplitter.processRemoteMessage(ungroupedMessage2);\n\t\t\t\tungroupedMessage2 = chunkProcessingResult.message;\n\n\t\t\t\tif (chunkProcessingResult.state !== \"Processed\") {\n\t\t\t\t\t// If the message is not chunked or if the splitter is still rebuilding the original message,\n\t\t\t\t\t// there is no need to continue processing\n\t\t\t\t\tresult.push(\n\t\t\t\t\t\tungroupedMessage2 as InboundSequencedContainerRuntimeMessageOrSystemMessage,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Ungroup before and after decompression for back-compat (cleanup tracked by AB#4371)\n\t\t\t\tfor (const ungroupedMessageAfterChunking of this.opGroupingManager.ungroupOp(\n\t\t\t\t\tungroupedMessage2,\n\t\t\t\t)) {\n\t\t\t\t\tconst decompressionAfterChunking = this.opDecompressor.processMessage(\n\t\t\t\t\t\tungroupedMessageAfterChunking,\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const ungroupedMessageAfterChunking2 of this.opGroupingManager.ungroupOp(\n\t\t\t\t\t\tdecompressionAfterChunking.message,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tif (decompressionAfterChunking.state === \"Skipped\") {\n\t\t\t\t\t\t\t// After chunking, if the original message was not compressed,\n\t\t\t\t\t\t\t// there is no need to continue processing\n\t\t\t\t\t\t\tresult.push(\n\t\t\t\t\t\t\t\tungroupedMessageAfterChunking2 as InboundSequencedContainerRuntimeMessageOrSystemMessage,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The message needs to be unpacked after chunking + decompression\n\t\t\t\t\t\tunpack(ungroupedMessageAfterChunking2);\n\t\t\t\t\t\tresult.push(ungroupedMessageAfterChunking2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n\n/** Takes an incoming message and if the contents is a string, JSON.parse's it in place */\nfunction ensureContentsDeserialized(mutableMessage: ISequencedDocumentMessage): void {\n\t// back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!\n\t// System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.\n\t// Old ops may contain empty string (I assume noops).\n\tif (typeof mutableMessage.contents === \"string\" && mutableMessage.contents !== \"\") {\n\t\tmutableMessage.contents = JSON.parse(mutableMessage.contents);\n\t}\n}\n\n/**\n * For a given message, it moves the nested InboundContainerRuntimeMessage props one level up.\n *\n * The return type illustrates the assumption that the message param\n * becomes a InboundSequencedContainerRuntimeMessage by the time the function returns\n * (but there is no runtime validation of the 'type' or 'compatDetails' values).\n */\nfunction unpack(\n\tmessage: ISequencedDocumentMessage,\n): asserts message is InboundSequencedContainerRuntimeMessage {\n\t// We assume the contents is an InboundContainerRuntimeMessage (the message is \"packed\")\n\tconst contents = message.contents as InboundContainerRuntimeMessage;\n\n\t// We're going to unpack message in-place (promoting those properties of contents up to message itself)\n\tconst messageUnpacked = message as InboundSequencedContainerRuntimeMessage;\n\n\tmessageUnpacked.type = contents.type;\n\tmessageUnpacked.contents = contents.contents;\n\tif (\"compatDetails\" in contents) {\n\t\t(messageUnpacked as InboundSequencedRecentlyAddedContainerRuntimeMessage).compatDetails =\n\t\t\tcontents.compatDetails;\n\t}\n}\n\n/**\n * Unpacks runtime messages.\n *\n * @remarks This API makes no promises regarding backward-compatibility. This is internal API.\n * @param message - message (as it observed in storage / service)\n * @returns whether the given message was unpacked\n *\n * @internal\n */\nexport function unpackRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n\tif (message.type !== MessageType.Operation) {\n\t\t// Legacy format, but it's already \"unpacked\",\n\t\t// i.e. message.type is actually ContainerMessageType.\n\t\t// Or it's non-runtime message.\n\t\t// Nothing to do in such case.\n\t\treturn false;\n\t}\n\n\t// legacy op format?\n\t// TODO: Unsure if this is a real format we should be concerned with. There doesn't appear to be anything prepared to handle the address member.\n\tif (\n\t\t(message.contents as { address?: unknown }).address !== undefined &&\n\t\t(message.contents as { type?: unknown }).type === undefined\n\t) {\n\t\tmessage.type = ContainerMessageType.FluidDataStoreOp;\n\t} else {\n\t\t// new format\n\t\tunpack(message);\n\t}\n\n\treturn true;\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -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.6.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -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.6.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.6.4.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.6.
|
|
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.6.4.0\";\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
7
7
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
8
|
-
import { ContainerMessageType,
|
|
8
|
+
import { ContainerMessageType, InboundSequencedContainerRuntimeMessage } from "./messageTypes";
|
|
9
9
|
/**
|
|
10
10
|
* ! TODO: Remove this interface in "2.0.0-internal.7.0.0" once we only read IPendingMessageNew (AB#4763)
|
|
11
11
|
*/
|
|
@@ -108,7 +108,7 @@ export declare class PendingStateManager implements IDisposable {
|
|
|
108
108
|
* the batch information was preserved for batch messages.
|
|
109
109
|
* @param message - The message that got ack'd and needs to be processed.
|
|
110
110
|
*/
|
|
111
|
-
processPendingLocalMessage(message:
|
|
111
|
+
processPendingLocalMessage(message: InboundSequencedContainerRuntimeMessage): unknown;
|
|
112
112
|
/**
|
|
113
113
|
* This message could be the first message in batch. If so, set batch state marking the beginning of a batch.
|
|
114
114
|
* @param message - The message that is being processed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pendingStateManager.d.ts","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAuB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"pendingStateManager.d.ts","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAuB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,uCAAuC,EAAE,MAAM,gBAAgB,CAAC;AAI/F;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,SAAS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core_utils_1 = require("@fluidframework/core-utils");
|
|
13
13
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
14
|
-
const
|
|
14
|
+
const messageTypes_1 = require("./messageTypes");
|
|
15
15
|
const packageVersion_1 = require("./packageVersion");
|
|
16
|
+
function buildPendingMessageContent(
|
|
17
|
+
// AnyComboFromUnion is needed need to gain access to compatDetails that
|
|
18
|
+
// is only defined for some cases.
|
|
19
|
+
message) {
|
|
20
|
+
// IMPORTANT: Order matters here, this must match the order of the properties used
|
|
21
|
+
// when submitting the message.
|
|
22
|
+
const { type, contents, compatDetails } = message;
|
|
23
|
+
// Any properties that are not defined, won't be emitted by stringify.
|
|
24
|
+
return JSON.stringify({ type, contents, compatDetails });
|
|
25
|
+
}
|
|
16
26
|
/**
|
|
17
27
|
* PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been
|
|
18
28
|
* acknowledged by the server. It also maintains the batch information for both automatically and manually flushed
|
|
@@ -85,7 +95,7 @@ class PendingStateManager {
|
|
|
85
95
|
const parsedContent = JSON.parse(content);
|
|
86
96
|
// IdAllocations need their localOpMetadata stashed in the contents
|
|
87
97
|
// of the op to correctly resume the session when processing stashed ops
|
|
88
|
-
if (parsedContent.type ===
|
|
98
|
+
if (parsedContent.type === messageTypes_1.ContainerMessageType.IdAllocation) {
|
|
89
99
|
parsedContent.contents.stashedState = message.localOpMetadata;
|
|
90
100
|
content = JSON.stringify(parsedContent);
|
|
91
101
|
}
|
|
@@ -160,10 +170,7 @@ class PendingStateManager {
|
|
|
160
170
|
(0, core_utils_1.assert)(pendingMessage !== undefined, 0x169 /* "No pending message found for this remote message" */);
|
|
161
171
|
this.savedOps.push(pendingMessage);
|
|
162
172
|
this.pendingMessages.shift();
|
|
163
|
-
|
|
164
|
-
// when submitting the message.
|
|
165
|
-
const { type, contents, compatDetails } = message;
|
|
166
|
-
const messageContent = JSON.stringify({ type, contents, compatDetails });
|
|
173
|
+
const messageContent = buildPendingMessageContent(message);
|
|
167
174
|
// Stringified content should match
|
|
168
175
|
if (pendingMessage.content !== messageContent) {
|
|
169
176
|
this.stateHandler.close(telemetry_utils_1.DataProcessingError.create("pending local message content mismatch", "unexpectedAckReceived", message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pendingStateManager.js","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4EAAuC;AAGvC,2DAA0D;AAG1D,qEAA2F;AAE3F,yDAA4F;AAC5F,qDAA8C;AAyD9C;;;;;;;;GAQG;AACH,MAAa,mBAAmB;IAkE/B,YACkB,YAAkC,EACnD,iBAAiD,EAChC,MAAuC;QAFvC,iBAAY,GAAZ,YAAY,CAAsB;QAElC,WAAM,GAAN,MAAM,CAAiC;QApExC,oBAAe,GAAG,IAAI,4BAAK,EAAsB,CAAC;QAClD,oBAAe,GAAG,IAAI,4BAAK,EAAsB,CAAC;QAEnE;;WAEG;QACK,aAAQ,GAAyB,EAAE,CAAC;QAE3B,gBAAW,GAAG,IAAI,iBAAI,CAAO,GAAG,EAAE;YAClD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,+CAA+C;QACvC,sBAAiB,GAAY,KAAK,CAAC;QAqF3B,YAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QA7BtD;;;WAGG;QACH,IAAI,iBAAiB,EAAE,aAAa,EAAE;YACrC,KAAK,MAAM,YAAY,IAAI,iBAAiB,CAAC,aAAa,EAAE;gBAC3D,IAAI,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC;gBAC1C,IACE,YAAmC,CAAC,WAAW,KAAK,SAAS;oBAC9D,OAAO,YAAY,CAAC,OAAO,KAAK,QAAQ,EACvC;oBACD,mDAAmD;oBACnD,cAAc,GAAG,IAAI,CAAC,SAAS,CAA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EAAE,kBAAkB,CAAC;gBAC/B,SAAS,EAAE,uBAAuB;gBAClC,KAAK,EAAE,2BAA2B;gBAClC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;aACtC,CAAC,CAAC;SACH;IACF,CAAC;CACD;AA1XD,kDA0XC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport Deque from \"double-ended-queue\";\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert, Lazy } from \"@fluidframework/core-utils\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { DataProcessingError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\nimport { ContainerMessageType, SequencedContainerRuntimeMessage } from \"./containerRuntime\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IBatchMetadata } from \"./metadata\";\n\n/**\n * ! TODO: Remove this interface in \"2.0.0-internal.7.0.0\" once we only read IPendingMessageNew (AB#4763)\n */\nexport interface IPendingMessageOld {\n\ttype: \"message\";\n\tmessageType: ContainerMessageType;\n\tclientSequenceNumber: number;\n\treferenceSequenceNumber: number;\n\tcontent: any;\n\tlocalOpMetadata: unknown;\n\topMetadata: Record<string, unknown> | undefined;\n}\n\n/**\n * This represents a message that has been submitted and is added to the pending queue when `submit` is called on the\n * ContainerRuntime. This message has either not been ack'd by the server or has not been submitted to the server yet.\n */\nexport interface IPendingMessageNew {\n\ttype: \"message\";\n\tclientSequenceNumber: number;\n\treferenceSequenceNumber: number;\n\tcontent: string;\n\tlocalOpMetadata: unknown;\n\topMetadata: Record<string, unknown> | undefined;\n}\n\n/**\n * ! TODO: Remove this type in \"2.0.0-internal.7.0.0\" (AB#4763)\n */\nexport type IPendingState = IPendingMessageOld | IPendingMessageNew;\n\nexport interface IPendingLocalState {\n\t/**\n\t * list of pending states, including ops and batch information\n\t */\n\tpendingStates: IPendingState[];\n}\n\nexport interface IPendingBatchMessage {\n\tcontent: string;\n\tlocalOpMetadata: unknown;\n\topMetadata: Record<string, unknown> | undefined;\n}\n\nexport interface IRuntimeStateHandler {\n\tconnected(): boolean;\n\tclientId(): string | undefined;\n\tclose(error?: ICriticalContainerError): void;\n\tapplyStashedOp(content: string): Promise<unknown>;\n\treSubmit(message: IPendingBatchMessage): void;\n\treSubmitBatch(batch: IPendingBatchMessage[]): void;\n\tisActiveConnection: () => boolean;\n}\n\n/**\n * PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been\n * acknowledged by the server. It also maintains the batch information for both automatically and manually flushed\n * batches along with the messages.\n * When the Container reconnects, it replays the pending states, which includes manual flushing\n * of messages and triggering resubmission of unacked ops.\n *\n * It verifies that all the ops are acked, are received in the right order and batch information is correct.\n */\nexport class PendingStateManager implements IDisposable {\n\tprivate readonly pendingMessages = new Deque<IPendingMessageNew>();\n\tprivate readonly initialMessages = new Deque<IPendingMessageNew>();\n\n\t/**\n\t * Sequenced local ops that are saved when stashing since pending ops may depend on them\n\t */\n\tprivate savedOps: IPendingMessageNew[] = [];\n\n\tprivate readonly disposeOnce = new Lazy<void>(() => {\n\t\tthis.initialMessages.clear();\n\t\tthis.pendingMessages.clear();\n\t});\n\n\t// Indicates whether we are processing a batch.\n\tprivate isProcessingBatch: boolean = false;\n\n\t// This stores the first message in the batch that we are processing. This is used to verify that we get\n\t// the correct batch metadata.\n\tprivate pendingBatchBeginMessage: ISequencedDocumentMessage | undefined;\n\n\tprivate clientId: string | undefined;\n\n\t/**\n\t * The pending messages count. Includes `pendingMessages` and `initialMessages` to keep in sync with\n\t * 'hasPendingMessages'.\n\t */\n\tpublic get pendingMessagesCount(): number {\n\t\treturn this.pendingMessages.length + this.initialMessages.length;\n\t}\n\n\t/**\n\t * Called to check if there are any pending messages in the pending message queue.\n\t * @returns A boolean indicating whether there are messages or not.\n\t */\n\tpublic hasPendingMessages(): boolean {\n\t\treturn this.pendingMessagesCount !== 0;\n\t}\n\n\tpublic getLocalState(): IPendingLocalState | undefined {\n\t\tassert(\n\t\t\tthis.initialMessages.isEmpty(),\n\t\t\t0x2e9 /* \"Must call getLocalState() after applying initial states\" */,\n\t\t);\n\t\tif (!this.pendingMessages.isEmpty()) {\n\t\t\treturn {\n\t\t\t\tpendingStates: [...this.savedOps, ...this.pendingMessages.toArray()].map(\n\t\t\t\t\t(message) => {\n\t\t\t\t\t\tlet content = message.content;\n\t\t\t\t\t\tconst parsedContent = JSON.parse(content);\n\t\t\t\t\t\t// IdAllocations need their localOpMetadata stashed in the contents\n\t\t\t\t\t\t// of the op to correctly resume the session when processing stashed ops\n\t\t\t\t\t\tif (parsedContent.type === ContainerMessageType.IdAllocation) {\n\t\t\t\t\t\t\tparsedContent.contents.stashedState = message.localOpMetadata;\n\t\t\t\t\t\t\tcontent = JSON.stringify(parsedContent);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// delete localOpMetadata since it may not be serializable\n\t\t\t\t\t\t// and will be regenerated by applyStashedOp()\n\t\t\t\t\t\treturn { ...message, content, localOpMetadata: undefined };\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n\n\tconstructor(\n\t\tprivate readonly stateHandler: IRuntimeStateHandler,\n\t\tinitialLocalState: IPendingLocalState | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt | undefined,\n\t) {\n\t\t/**\n\t\t * Convert old local state format to the new format (IPendingMessageOld to IPendingMessageNew)\n\t\t * ! TODO: Remove this conversion in \"2.0.0-internal.7.0.0\" (AB#4763)\n\t\t */\n\t\tif (initialLocalState?.pendingStates) {\n\t\t\tfor (const initialState of initialLocalState.pendingStates) {\n\t\t\t\tlet messageContent = initialState.content;\n\t\t\t\tif (\n\t\t\t\t\t(initialState as IPendingMessageOld).messageType !== undefined &&\n\t\t\t\t\ttypeof initialState.content !== \"string\"\n\t\t\t\t) {\n\t\t\t\t\t// Convert IPendingMessageOld to IPendingMessageNew\n\t\t\t\t\tmessageContent = JSON.stringify({\n\t\t\t\t\t\ttype: (initialState as IPendingMessageOld).messageType,\n\t\t\t\t\t\tcontents: initialState.content,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// Note: this object may contain \"messageType\" prop, but it should not be easily accesible due to interface being used\n\t\t\t\tthis.initialMessages.push({\n\t\t\t\t\t...initialState,\n\t\t\t\t\tcontent: messageContent,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get disposed() {\n\t\treturn this.disposeOnce.evaluated;\n\t}\n\tpublic readonly dispose = () => this.disposeOnce.value;\n\n\t/**\n\t * Called when a message is submitted locally. Adds the message and the associated details to the pending state\n\t * queue.\n\t * @param type - The container message type.\n\t * @param content - The message content.\n\t * @param localOpMetadata - The local metadata associated with the message.\n\t */\n\tpublic onSubmitMessage(\n\t\tcontent: string,\n\t\treferenceSequenceNumber: number,\n\t\tlocalOpMetadata: unknown,\n\t\topMetadata: Record<string, unknown> | undefined,\n\t) {\n\t\tconst pendingMessage: IPendingMessageNew = {\n\t\t\ttype: \"message\",\n\t\t\tclientSequenceNumber: -1, // dummy value (not to be used anywhere)\n\t\t\treferenceSequenceNumber,\n\t\t\tcontent,\n\t\t\tlocalOpMetadata,\n\t\t\topMetadata,\n\t\t};\n\n\t\tthis.pendingMessages.push(pendingMessage);\n\t}\n\n\t/**\n\t * Applies stashed ops at their reference sequence number so they are ready to be ACKed or resubmitted\n\t * @param seqNum - Sequence number at which to apply ops. Will apply all ops if seqNum is undefined.\n\t */\n\tpublic async applyStashedOpsAt(seqNum?: number) {\n\t\t// apply stashed ops at sequence number\n\t\twhile (!this.initialMessages.isEmpty()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst nextMessage = this.initialMessages.peekFront()!;\n\t\t\tif (seqNum !== undefined) {\n\t\t\t\tif (nextMessage.referenceSequenceNumber > seqNum) {\n\t\t\t\t\tbreak; // nothing left to do at this sequence number\n\t\t\t\t}\n\t\t\t\tif (nextMessage.referenceSequenceNumber < seqNum) {\n\t\t\t\t\tthrow new Error(\"loaded from snapshot too recent to apply stashed ops\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// applyStashedOp will cause the DDS to behave as if it has sent the op but not actually send it\n\t\t\t\tconst localOpMetadata = await this.stateHandler.applyStashedOp(nextMessage.content);\n\t\t\t\tnextMessage.localOpMetadata = localOpMetadata;\n\t\t\t} catch (error) {\n\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(error, \"applyStashedOp\", nextMessage);\n\t\t\t}\n\n\t\t\t// then we push onto pendingMessages which will cause PendingStateManager to resubmit when we connect\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.pendingMessages.push(this.initialMessages.shift()!);\n\t\t}\n\t}\n\n\t/**\n\t * Processes a local message once its ack'd by the server. It verifies that there was no data corruption and that\n\t * the batch information was preserved for batch messages.\n\t * @param message - The message that got ack'd and needs to be processed.\n\t */\n\tpublic processPendingLocalMessage(message: SequencedContainerRuntimeMessage): unknown {\n\t\t// Pre-processing part - This may be the start of a batch.\n\t\tthis.maybeProcessBatchBegin(message);\n\n\t\t// Get the next message from the pending queue. Verify a message exists.\n\t\tconst pendingMessage = this.pendingMessages.peekFront();\n\t\tassert(\n\t\t\tpendingMessage !== undefined,\n\t\t\t0x169 /* \"No pending message found for this remote message\" */,\n\t\t);\n\t\tthis.savedOps.push(pendingMessage);\n\n\t\tthis.pendingMessages.shift();\n\n\t\t// IMPORTANT: Order matters here, this must match the order of the properties used\n\t\t// when submitting the message.\n\t\tconst { type, contents, compatDetails } = message;\n\t\tconst messageContent = JSON.stringify({ type, contents, compatDetails });\n\n\t\t// Stringified content should match\n\t\tif (pendingMessage.content !== messageContent) {\n\t\t\tthis.stateHandler.close(\n\t\t\t\tDataProcessingError.create(\n\t\t\t\t\t\"pending local message content mismatch\",\n\t\t\t\t\t\"unexpectedAckReceived\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\texpectedMessageType: JSON.parse(pendingMessage.content).type,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Post-processing part - If we are processing a batch then this could be the last message in the batch.\n\t\tthis.maybeProcessBatchEnd(message);\n\n\t\treturn pendingMessage.localOpMetadata;\n\t}\n\n\t/**\n\t * This message could be the first message in batch. If so, set batch state marking the beginning of a batch.\n\t * @param message - The message that is being processed.\n\t */\n\tprivate maybeProcessBatchBegin(message: ISequencedDocumentMessage) {\n\t\t// This message is the first in a batch if the \"batch\" property on the metadata is set to true\n\t\tif ((message.metadata as IBatchMetadata | undefined)?.batch) {\n\t\t\t// We should not already be processing a batch and there should be no pending batch begin message.\n\t\t\tassert(\n\t\t\t\t!this.isProcessingBatch && this.pendingBatchBeginMessage === undefined,\n\t\t\t\t0x16b /* \"The pending batch state indicates we are already processing a batch\" */,\n\t\t\t);\n\n\t\t\t// Set the pending batch state indicating we have started processing a batch.\n\t\t\tthis.pendingBatchBeginMessage = message;\n\t\t\tthis.isProcessingBatch = true;\n\t\t}\n\t}\n\n\t/**\n\t * This message could be the last message in batch. If so, clear batch state since the batch is complete.\n\t * @param message - The message that is being processed.\n\t */\n\tprivate maybeProcessBatchEnd(message: ISequencedDocumentMessage) {\n\t\tif (!this.isProcessingBatch) {\n\t\t\treturn;\n\t\t}\n\n\t\t// There should be a pending batch begin message.\n\t\tassert(\n\t\t\tthis.pendingBatchBeginMessage !== undefined,\n\t\t\t0x16d /* \"There is no pending batch begin message\" */,\n\t\t);\n\n\t\tconst batchEndMetadata = (message.metadata as IBatchMetadata | undefined)?.batch;\n\t\tif (this.pendingMessages.isEmpty() || batchEndMetadata === false) {\n\t\t\t// Get the batch begin metadata from the first message in the batch.\n\t\t\tconst batchBeginMetadata = (\n\t\t\t\tthis.pendingBatchBeginMessage.metadata as IBatchMetadata | undefined\n\t\t\t)?.batch;\n\n\t\t\t// There could be just a single message in the batch. If so, it should not have any batch metadata. If there\n\t\t\t// are multiple messages in the batch, verify that we got the correct batch begin and end metadata.\n\t\t\tif (this.pendingBatchBeginMessage === message) {\n\t\t\t\tassert(\n\t\t\t\t\tbatchBeginMetadata === undefined,\n\t\t\t\t\t0x16e /* \"Batch with single message should not have batch metadata\" */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (batchBeginMetadata !== true || batchEndMetadata !== false) {\n\t\t\t\t\tthis.stateHandler.close(\n\t\t\t\t\t\tDataProcessingError.create(\n\t\t\t\t\t\t\t\"Pending batch inconsistency\", // Formerly known as asserts 0x16f and 0x170\n\t\t\t\t\t\t\t\"processPendingLocalMessage\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\t\t\t\t\tbatchClientId:\n\t\t\t\t\t\t\t\t\tthis.pendingBatchBeginMessage.clientId === null\n\t\t\t\t\t\t\t\t\t\t? \"null\"\n\t\t\t\t\t\t\t\t\t\t: this.pendingBatchBeginMessage.clientId,\n\t\t\t\t\t\t\t\tclientId: this.stateHandler.clientId(),\n\t\t\t\t\t\t\t\thasBatchStart: batchBeginMetadata === true,\n\t\t\t\t\t\t\t\thasBatchEnd: batchEndMetadata === false,\n\t\t\t\t\t\t\t\tmessageType: message.type,\n\t\t\t\t\t\t\t\tpendingMessagesCount: this.pendingMessagesCount,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Clear the pending batch state now that we have processed the entire batch.\n\t\t\tthis.pendingBatchBeginMessage = undefined;\n\t\t\tthis.isProcessingBatch = false;\n\t\t}\n\t}\n\n\t/**\n\t * Called when the Container's connection state changes. If the Container gets connected, it replays all the pending\n\t * states in its queue. This includes triggering resubmission of unacked ops.\n\t */\n\tpublic replayPendingStates() {\n\t\tassert(\n\t\t\tthis.stateHandler.connected(),\n\t\t\t0x172 /* \"The connection state is not consistent with the runtime\" */,\n\t\t);\n\n\t\t// This assert suggests we are about to send same ops twice, which will result in data loss.\n\t\tassert(\n\t\t\tthis.clientId !== this.stateHandler.clientId(),\n\t\t\t0x173 /* \"replayPendingStates called twice for same clientId!\" */,\n\t\t);\n\t\tthis.clientId = this.stateHandler.clientId();\n\n\t\tassert(\n\t\t\tthis.initialMessages.isEmpty(),\n\t\t\t0x174 /* \"initial states should be empty before replaying pending\" */,\n\t\t);\n\n\t\tconst initialPendingMessagesCount = this.pendingMessages.length;\n\t\tlet remainingPendingMessagesCount = this.pendingMessages.length;\n\n\t\t// Process exactly `pendingMessagesCount` items in the queue as it represents the number of messages that were\n\t\t// pending when we connected. This is important because the `reSubmitFn` might add more items in the queue\n\t\t// which must not be replayed.\n\t\twhile (remainingPendingMessagesCount > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tlet pendingMessage = this.pendingMessages.shift()!;\n\t\t\tremainingPendingMessagesCount--;\n\t\t\tassert(\n\t\t\t\tpendingMessage.opMetadata?.batch !== false,\n\t\t\t\t0x41b /* We cannot process batches in chunks */,\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * We want to ensure grouped messages get processed in a batch.\n\t\t\t * Note: It is not possible for the PendingStateManager to receive a partially acked batch. It will\n\t\t\t * either receive the whole batch ack or nothing at all.\n\t\t\t */\n\t\t\tif (pendingMessage.opMetadata?.batch) {\n\t\t\t\tassert(\n\t\t\t\t\tremainingPendingMessagesCount > 0,\n\t\t\t\t\t0x554 /* Last pending message cannot be a batch begin */,\n\t\t\t\t);\n\n\t\t\t\tconst batch: IPendingBatchMessage[] = [];\n\n\t\t\t\t// check is >= because batch end may be last pending message\n\t\t\t\twhile (remainingPendingMessagesCount >= 0) {\n\t\t\t\t\tbatch.push({\n\t\t\t\t\t\tcontent: pendingMessage.content,\n\t\t\t\t\t\tlocalOpMetadata: pendingMessage.localOpMetadata,\n\t\t\t\t\t\topMetadata: pendingMessage.opMetadata,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (pendingMessage.opMetadata?.batch === false) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tassert(remainingPendingMessagesCount > 0, 0x555 /* No batch end found */);\n\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tpendingMessage = this.pendingMessages.shift()!;\n\t\t\t\t\tremainingPendingMessagesCount--;\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingMessage.opMetadata?.batch !== true,\n\t\t\t\t\t\t0x556 /* Batch start needs a corresponding batch end */,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.stateHandler.reSubmitBatch(batch);\n\t\t\t} else {\n\t\t\t\tthis.stateHandler.reSubmit({\n\t\t\t\t\tcontent: pendingMessage.content,\n\t\t\t\t\tlocalOpMetadata: pendingMessage.localOpMetadata,\n\t\t\t\t\topMetadata: pendingMessage.opMetadata,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pending ops should no longer depend on previous sequenced local ops after resubmit\n\t\tthis.savedOps = [];\n\n\t\t// We replayPendingStates on read connections too - we expect these to get nack'd though, and to then reconnect\n\t\t// on a write connection and replay again. This filters out the replay that happens on the read connection so\n\t\t// we only see the replays on write connections (that have a chance to go through).\n\t\tif (this.stateHandler.isActiveConnection()) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"PendingStatesReplayed\",\n\t\t\t\tcount: initialPendingMessagesCount,\n\t\t\t\tclientId: this.stateHandler.clientId(),\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pendingStateManager.js","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4EAAuC;AAGvC,2DAA0D;AAG1D,qEAA2F;AAE3F,iDAA+F;AAC/F,qDAA8C;AAiE9C,SAAS,0BAA0B;AAClC,wEAAwE;AAC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reserved.\n * Licensed under the MIT License.\n */\n\nimport Deque from \"double-ended-queue\";\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert, Lazy } from \"@fluidframework/core-utils\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { DataProcessingError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\nimport { ContainerMessageType, InboundSequencedContainerRuntimeMessage } from \"./messageTypes\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IBatchMetadata } from \"./metadata\";\n\n/**\n * ! TODO: Remove this interface in \"2.0.0-internal.7.0.0\" once we only read IPendingMessageNew (AB#4763)\n */\nexport interface IPendingMessageOld {\n\ttype: \"message\";\n\tmessageType: ContainerMessageType;\n\tclientSequenceNumber: number;\n\treferenceSequenceNumber: number;\n\tcontent: any;\n\tlocalOpMetadata: unknown;\n\topMetadata: Record<string, unknown> | undefined;\n}\n\n/**\n * This represents a message that has been submitted and is added to the pending queue when `submit` is called on the\n * ContainerRuntime. This message has either not been ack'd by the server or has not been submitted to the server yet.\n */\nexport interface IPendingMessageNew {\n\ttype: \"message\";\n\tclientSequenceNumber: number;\n\treferenceSequenceNumber: number;\n\tcontent: string;\n\tlocalOpMetadata: unknown;\n\topMetadata: Record<string, unknown> | undefined;\n}\n\n/**\n * ! TODO: Remove this type in \"2.0.0-internal.7.0.0\" (AB#4763)\n */\nexport type IPendingState = IPendingMessageOld | IPendingMessageNew;\n\nexport interface IPendingLocalState {\n\t/**\n\t * list of pending states, including ops and batch information\n\t */\n\tpendingStates: IPendingState[];\n}\n\nexport interface IPendingBatchMessage {\n\tcontent: string;\n\tlocalOpMetadata: unknown;\n\topMetadata: Record<string, unknown> | undefined;\n}\n\nexport interface IRuntimeStateHandler {\n\tconnected(): boolean;\n\tclientId(): string | undefined;\n\tclose(error?: ICriticalContainerError): void;\n\tapplyStashedOp(content: string): Promise<unknown>;\n\treSubmit(message: IPendingBatchMessage): void;\n\treSubmitBatch(batch: IPendingBatchMessage[]): void;\n\tisActiveConnection: () => boolean;\n}\n\n/** Union of keys of T */\ntype KeysOfUnion<T extends object> = T extends T ? keyof T : never;\n/** *Partial* type all possible combinations of properties and values of union T.\n * This loosens typing allowing access to all possible properties without\n * narrowing.\n */\ntype AnyComboFromUnion<T extends object> = { [P in KeysOfUnion<T>]?: T[P] };\n\nfunction buildPendingMessageContent(\n\t// AnyComboFromUnion is needed need to gain access to compatDetails that\n\t// is only defined for some cases.\n\tmessage: AnyComboFromUnion<InboundSequencedContainerRuntimeMessage>,\n): string {\n\t// IMPORTANT: Order matters here, this must match the order of the properties used\n\t// when submitting the message.\n\tconst { type, contents, compatDetails } = message;\n\t// Any properties that are not defined, won't be emitted by stringify.\n\treturn JSON.stringify({ type, contents, compatDetails });\n}\n\n/**\n * PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been\n * acknowledged by the server. It also maintains the batch information for both automatically and manually flushed\n * batches along with the messages.\n * When the Container reconnects, it replays the pending states, which includes manual flushing\n * of messages and triggering resubmission of unacked ops.\n *\n * It verifies that all the ops are acked, are received in the right order and batch information is correct.\n */\nexport class PendingStateManager implements IDisposable {\n\tprivate readonly pendingMessages = new Deque<IPendingMessageNew>();\n\tprivate readonly initialMessages = new Deque<IPendingMessageNew>();\n\n\t/**\n\t * Sequenced local ops that are saved when stashing since pending ops may depend on them\n\t */\n\tprivate savedOps: IPendingMessageNew[] = [];\n\n\tprivate readonly disposeOnce = new Lazy<void>(() => {\n\t\tthis.initialMessages.clear();\n\t\tthis.pendingMessages.clear();\n\t});\n\n\t// Indicates whether we are processing a batch.\n\tprivate isProcessingBatch: boolean = false;\n\n\t// This stores the first message in the batch that we are processing. This is used to verify that we get\n\t// the correct batch metadata.\n\tprivate pendingBatchBeginMessage: ISequencedDocumentMessage | undefined;\n\n\tprivate clientId: string | undefined;\n\n\t/**\n\t * The pending messages count. Includes `pendingMessages` and `initialMessages` to keep in sync with\n\t * 'hasPendingMessages'.\n\t */\n\tpublic get pendingMessagesCount(): number {\n\t\treturn this.pendingMessages.length + this.initialMessages.length;\n\t}\n\n\t/**\n\t * Called to check if there are any pending messages in the pending message queue.\n\t * @returns A boolean indicating whether there are messages or not.\n\t */\n\tpublic hasPendingMessages(): boolean {\n\t\treturn this.pendingMessagesCount !== 0;\n\t}\n\n\tpublic getLocalState(): IPendingLocalState | undefined {\n\t\tassert(\n\t\t\tthis.initialMessages.isEmpty(),\n\t\t\t0x2e9 /* \"Must call getLocalState() after applying initial states\" */,\n\t\t);\n\t\tif (!this.pendingMessages.isEmpty()) {\n\t\t\treturn {\n\t\t\t\tpendingStates: [...this.savedOps, ...this.pendingMessages.toArray()].map(\n\t\t\t\t\t(message) => {\n\t\t\t\t\t\tlet content = message.content;\n\t\t\t\t\t\tconst parsedContent = JSON.parse(content);\n\t\t\t\t\t\t// IdAllocations need their localOpMetadata stashed in the contents\n\t\t\t\t\t\t// of the op to correctly resume the session when processing stashed ops\n\t\t\t\t\t\tif (parsedContent.type === ContainerMessageType.IdAllocation) {\n\t\t\t\t\t\t\tparsedContent.contents.stashedState = message.localOpMetadata;\n\t\t\t\t\t\t\tcontent = JSON.stringify(parsedContent);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// delete localOpMetadata since it may not be serializable\n\t\t\t\t\t\t// and will be regenerated by applyStashedOp()\n\t\t\t\t\t\treturn { ...message, content, localOpMetadata: undefined };\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n\n\tconstructor(\n\t\tprivate readonly stateHandler: IRuntimeStateHandler,\n\t\tinitialLocalState: IPendingLocalState | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt | undefined,\n\t) {\n\t\t/**\n\t\t * Convert old local state format to the new format (IPendingMessageOld to IPendingMessageNew)\n\t\t * ! TODO: Remove this conversion in \"2.0.0-internal.7.0.0\" (AB#4763)\n\t\t */\n\t\tif (initialLocalState?.pendingStates) {\n\t\t\tfor (const initialState of initialLocalState.pendingStates) {\n\t\t\t\tlet messageContent = initialState.content;\n\t\t\t\tif (\n\t\t\t\t\t(initialState as IPendingMessageOld).messageType !== undefined &&\n\t\t\t\t\ttypeof initialState.content !== \"string\"\n\t\t\t\t) {\n\t\t\t\t\t// Convert IPendingMessageOld to IPendingMessageNew\n\t\t\t\t\tmessageContent = JSON.stringify({\n\t\t\t\t\t\ttype: (initialState as IPendingMessageOld).messageType,\n\t\t\t\t\t\tcontents: initialState.content,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// Note: this object may contain \"messageType\" prop, but it should not be easily accesible due to interface being used\n\t\t\t\tthis.initialMessages.push({\n\t\t\t\t\t...initialState,\n\t\t\t\t\tcontent: messageContent,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get disposed() {\n\t\treturn this.disposeOnce.evaluated;\n\t}\n\tpublic readonly dispose = () => this.disposeOnce.value;\n\n\t/**\n\t * Called when a message is submitted locally. Adds the message and the associated details to the pending state\n\t * queue.\n\t * @param type - The container message type.\n\t * @param content - The message content.\n\t * @param localOpMetadata - The local metadata associated with the message.\n\t */\n\tpublic onSubmitMessage(\n\t\tcontent: string,\n\t\treferenceSequenceNumber: number,\n\t\tlocalOpMetadata: unknown,\n\t\topMetadata: Record<string, unknown> | undefined,\n\t) {\n\t\tconst pendingMessage: IPendingMessageNew = {\n\t\t\ttype: \"message\",\n\t\t\tclientSequenceNumber: -1, // dummy value (not to be used anywhere)\n\t\t\treferenceSequenceNumber,\n\t\t\tcontent,\n\t\t\tlocalOpMetadata,\n\t\t\topMetadata,\n\t\t};\n\n\t\tthis.pendingMessages.push(pendingMessage);\n\t}\n\n\t/**\n\t * Applies stashed ops at their reference sequence number so they are ready to be ACKed or resubmitted\n\t * @param seqNum - Sequence number at which to apply ops. Will apply all ops if seqNum is undefined.\n\t */\n\tpublic async applyStashedOpsAt(seqNum?: number) {\n\t\t// apply stashed ops at sequence number\n\t\twhile (!this.initialMessages.isEmpty()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst nextMessage = this.initialMessages.peekFront()!;\n\t\t\tif (seqNum !== undefined) {\n\t\t\t\tif (nextMessage.referenceSequenceNumber > seqNum) {\n\t\t\t\t\tbreak; // nothing left to do at this sequence number\n\t\t\t\t}\n\t\t\t\tif (nextMessage.referenceSequenceNumber < seqNum) {\n\t\t\t\t\tthrow new Error(\"loaded from snapshot too recent to apply stashed ops\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// applyStashedOp will cause the DDS to behave as if it has sent the op but not actually send it\n\t\t\t\tconst localOpMetadata = await this.stateHandler.applyStashedOp(nextMessage.content);\n\t\t\t\tnextMessage.localOpMetadata = localOpMetadata;\n\t\t\t} catch (error) {\n\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(error, \"applyStashedOp\", nextMessage);\n\t\t\t}\n\n\t\t\t// then we push onto pendingMessages which will cause PendingStateManager to resubmit when we connect\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.pendingMessages.push(this.initialMessages.shift()!);\n\t\t}\n\t}\n\n\t/**\n\t * Processes a local message once its ack'd by the server. It verifies that there was no data corruption and that\n\t * the batch information was preserved for batch messages.\n\t * @param message - The message that got ack'd and needs to be processed.\n\t */\n\tpublic processPendingLocalMessage(message: InboundSequencedContainerRuntimeMessage): unknown {\n\t\t// Pre-processing part - This may be the start of a batch.\n\t\tthis.maybeProcessBatchBegin(message);\n\n\t\t// Get the next message from the pending queue. Verify a message exists.\n\t\tconst pendingMessage = this.pendingMessages.peekFront();\n\t\tassert(\n\t\t\tpendingMessage !== undefined,\n\t\t\t0x169 /* \"No pending message found for this remote message\" */,\n\t\t);\n\t\tthis.savedOps.push(pendingMessage);\n\n\t\tthis.pendingMessages.shift();\n\n\t\tconst messageContent = buildPendingMessageContent(message);\n\n\t\t// Stringified content should match\n\t\tif (pendingMessage.content !== messageContent) {\n\t\t\tthis.stateHandler.close(\n\t\t\t\tDataProcessingError.create(\n\t\t\t\t\t\"pending local message content mismatch\",\n\t\t\t\t\t\"unexpectedAckReceived\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\texpectedMessageType: JSON.parse(pendingMessage.content).type,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Post-processing part - If we are processing a batch then this could be the last message in the batch.\n\t\tthis.maybeProcessBatchEnd(message);\n\n\t\treturn pendingMessage.localOpMetadata;\n\t}\n\n\t/**\n\t * This message could be the first message in batch. If so, set batch state marking the beginning of a batch.\n\t * @param message - The message that is being processed.\n\t */\n\tprivate maybeProcessBatchBegin(message: ISequencedDocumentMessage) {\n\t\t// This message is the first in a batch if the \"batch\" property on the metadata is set to true\n\t\tif ((message.metadata as IBatchMetadata | undefined)?.batch) {\n\t\t\t// We should not already be processing a batch and there should be no pending batch begin message.\n\t\t\tassert(\n\t\t\t\t!this.isProcessingBatch && this.pendingBatchBeginMessage === undefined,\n\t\t\t\t0x16b /* \"The pending batch state indicates we are already processing a batch\" */,\n\t\t\t);\n\n\t\t\t// Set the pending batch state indicating we have started processing a batch.\n\t\t\tthis.pendingBatchBeginMessage = message;\n\t\t\tthis.isProcessingBatch = true;\n\t\t}\n\t}\n\n\t/**\n\t * This message could be the last message in batch. If so, clear batch state since the batch is complete.\n\t * @param message - The message that is being processed.\n\t */\n\tprivate maybeProcessBatchEnd(message: ISequencedDocumentMessage) {\n\t\tif (!this.isProcessingBatch) {\n\t\t\treturn;\n\t\t}\n\n\t\t// There should be a pending batch begin message.\n\t\tassert(\n\t\t\tthis.pendingBatchBeginMessage !== undefined,\n\t\t\t0x16d /* \"There is no pending batch begin message\" */,\n\t\t);\n\n\t\tconst batchEndMetadata = (message.metadata as IBatchMetadata | undefined)?.batch;\n\t\tif (this.pendingMessages.isEmpty() || batchEndMetadata === false) {\n\t\t\t// Get the batch begin metadata from the first message in the batch.\n\t\t\tconst batchBeginMetadata = (\n\t\t\t\tthis.pendingBatchBeginMessage.metadata as IBatchMetadata | undefined\n\t\t\t)?.batch;\n\n\t\t\t// There could be just a single message in the batch. If so, it should not have any batch metadata. If there\n\t\t\t// are multiple messages in the batch, verify that we got the correct batch begin and end metadata.\n\t\t\tif (this.pendingBatchBeginMessage === message) {\n\t\t\t\tassert(\n\t\t\t\t\tbatchBeginMetadata === undefined,\n\t\t\t\t\t0x16e /* \"Batch with single message should not have batch metadata\" */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (batchBeginMetadata !== true || batchEndMetadata !== false) {\n\t\t\t\t\tthis.stateHandler.close(\n\t\t\t\t\t\tDataProcessingError.create(\n\t\t\t\t\t\t\t\"Pending batch inconsistency\", // Formerly known as asserts 0x16f and 0x170\n\t\t\t\t\t\t\t\"processPendingLocalMessage\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\t\t\t\t\tbatchClientId:\n\t\t\t\t\t\t\t\t\tthis.pendingBatchBeginMessage.clientId === null\n\t\t\t\t\t\t\t\t\t\t? \"null\"\n\t\t\t\t\t\t\t\t\t\t: this.pendingBatchBeginMessage.clientId,\n\t\t\t\t\t\t\t\tclientId: this.stateHandler.clientId(),\n\t\t\t\t\t\t\t\thasBatchStart: batchBeginMetadata === true,\n\t\t\t\t\t\t\t\thasBatchEnd: batchEndMetadata === false,\n\t\t\t\t\t\t\t\tmessageType: message.type,\n\t\t\t\t\t\t\t\tpendingMessagesCount: this.pendingMessagesCount,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Clear the pending batch state now that we have processed the entire batch.\n\t\t\tthis.pendingBatchBeginMessage = undefined;\n\t\t\tthis.isProcessingBatch = false;\n\t\t}\n\t}\n\n\t/**\n\t * Called when the Container's connection state changes. If the Container gets connected, it replays all the pending\n\t * states in its queue. This includes triggering resubmission of unacked ops.\n\t */\n\tpublic replayPendingStates() {\n\t\tassert(\n\t\t\tthis.stateHandler.connected(),\n\t\t\t0x172 /* \"The connection state is not consistent with the runtime\" */,\n\t\t);\n\n\t\t// This assert suggests we are about to send same ops twice, which will result in data loss.\n\t\tassert(\n\t\t\tthis.clientId !== this.stateHandler.clientId(),\n\t\t\t0x173 /* \"replayPendingStates called twice for same clientId!\" */,\n\t\t);\n\t\tthis.clientId = this.stateHandler.clientId();\n\n\t\tassert(\n\t\t\tthis.initialMessages.isEmpty(),\n\t\t\t0x174 /* \"initial states should be empty before replaying pending\" */,\n\t\t);\n\n\t\tconst initialPendingMessagesCount = this.pendingMessages.length;\n\t\tlet remainingPendingMessagesCount = this.pendingMessages.length;\n\n\t\t// Process exactly `pendingMessagesCount` items in the queue as it represents the number of messages that were\n\t\t// pending when we connected. This is important because the `reSubmitFn` might add more items in the queue\n\t\t// which must not be replayed.\n\t\twhile (remainingPendingMessagesCount > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tlet pendingMessage = this.pendingMessages.shift()!;\n\t\t\tremainingPendingMessagesCount--;\n\t\t\tassert(\n\t\t\t\tpendingMessage.opMetadata?.batch !== false,\n\t\t\t\t0x41b /* We cannot process batches in chunks */,\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * We want to ensure grouped messages get processed in a batch.\n\t\t\t * Note: It is not possible for the PendingStateManager to receive a partially acked batch. It will\n\t\t\t * either receive the whole batch ack or nothing at all.\n\t\t\t */\n\t\t\tif (pendingMessage.opMetadata?.batch) {\n\t\t\t\tassert(\n\t\t\t\t\tremainingPendingMessagesCount > 0,\n\t\t\t\t\t0x554 /* Last pending message cannot be a batch begin */,\n\t\t\t\t);\n\n\t\t\t\tconst batch: IPendingBatchMessage[] = [];\n\n\t\t\t\t// check is >= because batch end may be last pending message\n\t\t\t\twhile (remainingPendingMessagesCount >= 0) {\n\t\t\t\t\tbatch.push({\n\t\t\t\t\t\tcontent: pendingMessage.content,\n\t\t\t\t\t\tlocalOpMetadata: pendingMessage.localOpMetadata,\n\t\t\t\t\t\topMetadata: pendingMessage.opMetadata,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (pendingMessage.opMetadata?.batch === false) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tassert(remainingPendingMessagesCount > 0, 0x555 /* No batch end found */);\n\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tpendingMessage = this.pendingMessages.shift()!;\n\t\t\t\t\tremainingPendingMessagesCount--;\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingMessage.opMetadata?.batch !== true,\n\t\t\t\t\t\t0x556 /* Batch start needs a corresponding batch end */,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.stateHandler.reSubmitBatch(batch);\n\t\t\t} else {\n\t\t\t\tthis.stateHandler.reSubmit({\n\t\t\t\t\tcontent: pendingMessage.content,\n\t\t\t\t\tlocalOpMetadata: pendingMessage.localOpMetadata,\n\t\t\t\t\topMetadata: pendingMessage.opMetadata,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pending ops should no longer depend on previous sequenced local ops after resubmit\n\t\tthis.savedOps = [];\n\n\t\t// We replayPendingStates on read connections too - we expect these to get nack'd though, and to then reconnect\n\t\t// on a write connection and replay again. This filters out the replay that happens on the read connection so\n\t\t// we only see the replays on write connections (that have a chance to go through).\n\t\tif (this.stateHandler.isActiveConnection()) {\n\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\teventName: \"PendingStatesReplayed\",\n\t\t\t\tcount: initialPendingMessagesCount,\n\t\t\t\tclientId: this.stateHandler.clientId(),\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
@@ -94,7 +94,7 @@ export declare class RunningSummarizer extends TypedEventEmitter<ISummarizerEven
|
|
|
94
94
|
* @param before - set of instructions to run before running the action.
|
|
95
95
|
* @param action - action to perform.
|
|
96
96
|
* @param after - set of instructions to run after running the action.
|
|
97
|
-
* @returns
|
|
97
|
+
* @returns The result of the action.
|
|
98
98
|
*/
|
|
99
99
|
private lockedSummaryAction;
|
|
100
100
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runningSummarizer.d.ts","sourceRoot":"","sources":["../../src/summary/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AASpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EACN,wBAAwB,EAExB,uBAAuB,EAEvB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,kBAAkB,EAElB,yBAAyB,EACzB,iBAAiB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAiB,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAGN,sBAAsB,EAEtB,MAAM,oBAAoB,CAAC;AAI5B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC;;;GAGG;AACH,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,iBAAiB,CAAC,iBAAiB,CAAE,YAAW,WAAW;IAqGhG,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAGtC,OAAO,CAAC,QAAQ,CAAC,+BAA+B;IAGhD,OAAO,CAAC,QA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;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,6BAA6B;IAWxB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;YA6BjD,SAAS;IAuBvB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,kBAAkB;IAW1B;;;;;;;;OAQG;YACW,mBAAmB;IAsBjC;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAoCxB,oCAAoC;IACpC,OAAO,CAAC,YAAY;IAyBpB;;;OAGG;YACW,8BAA8B;IAsE5C;;;OAGG;YACW,uBAAuB;IAoIrC,8DAA8D;IACvD,iBAAiB,CACvB,OAAO,EAAE,yBAAyB,EAClC,cAAc,GAAE,sBAAqD,GACnE,iBAAiB;IAqBpB,6DAA6D;IACtD,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,sBAAsB;IAiClF,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,sBAAsB;CAS9B"}
|
|
@@ -189,7 +189,8 @@ class RunningSummarizer extends client_utils_1.TypedEventEmitter {
|
|
|
189
189
|
// latest version with which we will refresh the state. However in case of single commit
|
|
190
190
|
// summary, we might me missing a summary ack, so in that case we are still fine as the
|
|
191
191
|
// code in `submitSummary` function in container runtime, will refresh the latest state
|
|
192
|
-
// by calling `
|
|
192
|
+
// by calling `prefetchLatestSummaryThenClose`. We will load the next summarizer from the
|
|
193
|
+
// updated state and be fine.
|
|
193
194
|
const isIgnoredError = (0, telemetry_utils_1.isFluidError)(error) &&
|
|
194
195
|
error.errorType === driver_definitions_1.DriverErrorTypes.fileNotFoundOrAccessDeniedError;
|
|
195
196
|
summaryLogger.sendTelemetryEvent({
|
|
@@ -256,6 +257,7 @@ class RunningSummarizer extends client_utils_1.TypedEventEmitter {
|
|
|
256
257
|
!this.tryRunEnqueuedSummary() &&
|
|
257
258
|
!this.heuristicRunnerMicroTaskExists) {
|
|
258
259
|
this.heuristicRunnerMicroTaskExists = true;
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
259
261
|
Promise.resolve()
|
|
260
262
|
.then(() => {
|
|
261
263
|
this.heuristicRunner?.run();
|
|
@@ -347,7 +349,7 @@ class RunningSummarizer extends client_utils_1.TypedEventEmitter {
|
|
|
347
349
|
* @param before - set of instructions to run before running the action.
|
|
348
350
|
* @param action - action to perform.
|
|
349
351
|
* @param after - set of instructions to run after running the action.
|
|
350
|
-
* @returns
|
|
352
|
+
* @returns The result of the action.
|
|
351
353
|
*/
|
|
352
354
|
async lockedSummaryAction(before, action, after) {
|
|
353
355
|
(0, core_utils_1.assert)(this.summarizingLock === undefined, 0x25b /* "Caller is responsible for checking lock" */);
|