@fluidframework/container-loader 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191258
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 +131 -0
- package/README.md +10 -6
- package/dist/audience.d.ts +1 -0
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +5 -3
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.js +2 -2
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +5 -5
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +97 -93
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +15 -14
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +50 -52
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +20 -9
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +327 -277
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -7
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +2 -14
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +12 -13
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +21 -8
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +3 -3
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.d.ts +30 -0
- package/dist/debugLogger.d.ts.map +1 -0
- package/dist/debugLogger.js +95 -0
- package/dist/debugLogger.js.map +1 -0
- package/dist/deltaManager.d.ts +21 -10
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +114 -66
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +10 -10
- package/dist/deltaQueue.js.map +1 -1
- package/dist/disposal.d.ts +2 -2
- package/dist/disposal.d.ts.map +1 -1
- package/dist/disposal.js +1 -1
- package/dist/disposal.js.map +1 -1
- package/dist/error.d.ts +23 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +32 -0
- package/dist/error.js.map +1 -0
- package/dist/loader.d.ts +22 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +82 -51
- package/dist/loader.js.map +1 -1
- package/dist/noopHeuristic.d.ts +2 -2
- package/dist/noopHeuristic.d.ts.map +1 -1
- package/dist/noopHeuristic.js +6 -5
- package/dist/noopHeuristic.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/protocol.d.ts +4 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +25 -4
- package/dist/protocol.js.map +1 -1
- package/dist/quorum.d.ts +4 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js +1 -13
- package/dist/quorum.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +4 -4
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/utils.d.ts +8 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +30 -11
- package/dist/utils.js.map +1 -1
- package/lib/audience.d.ts +1 -0
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +4 -2
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.js +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +5 -5
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +74 -67
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +15 -14
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +27 -29
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +20 -9
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +288 -238
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -7
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +2 -14
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +5 -6
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +21 -8
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +3 -3
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.d.ts +30 -0
- package/lib/debugLogger.d.ts.map +1 -0
- package/lib/debugLogger.js +91 -0
- package/lib/debugLogger.js.map +1 -0
- package/lib/deltaManager.d.ts +21 -10
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +88 -37
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +3 -3
- package/lib/deltaQueue.js.map +1 -1
- package/lib/disposal.d.ts +2 -2
- package/lib/disposal.d.ts.map +1 -1
- package/lib/disposal.js +1 -1
- package/lib/disposal.js.map +1 -1
- package/lib/error.d.ts +23 -0
- package/lib/error.d.ts.map +1 -0
- package/lib/error.js +28 -0
- package/lib/error.js.map +1 -0
- package/lib/loader.d.ts +22 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +82 -51
- package/lib/loader.js.map +1 -1
- package/lib/noopHeuristic.d.ts +2 -2
- package/lib/noopHeuristic.d.ts.map +1 -1
- package/lib/noopHeuristic.js +2 -1
- package/lib/noopHeuristic.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/protocol.d.ts +4 -2
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +25 -4
- package/lib/protocol.js.map +1 -1
- package/lib/quorum.d.ts +4 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js +0 -11
- package/lib/quorum.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +2 -2
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts +8 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +25 -7
- package/lib/utils.js.map +1 -1
- package/package.json +26 -32
- package/src/audience.ts +7 -1
- package/src/catchUpMonitor.ts +1 -1
- package/src/connectionManager.ts +75 -51
- package/src/connectionStateHandler.ts +31 -38
- package/src/container.ts +335 -240
- package/src/containerContext.ts +0 -16
- package/src/containerStorageAdapter.ts +2 -1
- package/src/contracts.ts +27 -11
- package/src/debugLogger.ts +113 -0
- package/src/deltaManager.ts +84 -34
- package/src/deltaQueue.ts +2 -1
- package/src/disposal.ts +2 -2
- package/src/error.ts +44 -0
- package/src/loader.ts +83 -35
- package/src/noopHeuristic.ts +3 -2
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +33 -2
- package/src/quorum.ts +0 -10
- package/src/retriableDocumentStorageService.ts +2 -4
- package/src/utils.ts +33 -8
package/dist/deltaManager.d.ts
CHANGED
|
@@ -2,19 +2,17 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { IDeltaHandlerStrategy, IDeltaManager, IDeltaManagerEvents, IDeltaQueue, ICriticalContainerError, IThrottlingWarning, IConnectionDetailsInternal } from "@fluidframework/container-definitions";
|
|
9
|
-
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
5
|
+
import { IThrottlingWarning, IEventProvider, ITelemetryProperties, ITelemetryErrorEvent } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { ICriticalContainerError, IDeltaManager, IDeltaManagerEvents, IDeltaQueue } from "@fluidframework/container-definitions";
|
|
7
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
10
8
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
11
9
|
import { IDocumentService } from "@fluidframework/driver-definitions";
|
|
12
10
|
import { IDocumentMessage, ISequencedDocumentMessage, ISignalMessage, MessageType, ConnectionMode } from "@fluidframework/protocol-definitions";
|
|
13
|
-
import {
|
|
11
|
+
import { IConnectionDetailsInternal, IConnectionManager, IConnectionManagerFactoryArgs, IConnectionStateChangeReason } from "./contracts";
|
|
14
12
|
export interface IConnectionArgs {
|
|
15
13
|
mode?: ConnectionMode;
|
|
16
14
|
fetchOpsFromStorage?: boolean;
|
|
17
|
-
reason:
|
|
15
|
+
reason: IConnectionStateChangeReason;
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
20
18
|
* Includes events emitted by the concrete implementation DeltaManager
|
|
@@ -24,8 +22,21 @@ export interface IDeltaManagerInternalEvents extends IDeltaManagerEvents {
|
|
|
24
22
|
(event: "throttled", listener: (error: IThrottlingWarning) => void): any;
|
|
25
23
|
(event: "closed" | "disposed", listener: (error?: ICriticalContainerError) => void): any;
|
|
26
24
|
(event: "connect", listener: (details: IConnectionDetailsInternal, opsBehind?: number) => void): any;
|
|
27
|
-
(event: "establishingConnection", listener: (reason:
|
|
28
|
-
(event: "cancelEstablishingConnection", listener: (reason:
|
|
25
|
+
(event: "establishingConnection", listener: (reason: IConnectionStateChangeReason) => void): any;
|
|
26
|
+
(event: "cancelEstablishingConnection", listener: (reason: IConnectionStateChangeReason) => void): any;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Interface used to define a strategy for handling incoming delta messages
|
|
30
|
+
*/
|
|
31
|
+
export interface IDeltaHandlerStrategy {
|
|
32
|
+
/**
|
|
33
|
+
* Processes the message.
|
|
34
|
+
*/
|
|
35
|
+
process: (message: ISequencedDocumentMessage) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Processes the signal.
|
|
38
|
+
*/
|
|
39
|
+
processSignal: (message: ISignalMessage) => void;
|
|
29
40
|
}
|
|
30
41
|
/**
|
|
31
42
|
* Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta
|
|
@@ -107,7 +118,7 @@ export declare class DeltaManager<TConnectionManager extends IConnectionManager>
|
|
|
107
118
|
/**
|
|
108
119
|
* Sets the sequence number from which inbound messages should be returned
|
|
109
120
|
*/
|
|
110
|
-
attachOpHandler(minSequenceNumber: number, sequenceNumber: number, handler: IDeltaHandlerStrategy, prefetchType?: "cached" | "all" | "none"): Promise<void>;
|
|
121
|
+
attachOpHandler(minSequenceNumber: number, sequenceNumber: number, handler: IDeltaHandlerStrategy, prefetchType?: "sequenceNumber" | "cached" | "all" | "none"): Promise<void>;
|
|
111
122
|
connect(args: IConnectionArgs): void;
|
|
112
123
|
private getDeltas;
|
|
113
124
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaManager.d.ts","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"deltaManager.d.ts","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,uBAAuB,EACvB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAON,mBAAmB,EAGnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEN,gBAAgB,EAEhB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,WAAW,EACX,cAAc,EACd,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,6BAA6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,KAAK,CAAC,EAAE,uBAAuB,GAAG,IAAI;IAWnD;;;;;;;OAOG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,uBAAuB,GAAG,IAAI;IAoB7D,OAAO,CAAC,WAAW;IAgBZ,gBAAgB,CAAC,EAAE,EAAE,MAAM;IAOlC,OAAO,CAAC,iBAAiB;IAKzB;;;;;OAKG;IACI,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAsBhE,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,eAAe;IAyJvB,OAAO,CAAC,qBAAqB;IAyG7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;YACW,sBAAsB;IA6DpC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,4BAA4B;CAKpC"}
|
package/dist/deltaManager.js
CHANGED
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
7
|
exports.DeltaManager = void 0;
|
|
11
|
-
const abort_controller_1 = __importDefault(require("abort-controller"));
|
|
12
8
|
const uuid_1 = require("uuid");
|
|
13
|
-
const
|
|
9
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
10
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
14
11
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
15
12
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
16
13
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
17
14
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
18
|
-
const container_utils_1 = require("@fluidframework/container-utils");
|
|
19
15
|
const deltaQueue_1 = require("./deltaQueue");
|
|
20
16
|
const protocol_1 = require("./protocol");
|
|
17
|
+
const error_1 = require("./error");
|
|
21
18
|
/**
|
|
22
19
|
* Determines if message was sent by client, not service
|
|
23
20
|
*/
|
|
@@ -40,7 +37,7 @@ function isClientMessage(message) {
|
|
|
40
37
|
* Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta
|
|
41
38
|
* messages in order regardless of possible network conditions or timings causing out of order delivery.
|
|
42
39
|
*/
|
|
43
|
-
class DeltaManager extends
|
|
40
|
+
class DeltaManager extends client_utils_1.TypedEventEmitter {
|
|
44
41
|
constructor(serviceProvider, logger, _active, createConnectionManager) {
|
|
45
42
|
super();
|
|
46
43
|
this.serviceProvider = serviceProvider;
|
|
@@ -77,7 +74,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
77
74
|
this._disposed = false;
|
|
78
75
|
this.throttlingIdSet = new Set();
|
|
79
76
|
this.timeTillThrottling = 0;
|
|
80
|
-
this.closeAbortController = new
|
|
77
|
+
this.closeAbortController = new AbortController();
|
|
81
78
|
this.deltaStorageDelayId = (0, uuid_1.v4)();
|
|
82
79
|
this.deltaStreamDelayId = (0, uuid_1.v4)();
|
|
83
80
|
this.messageBuffer = [];
|
|
@@ -94,7 +91,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
94
91
|
signalHandler: (message) => this._inboundSignal.push(message),
|
|
95
92
|
reconnectionDelayHandler: (delayMs, error) => this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),
|
|
96
93
|
closeHandler: (error) => this.close(error),
|
|
97
|
-
disconnectHandler: (reason
|
|
94
|
+
disconnectHandler: (reason) => this.disconnectHandler(reason),
|
|
98
95
|
connectHandler: (connection) => this.connectHandler(connection),
|
|
99
96
|
pongHandler: (latency) => this.emit("pong", latency),
|
|
100
97
|
readonlyChangeHandler: (readonly) => (0, telemetry_utils_1.safeRaiseEvent)(this, this.logger, "readonly", readonly),
|
|
@@ -106,7 +103,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
106
103
|
this.processInboundMessage(op);
|
|
107
104
|
});
|
|
108
105
|
this._inbound.on("error", (error) => {
|
|
109
|
-
this.close(
|
|
106
|
+
this.close(telemetry_utils_1.DataProcessingError.wrapIfUnrecognized(error, "deltaManagerInboundErrorHandler", this.lastMessage));
|
|
110
107
|
});
|
|
111
108
|
// Inbound signal queue
|
|
112
109
|
this._inboundSignal = new deltaQueue_1.DeltaQueue((message) => {
|
|
@@ -161,7 +158,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
161
158
|
*/
|
|
162
159
|
get hasCheckpointSequenceNumber() {
|
|
163
160
|
// Valid to be called only if we have active connection.
|
|
164
|
-
(0,
|
|
161
|
+
(0, core_utils_1.assert)(this.connectionManager.connected, 0x0df /* "Missing active connection" */);
|
|
165
162
|
return this._checkpointSequenceNumber !== undefined;
|
|
166
163
|
}
|
|
167
164
|
// Forwarding connection manager properties / IDeltaManager implementation
|
|
@@ -185,7 +182,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
185
182
|
}
|
|
186
183
|
submit(type, contents, batch = false, metadata, compression, referenceSequenceNumber) {
|
|
187
184
|
// Back-compat ADO:3455
|
|
188
|
-
const backCompatRefSeqNum = referenceSequenceNumber
|
|
185
|
+
const backCompatRefSeqNum = referenceSequenceNumber ?? this.lastProcessedSequenceNumber;
|
|
189
186
|
const messagePartial = {
|
|
190
187
|
contents,
|
|
191
188
|
metadata,
|
|
@@ -200,7 +197,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
200
197
|
if (message === undefined) {
|
|
201
198
|
return -1;
|
|
202
199
|
}
|
|
203
|
-
(0,
|
|
200
|
+
(0, core_utils_1.assert)(isClientMessage(message), 0x419 /* client sends non-client message */);
|
|
204
201
|
if (contents !== undefined) {
|
|
205
202
|
this.opsSize += contents.length;
|
|
206
203
|
}
|
|
@@ -218,7 +215,6 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
218
215
|
return this.connectionManager.submitSignal(content);
|
|
219
216
|
}
|
|
220
217
|
flush() {
|
|
221
|
-
var _a, _b, _c;
|
|
222
218
|
const batch = this.messageBuffer;
|
|
223
219
|
if (batch.length === 0) {
|
|
224
220
|
return;
|
|
@@ -227,17 +223,22 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
227
223
|
// The prepareFlush event allows listeners to append metadata to the batch prior to submission.
|
|
228
224
|
this.emit("prepareSend", batch);
|
|
229
225
|
if (batch.length === 1) {
|
|
230
|
-
(0,
|
|
226
|
+
(0, core_utils_1.assert)(batch[0].metadata?.batch === undefined, 0x3c9 /* no batch markup on single message */);
|
|
231
227
|
}
|
|
232
228
|
else {
|
|
233
|
-
(0,
|
|
234
|
-
(0,
|
|
229
|
+
(0, core_utils_1.assert)(batch[0].metadata?.batch === true, 0x3ca /* no start batch markup */);
|
|
230
|
+
(0, core_utils_1.assert)(batch[batch.length - 1].metadata?.batch === false, 0x3cb /* no end batch markup */);
|
|
235
231
|
}
|
|
236
232
|
this.connectionManager.sendMessages(batch);
|
|
237
|
-
(0,
|
|
233
|
+
(0, core_utils_1.assert)(this.messageBuffer.length === 0, 0x3cc /* reentrancy */);
|
|
238
234
|
}
|
|
239
235
|
get connectionProps() {
|
|
240
|
-
return
|
|
236
|
+
return {
|
|
237
|
+
sequenceNumber: this.lastSequenceNumber,
|
|
238
|
+
opsSize: this.opsSize > 0 ? this.opsSize : undefined,
|
|
239
|
+
deltaManagerState: this._disposed ? "disposed" : this._closed ? "closed" : "open",
|
|
240
|
+
...this.connectionManager.connectionProps,
|
|
241
|
+
};
|
|
241
242
|
}
|
|
242
243
|
/**
|
|
243
244
|
* Log error event with a bunch of internal to DeltaManager information about state of op processing
|
|
@@ -246,15 +247,25 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
246
247
|
* @param event - Event to log.
|
|
247
248
|
*/
|
|
248
249
|
logConnectionIssue(event) {
|
|
249
|
-
|
|
250
|
-
(0, common_utils_1.assert)(this.connectionManager.connected, 0x238 /* "called only in connected state" */);
|
|
250
|
+
(0, core_utils_1.assert)(this.connectionManager.connected, 0x238 /* "called only in connected state" */);
|
|
251
251
|
const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);
|
|
252
|
-
this.logger.sendErrorEvent(
|
|
252
|
+
this.logger.sendErrorEvent({
|
|
253
|
+
...event,
|
|
253
254
|
// This directly tells us if fetching ops is in flight, and thus likely the reason of
|
|
254
255
|
// stalled op processing
|
|
255
|
-
fetchReason: this.fetchReason,
|
|
256
|
+
fetchReason: this.fetchReason,
|
|
256
257
|
// A bunch of useful sequence numbers to understand if we are holding some ops from processing
|
|
257
|
-
lastQueuedSequenceNumber: this.lastQueuedSequenceNumber,
|
|
258
|
+
lastQueuedSequenceNumber: this.lastQueuedSequenceNumber,
|
|
259
|
+
lastProcessedSequenceNumber: this.lastProcessedSequenceNumber,
|
|
260
|
+
lastObserved: this.lastObservedSeqNumber,
|
|
261
|
+
// connection info
|
|
262
|
+
...this.connectionManager.connectionVerboseProps,
|
|
263
|
+
pendingOps: this.pending.length,
|
|
264
|
+
pendingFirst: pendingSorted[0]?.sequenceNumber,
|
|
265
|
+
haveHandler: this.handler !== undefined,
|
|
266
|
+
inboundLength: this.inbound.length,
|
|
267
|
+
inboundPaused: this.inbound.paused,
|
|
268
|
+
});
|
|
258
269
|
}
|
|
259
270
|
cancelEstablishingConnection(reason) {
|
|
260
271
|
this.emit("cancelEstablishingConnection", reason);
|
|
@@ -277,7 +288,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
277
288
|
// but it's safe to assume (until better design is put into place) that batches should not exist
|
|
278
289
|
// across multiple connections. Right now we assume runtime will not submit any ops in disconnected
|
|
279
290
|
// state. As requirements change, so should these checks.
|
|
280
|
-
(0,
|
|
291
|
+
(0, core_utils_1.assert)(this.messageBuffer.length === 0, 0x0e9 /* "messageBuffer is not empty on new connection" */);
|
|
281
292
|
this.opsSize = 0;
|
|
282
293
|
this.noOpCount = 0;
|
|
283
294
|
this.emit("connect", connection, checkpointSequenceNumber !== undefined
|
|
@@ -308,16 +319,16 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
308
319
|
this.lastQueuedSequenceNumber = sequenceNumber;
|
|
309
320
|
this.lastObservedSeqNumber = sequenceNumber;
|
|
310
321
|
// We will use same check in other places to make sure all the seq number above are set properly.
|
|
311
|
-
(0,
|
|
322
|
+
(0, core_utils_1.assert)(this.handler === undefined, 0x0e2 /* "DeltaManager already has attached op handler!" */);
|
|
312
323
|
this.handler = handler;
|
|
313
324
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
314
|
-
(0,
|
|
325
|
+
(0, core_utils_1.assert)(!!this.handler, 0x0e3 /* "Newly set op handler is null/undefined!" */);
|
|
315
326
|
// There should be no pending fetch!
|
|
316
327
|
// This API is called right after attachOpHandler by Container.load().
|
|
317
328
|
// We might have connection already and it might have called fetchMissingDeltas() from
|
|
318
329
|
// setupNewSuccessfulConnection. But it should do nothing, because there is no way to fetch ops before
|
|
319
330
|
// we know snapshot sequence number that is set in attachOpHandler. So all such calls should be noop.
|
|
320
|
-
(0,
|
|
331
|
+
(0, core_utils_1.assert)(this.fetchReason === undefined, 0x268 /* "There can't be pending fetch that early in boot sequence!" */);
|
|
321
332
|
if (this._closed) {
|
|
322
333
|
return;
|
|
323
334
|
}
|
|
@@ -336,11 +347,10 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
336
347
|
}
|
|
337
348
|
}
|
|
338
349
|
// Ensure there is no need to call this.processPendingOps() at the end of boot sequence
|
|
339
|
-
(0,
|
|
350
|
+
(0, core_utils_1.assert)(this.fetchReason !== undefined || this.pending.length === 0, 0x269 /* "pending ops are not dropped" */);
|
|
340
351
|
}
|
|
341
352
|
connect(args) {
|
|
342
|
-
|
|
343
|
-
const fetchOpsFromStorage = (_a = args.fetchOpsFromStorage) !== null && _a !== void 0 ? _a : true;
|
|
353
|
+
const fetchOpsFromStorage = args.fetchOpsFromStorage ?? true;
|
|
344
354
|
(0, telemetry_utils_1.logIfFalse)(this.handler !== undefined || !fetchOpsFromStorage, this.logger, "CantFetchWithoutBaseline"); // can't fetch if no baseline
|
|
345
355
|
// Note: There is race condition here.
|
|
346
356
|
// We want to issue request to storage as soon as possible, to
|
|
@@ -353,7 +363,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
353
363
|
// on the wire, we might be always behind.
|
|
354
364
|
// See comment at the end of "connect" handler
|
|
355
365
|
if (fetchOpsFromStorage) {
|
|
356
|
-
this.fetchMissingDeltas(args.reason);
|
|
366
|
+
this.fetchMissingDeltas(args.reason.text);
|
|
357
367
|
}
|
|
358
368
|
this.connectionManager.connect(args.reason, args.mode);
|
|
359
369
|
}
|
|
@@ -373,8 +383,14 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
373
383
|
// It is possible that due to asynchrony (including await above), required ops were already
|
|
374
384
|
// received through delta stream. Validate that before moving forward.
|
|
375
385
|
if (this.lastQueuedSequenceNumber >= lastExpectedOp) {
|
|
376
|
-
this.logger.sendPerformanceEvent(
|
|
377
|
-
|
|
386
|
+
this.logger.sendPerformanceEvent({
|
|
387
|
+
reason: fetchReason,
|
|
388
|
+
eventName: "ExtraStorageCall",
|
|
389
|
+
early: true,
|
|
390
|
+
from,
|
|
391
|
+
to,
|
|
392
|
+
...this.connectionManager.connectionVerboseProps,
|
|
393
|
+
});
|
|
378
394
|
return;
|
|
379
395
|
}
|
|
380
396
|
// Be prepared for the case where webSocket would receive the ops that we are trying to fill through
|
|
@@ -391,22 +407,25 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
391
407
|
// That said, if we have socket connection, make sure we got ops up to checkpointSequenceNumber!
|
|
392
408
|
cancelFetch = (op) => op.sequenceNumber >= this.lastObservedSeqNumber;
|
|
393
409
|
}
|
|
394
|
-
const controller = new
|
|
410
|
+
const controller = new AbortController();
|
|
395
411
|
let opsFromFetch = false;
|
|
396
412
|
const opListener = (op) => {
|
|
397
|
-
(0,
|
|
413
|
+
(0, core_utils_1.assert)(op.sequenceNumber === this.lastQueuedSequenceNumber, 0x23a /* "seq#'s" */);
|
|
398
414
|
// Ops that are coming from this request should not cancel itself.
|
|
399
415
|
// This is useless for known ranges (to is defined) as it means request is over either way.
|
|
400
416
|
// And it will cancel unbound request too early, not allowing us to learn where the end of the file is.
|
|
401
417
|
if (!opsFromFetch && cancelFetch(op)) {
|
|
402
|
-
|
|
418
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
419
|
+
controller.abort("DeltaManager getDeltas fetch cancelled");
|
|
403
420
|
this._inbound.off("push", opListener);
|
|
404
421
|
}
|
|
405
422
|
};
|
|
406
423
|
try {
|
|
407
424
|
this._inbound.on("push", opListener);
|
|
408
|
-
(0,
|
|
409
|
-
this.closeAbortController.signal.onabort = () =>
|
|
425
|
+
(0, core_utils_1.assert)(this.closeAbortController.signal.onabort === null, 0x1e8 /* "reentrancy" */);
|
|
426
|
+
this.closeAbortController.signal.onabort = () =>
|
|
427
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
428
|
+
controller.abort(this.closeAbortController.signal.reason);
|
|
410
429
|
const stream = this.deltaStorage.fetchMessages(from, // inclusive
|
|
411
430
|
to, // exclusive
|
|
412
431
|
controller.signal, cacheOnly, fetchReason);
|
|
@@ -426,9 +445,17 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
426
445
|
}
|
|
427
446
|
}
|
|
428
447
|
finally {
|
|
448
|
+
if (controller.signal.aborted) {
|
|
449
|
+
this.logger.sendTelemetryEvent({
|
|
450
|
+
eventName: "DeltaManager_GetDeltasAborted",
|
|
451
|
+
fetchReason,
|
|
452
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
453
|
+
reason: controller.signal.reason,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
429
456
|
this.closeAbortController.signal.onabort = null;
|
|
430
457
|
this._inbound.off("push", opListener);
|
|
431
|
-
(0,
|
|
458
|
+
(0, core_utils_1.assert)(!opsFromFetch, 0x289 /* "logic error" */);
|
|
432
459
|
}
|
|
433
460
|
}
|
|
434
461
|
/**
|
|
@@ -461,7 +488,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
461
488
|
return;
|
|
462
489
|
}
|
|
463
490
|
if (error !== undefined && !(0, telemetry_utils_1.isFluidError)(error)) {
|
|
464
|
-
throw new
|
|
491
|
+
throw new telemetry_utils_1.UsageError("Error must be a Fluid error");
|
|
465
492
|
}
|
|
466
493
|
this._disposed = true;
|
|
467
494
|
this._closed = true; // We consider "disposed" as a further state than "closed"
|
|
@@ -473,7 +500,8 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
473
500
|
this.removeAllListeners();
|
|
474
501
|
}
|
|
475
502
|
clearQueues() {
|
|
476
|
-
|
|
503
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
504
|
+
this.closeAbortController.abort("DeltaManager is closed");
|
|
477
505
|
this._inbound.clear();
|
|
478
506
|
this._inboundSignal.clear();
|
|
479
507
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
@@ -489,9 +517,9 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
489
517
|
this.timeTillThrottling = 0;
|
|
490
518
|
}
|
|
491
519
|
}
|
|
492
|
-
disconnectHandler(reason
|
|
520
|
+
disconnectHandler(reason) {
|
|
493
521
|
this.messageBuffer.length = 0;
|
|
494
|
-
this.emit("disconnect", reason
|
|
522
|
+
this.emit("disconnect", reason);
|
|
495
523
|
}
|
|
496
524
|
/**
|
|
497
525
|
* Emit info about a delay in service communication on account of throttling.
|
|
@@ -504,7 +532,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
504
532
|
this.throttlingIdSet.add(id);
|
|
505
533
|
if (delayMs > 0 && timeNow + delayMs > this.timeTillThrottling) {
|
|
506
534
|
this.timeTillThrottling = timeNow + delayMs;
|
|
507
|
-
const throttlingWarning =
|
|
535
|
+
const throttlingWarning = error_1.ThrottlingWarning.wrap(error, delayMs / 1000 /* retryAfterSeconds */, this.logger);
|
|
508
536
|
this.emit("throttled", throttlingWarning);
|
|
509
537
|
}
|
|
510
538
|
}
|
|
@@ -519,7 +547,6 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
519
547
|
return `${m.clientId}-${m.type}-${m.minimumSequenceNumber}-${m.referenceSequenceNumber}-${m.timestamp}`;
|
|
520
548
|
}
|
|
521
549
|
enqueueMessages(messages, reason, allowGaps = false) {
|
|
522
|
-
var _a, _b;
|
|
523
550
|
if (this.handler === undefined) {
|
|
524
551
|
// We did not setup handler yet.
|
|
525
552
|
// This happens when we connect to web socket faster than we get attributes for container
|
|
@@ -535,7 +562,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
535
562
|
// It's responsibility of
|
|
536
563
|
// - attachOpHandler()
|
|
537
564
|
// - fetchMissingDeltas() after it's done with querying storage
|
|
538
|
-
(0,
|
|
565
|
+
(0, core_utils_1.assert)(this.pending.length === 0 || this.fetchReason !== undefined, 0x1e9 /* "Pending ops" */);
|
|
539
566
|
if (messages.length === 0) {
|
|
540
567
|
return;
|
|
541
568
|
}
|
|
@@ -582,19 +609,32 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
582
609
|
// Do not report when pending fetch is in progress, as such reporting will not
|
|
583
610
|
// correctly take into account pending ops.
|
|
584
611
|
if (eventName !== undefined) {
|
|
585
|
-
this.logger.sendPerformanceEvent(
|
|
586
|
-
|
|
612
|
+
this.logger.sendPerformanceEvent({
|
|
613
|
+
eventName,
|
|
614
|
+
reason,
|
|
615
|
+
previousReason: this.prevEnqueueMessagesReason,
|
|
616
|
+
from,
|
|
617
|
+
to: last + 1,
|
|
618
|
+
length: messages.length,
|
|
619
|
+
fetchReason: this.fetchReason,
|
|
620
|
+
duplicate: duplicate > 0 ? duplicate : undefined,
|
|
621
|
+
initialGap: initialGap !== 0 ? initialGap : undefined,
|
|
622
|
+
gap: gap > 0 ? gap : undefined,
|
|
623
|
+
firstMissing,
|
|
624
|
+
dmInitialSeqNumber: this.initialSequenceNumber,
|
|
625
|
+
...this.connectionManager.connectionVerboseProps,
|
|
626
|
+
});
|
|
587
627
|
}
|
|
588
628
|
}
|
|
589
629
|
this.updateLatestKnownOpSeqNumber(messages[messages.length - 1].sequenceNumber);
|
|
590
|
-
const n =
|
|
591
|
-
(0,
|
|
630
|
+
const n = this.previouslyProcessedMessage?.sequenceNumber;
|
|
631
|
+
(0, core_utils_1.assert)(n === undefined || n === this.lastQueuedSequenceNumber, 0x0ec /* "Unexpected value for previously processed message's sequence number" */);
|
|
592
632
|
for (const message of messages) {
|
|
593
633
|
// Check that the messages are arriving in the expected order
|
|
594
634
|
if (message.sequenceNumber <= this.lastQueuedSequenceNumber) {
|
|
595
635
|
// Validate that we do not have data loss, i.e. sequencing is reset and started again
|
|
596
636
|
// with numbers that this client already observed before.
|
|
597
|
-
if (
|
|
637
|
+
if (this.previouslyProcessedMessage?.sequenceNumber === message.sequenceNumber) {
|
|
598
638
|
const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);
|
|
599
639
|
const message2 = this.comparableMessagePayload(message);
|
|
600
640
|
if (message1 !== message2) {
|
|
@@ -607,7 +647,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
607
647
|
// instances such that the same sequence number is reused for two different ops.
|
|
608
648
|
// pre-0.58 error message: twoMessagesWithSameSeqNumAndDifferentPayload
|
|
609
649
|
"Found two messages with the same sequenceNumber but different payloads. Likely to be a " +
|
|
610
|
-
"service issue", driver_definitions_1.
|
|
650
|
+
"service issue", driver_definitions_1.DriverErrorTypes.fileOverwrittenInStorage, {
|
|
611
651
|
clientId: this.connectionManager.clientId,
|
|
612
652
|
sequenceNumber: message.sequenceNumber,
|
|
613
653
|
message1,
|
|
@@ -635,17 +675,20 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
635
675
|
}
|
|
636
676
|
processInboundMessage(message) {
|
|
637
677
|
const startTime = Date.now();
|
|
638
|
-
(0,
|
|
678
|
+
(0, core_utils_1.assert)(!this.currentlyProcessingOps, 0x3af /* Already processing ops. */);
|
|
639
679
|
this.currentlyProcessingOps = true;
|
|
640
680
|
this.lastProcessedMessage = message;
|
|
641
681
|
const isString = typeof message.clientId === "string";
|
|
642
|
-
(0,
|
|
682
|
+
(0, core_utils_1.assert)(message.clientId === null || isString, 0x41a /* undefined or string */);
|
|
643
683
|
// All client messages are coming from some client, and should have clientId,
|
|
644
684
|
// and non-client message should not have clientId. But, there are two exceptions:
|
|
645
685
|
// 1. (Legacy) We can see message.type === "attach" or "chunkedOp" for legacy files before RTM
|
|
646
686
|
// 2. Non-immediate noops (contents: null) can be sent by service without clientId
|
|
647
687
|
if (!isString && isClientMessage(message) && message.type !== protocol_definitions_1.MessageType.NoOp) {
|
|
648
|
-
throw new
|
|
688
|
+
throw new telemetry_utils_1.DataCorruptionError("Mismatch in clientId", {
|
|
689
|
+
...(0, telemetry_utils_1.extractSafePropertiesFromMessage)(message),
|
|
690
|
+
messageType: message.type,
|
|
691
|
+
});
|
|
649
692
|
}
|
|
650
693
|
// TODO Remove after SPO picks up the latest build.
|
|
651
694
|
if (typeof message.contents === "string" &&
|
|
@@ -671,23 +714,29 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
671
714
|
// Watch the minimum sequence number and be ready to update as needed
|
|
672
715
|
if (this.minSequenceNumber > message.minimumSequenceNumber) {
|
|
673
716
|
// pre-0.58 error message: msnMovesBackwards
|
|
674
|
-
throw new
|
|
717
|
+
throw new telemetry_utils_1.DataCorruptionError("Found a lower minimumSequenceNumber (msn) than previously recorded", {
|
|
718
|
+
...(0, telemetry_utils_1.extractSafePropertiesFromMessage)(message),
|
|
719
|
+
clientId: this.connectionManager.clientId,
|
|
720
|
+
});
|
|
675
721
|
}
|
|
676
722
|
// Client ops: MSN has to be lower than sequence #, as client can continue to send ops with same
|
|
677
723
|
// reference sequence number as this op.
|
|
678
724
|
// System ops (when no clients are connected) are the only ops where equation is possible.
|
|
679
725
|
const diff = message.sequenceNumber - message.minimumSequenceNumber;
|
|
680
726
|
if (diff < 0 || (diff === 0 && message.clientId !== null)) {
|
|
681
|
-
throw new
|
|
727
|
+
throw new telemetry_utils_1.DataCorruptionError("MSN has to be lower than sequence #", (0, telemetry_utils_1.extractSafePropertiesFromMessage)(message));
|
|
682
728
|
}
|
|
683
729
|
this.minSequenceNumber = message.minimumSequenceNumber;
|
|
684
730
|
if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {
|
|
685
731
|
// pre-0.58 error message: nonSequentialSequenceNumber
|
|
686
|
-
throw new
|
|
732
|
+
throw new telemetry_utils_1.DataCorruptionError("Found a non-Sequential sequenceNumber", {
|
|
733
|
+
...(0, telemetry_utils_1.extractSafePropertiesFromMessage)(message),
|
|
734
|
+
clientId: this.connectionManager.clientId,
|
|
735
|
+
});
|
|
687
736
|
}
|
|
688
737
|
this.lastProcessedSequenceNumber = message.sequenceNumber;
|
|
689
738
|
// a bunch of code assumes that this is true
|
|
690
|
-
(0,
|
|
739
|
+
(0, core_utils_1.assert)(this.lastProcessedSequenceNumber <= this.lastObservedSeqNumber, 0x267 /* "lastObservedSeqNumber should be updated first" */);
|
|
691
740
|
// Back-compat for older server with no term
|
|
692
741
|
if (message.term === undefined) {
|
|
693
742
|
message.term = protocol_1.OnlyValidTermValue;
|
|
@@ -714,7 +763,6 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
714
763
|
* Retrieves the missing deltas between the given sequence numbers
|
|
715
764
|
*/
|
|
716
765
|
async fetchMissingDeltasCore(reason, cacheOnly, to) {
|
|
717
|
-
var _a;
|
|
718
766
|
// Exit out early if we're already fetching deltas
|
|
719
767
|
if (this.fetchReason !== undefined) {
|
|
720
768
|
return;
|
|
@@ -728,20 +776,20 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
728
776
|
}
|
|
729
777
|
if (this.handler === undefined) {
|
|
730
778
|
// We do not poses yet any information
|
|
731
|
-
(0,
|
|
779
|
+
(0, core_utils_1.assert)(this.lastQueuedSequenceNumber === 0, 0x26b /* "initial state" */);
|
|
732
780
|
return;
|
|
733
781
|
}
|
|
734
782
|
try {
|
|
735
783
|
let from = this.lastQueuedSequenceNumber + 1;
|
|
736
|
-
const n =
|
|
784
|
+
const n = this.previouslyProcessedMessage?.sequenceNumber;
|
|
737
785
|
if (n !== undefined) {
|
|
738
786
|
// If we already processed at least one op, then we have this.previouslyProcessedMessage populated
|
|
739
787
|
// and can use it to validate that we are operating on same file, i.e. it was not overwritten.
|
|
740
788
|
// Knowing about this mechanism, we could ask for op we already observed to increase validation.
|
|
741
789
|
// This is especially useful when coming out of offline mode or loading from
|
|
742
790
|
// very old cached (by client / driver) snapshot.
|
|
743
|
-
(0,
|
|
744
|
-
(0,
|
|
791
|
+
(0, core_utils_1.assert)(n === this.lastQueuedSequenceNumber, 0x0f2 /* "previouslyProcessedMessage" */);
|
|
792
|
+
(0, core_utils_1.assert)(from > 1, 0x0f3 /* "not positive" */);
|
|
745
793
|
from--;
|
|
746
794
|
}
|
|
747
795
|
const fetchReason = `${reason}_fetch`;
|
|
@@ -768,7 +816,7 @@ class DeltaManager extends common_utils_1.TypedEventEmitter {
|
|
|
768
816
|
if (this._closed) {
|
|
769
817
|
return;
|
|
770
818
|
}
|
|
771
|
-
(0,
|
|
819
|
+
(0, core_utils_1.assert)(this.handler !== undefined, 0x26c /* "handler should be installed" */);
|
|
772
820
|
const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);
|
|
773
821
|
this.pending = [];
|
|
774
822
|
// Given that we do not track where these ops came from any more, it's not very
|