@fluidframework/container-loader 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191457
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/lib/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/lib/deltaManager.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { default as AbortController } from "abort-controller";
|
|
6
5
|
import { v4 as uuid } from "uuid";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils";
|
|
8
|
+
import { DataProcessingError, extractSafePropertiesFromMessage, normalizeError, logIfFalse, safeRaiseEvent, isFluidError, DataCorruptionError, UsageError, } from "@fluidframework/telemetry-utils";
|
|
9
|
+
import { DriverErrorTypes, } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { MessageType, } from "@fluidframework/protocol-definitions";
|
|
11
11
|
import { NonRetryableError, isRuntimeMessage, MessageType2 } from "@fluidframework/driver-utils";
|
|
12
|
-
import { ThrottlingWarning, DataCorruptionError, extractSafePropertiesFromMessage, DataProcessingError, UsageError, } from "@fluidframework/container-utils";
|
|
13
12
|
import { DeltaQueue } from "./deltaQueue";
|
|
14
13
|
import { OnlyValidTermValue } from "./protocol";
|
|
14
|
+
import { ThrottlingWarning } from "./error";
|
|
15
15
|
/**
|
|
16
16
|
* Determines if message was sent by client, not service
|
|
17
17
|
*/
|
|
@@ -88,7 +88,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
88
88
|
signalHandler: (message) => this._inboundSignal.push(message),
|
|
89
89
|
reconnectionDelayHandler: (delayMs, error) => this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),
|
|
90
90
|
closeHandler: (error) => this.close(error),
|
|
91
|
-
disconnectHandler: (reason
|
|
91
|
+
disconnectHandler: (reason) => this.disconnectHandler(reason),
|
|
92
92
|
connectHandler: (connection) => this.connectHandler(connection),
|
|
93
93
|
pongHandler: (latency) => this.emit("pong", latency),
|
|
94
94
|
readonlyChangeHandler: (readonly) => safeRaiseEvent(this, this.logger, "readonly", readonly),
|
|
@@ -179,7 +179,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
179
179
|
}
|
|
180
180
|
submit(type, contents, batch = false, metadata, compression, referenceSequenceNumber) {
|
|
181
181
|
// Back-compat ADO:3455
|
|
182
|
-
const backCompatRefSeqNum = referenceSequenceNumber
|
|
182
|
+
const backCompatRefSeqNum = referenceSequenceNumber ?? this.lastProcessedSequenceNumber;
|
|
183
183
|
const messagePartial = {
|
|
184
184
|
contents,
|
|
185
185
|
metadata,
|
|
@@ -212,7 +212,6 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
212
212
|
return this.connectionManager.submitSignal(content);
|
|
213
213
|
}
|
|
214
214
|
flush() {
|
|
215
|
-
var _a, _b, _c;
|
|
216
215
|
const batch = this.messageBuffer;
|
|
217
216
|
if (batch.length === 0) {
|
|
218
217
|
return;
|
|
@@ -221,17 +220,22 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
221
220
|
// The prepareFlush event allows listeners to append metadata to the batch prior to submission.
|
|
222
221
|
this.emit("prepareSend", batch);
|
|
223
222
|
if (batch.length === 1) {
|
|
224
|
-
assert(
|
|
223
|
+
assert(batch[0].metadata?.batch === undefined, 0x3c9 /* no batch markup on single message */);
|
|
225
224
|
}
|
|
226
225
|
else {
|
|
227
|
-
assert(
|
|
228
|
-
assert(
|
|
226
|
+
assert(batch[0].metadata?.batch === true, 0x3ca /* no start batch markup */);
|
|
227
|
+
assert(batch[batch.length - 1].metadata?.batch === false, 0x3cb /* no end batch markup */);
|
|
229
228
|
}
|
|
230
229
|
this.connectionManager.sendMessages(batch);
|
|
231
230
|
assert(this.messageBuffer.length === 0, 0x3cc /* reentrancy */);
|
|
232
231
|
}
|
|
233
232
|
get connectionProps() {
|
|
234
|
-
return
|
|
233
|
+
return {
|
|
234
|
+
sequenceNumber: this.lastSequenceNumber,
|
|
235
|
+
opsSize: this.opsSize > 0 ? this.opsSize : undefined,
|
|
236
|
+
deltaManagerState: this._disposed ? "disposed" : this._closed ? "closed" : "open",
|
|
237
|
+
...this.connectionManager.connectionProps,
|
|
238
|
+
};
|
|
235
239
|
}
|
|
236
240
|
/**
|
|
237
241
|
* Log error event with a bunch of internal to DeltaManager information about state of op processing
|
|
@@ -240,15 +244,25 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
240
244
|
* @param event - Event to log.
|
|
241
245
|
*/
|
|
242
246
|
logConnectionIssue(event) {
|
|
243
|
-
var _a;
|
|
244
247
|
assert(this.connectionManager.connected, 0x238 /* "called only in connected state" */);
|
|
245
248
|
const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);
|
|
246
|
-
this.logger.sendErrorEvent(
|
|
249
|
+
this.logger.sendErrorEvent({
|
|
250
|
+
...event,
|
|
247
251
|
// This directly tells us if fetching ops is in flight, and thus likely the reason of
|
|
248
252
|
// stalled op processing
|
|
249
|
-
fetchReason: this.fetchReason,
|
|
253
|
+
fetchReason: this.fetchReason,
|
|
250
254
|
// A bunch of useful sequence numbers to understand if we are holding some ops from processing
|
|
251
|
-
lastQueuedSequenceNumber: this.lastQueuedSequenceNumber,
|
|
255
|
+
lastQueuedSequenceNumber: this.lastQueuedSequenceNumber,
|
|
256
|
+
lastProcessedSequenceNumber: this.lastProcessedSequenceNumber,
|
|
257
|
+
lastObserved: this.lastObservedSeqNumber,
|
|
258
|
+
// connection info
|
|
259
|
+
...this.connectionManager.connectionVerboseProps,
|
|
260
|
+
pendingOps: this.pending.length,
|
|
261
|
+
pendingFirst: pendingSorted[0]?.sequenceNumber,
|
|
262
|
+
haveHandler: this.handler !== undefined,
|
|
263
|
+
inboundLength: this.inbound.length,
|
|
264
|
+
inboundPaused: this.inbound.paused,
|
|
265
|
+
});
|
|
252
266
|
}
|
|
253
267
|
cancelEstablishingConnection(reason) {
|
|
254
268
|
this.emit("cancelEstablishingConnection", reason);
|
|
@@ -333,8 +347,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
333
347
|
assert(this.fetchReason !== undefined || this.pending.length === 0, 0x269 /* "pending ops are not dropped" */);
|
|
334
348
|
}
|
|
335
349
|
connect(args) {
|
|
336
|
-
|
|
337
|
-
const fetchOpsFromStorage = (_a = args.fetchOpsFromStorage) !== null && _a !== void 0 ? _a : true;
|
|
350
|
+
const fetchOpsFromStorage = args.fetchOpsFromStorage ?? true;
|
|
338
351
|
logIfFalse(this.handler !== undefined || !fetchOpsFromStorage, this.logger, "CantFetchWithoutBaseline"); // can't fetch if no baseline
|
|
339
352
|
// Note: There is race condition here.
|
|
340
353
|
// We want to issue request to storage as soon as possible, to
|
|
@@ -347,7 +360,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
347
360
|
// on the wire, we might be always behind.
|
|
348
361
|
// See comment at the end of "connect" handler
|
|
349
362
|
if (fetchOpsFromStorage) {
|
|
350
|
-
this.fetchMissingDeltas(args.reason);
|
|
363
|
+
this.fetchMissingDeltas(args.reason.text);
|
|
351
364
|
}
|
|
352
365
|
this.connectionManager.connect(args.reason, args.mode);
|
|
353
366
|
}
|
|
@@ -367,8 +380,14 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
367
380
|
// It is possible that due to asynchrony (including await above), required ops were already
|
|
368
381
|
// received through delta stream. Validate that before moving forward.
|
|
369
382
|
if (this.lastQueuedSequenceNumber >= lastExpectedOp) {
|
|
370
|
-
this.logger.sendPerformanceEvent(
|
|
371
|
-
|
|
383
|
+
this.logger.sendPerformanceEvent({
|
|
384
|
+
reason: fetchReason,
|
|
385
|
+
eventName: "ExtraStorageCall",
|
|
386
|
+
early: true,
|
|
387
|
+
from,
|
|
388
|
+
to,
|
|
389
|
+
...this.connectionManager.connectionVerboseProps,
|
|
390
|
+
});
|
|
372
391
|
return;
|
|
373
392
|
}
|
|
374
393
|
// Be prepared for the case where webSocket would receive the ops that we are trying to fill through
|
|
@@ -393,14 +412,17 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
393
412
|
// This is useless for known ranges (to is defined) as it means request is over either way.
|
|
394
413
|
// And it will cancel unbound request too early, not allowing us to learn where the end of the file is.
|
|
395
414
|
if (!opsFromFetch && cancelFetch(op)) {
|
|
396
|
-
|
|
415
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
416
|
+
controller.abort("DeltaManager getDeltas fetch cancelled");
|
|
397
417
|
this._inbound.off("push", opListener);
|
|
398
418
|
}
|
|
399
419
|
};
|
|
400
420
|
try {
|
|
401
421
|
this._inbound.on("push", opListener);
|
|
402
422
|
assert(this.closeAbortController.signal.onabort === null, 0x1e8 /* "reentrancy" */);
|
|
403
|
-
this.closeAbortController.signal.onabort = () =>
|
|
423
|
+
this.closeAbortController.signal.onabort = () =>
|
|
424
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
425
|
+
controller.abort(this.closeAbortController.signal.reason);
|
|
404
426
|
const stream = this.deltaStorage.fetchMessages(from, // inclusive
|
|
405
427
|
to, // exclusive
|
|
406
428
|
controller.signal, cacheOnly, fetchReason);
|
|
@@ -420,6 +442,14 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
420
442
|
}
|
|
421
443
|
}
|
|
422
444
|
finally {
|
|
445
|
+
if (controller.signal.aborted) {
|
|
446
|
+
this.logger.sendTelemetryEvent({
|
|
447
|
+
eventName: "DeltaManager_GetDeltasAborted",
|
|
448
|
+
fetchReason,
|
|
449
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
450
|
+
reason: controller.signal.reason,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
423
453
|
this.closeAbortController.signal.onabort = null;
|
|
424
454
|
this._inbound.off("push", opListener);
|
|
425
455
|
assert(!opsFromFetch, 0x289 /* "logic error" */);
|
|
@@ -467,7 +497,8 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
467
497
|
this.removeAllListeners();
|
|
468
498
|
}
|
|
469
499
|
clearQueues() {
|
|
470
|
-
|
|
500
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
501
|
+
this.closeAbortController.abort("DeltaManager is closed");
|
|
471
502
|
this._inbound.clear();
|
|
472
503
|
this._inboundSignal.clear();
|
|
473
504
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
@@ -483,9 +514,9 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
483
514
|
this.timeTillThrottling = 0;
|
|
484
515
|
}
|
|
485
516
|
}
|
|
486
|
-
disconnectHandler(reason
|
|
517
|
+
disconnectHandler(reason) {
|
|
487
518
|
this.messageBuffer.length = 0;
|
|
488
|
-
this.emit("disconnect", reason
|
|
519
|
+
this.emit("disconnect", reason);
|
|
489
520
|
}
|
|
490
521
|
/**
|
|
491
522
|
* Emit info about a delay in service communication on account of throttling.
|
|
@@ -513,7 +544,6 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
513
544
|
return `${m.clientId}-${m.type}-${m.minimumSequenceNumber}-${m.referenceSequenceNumber}-${m.timestamp}`;
|
|
514
545
|
}
|
|
515
546
|
enqueueMessages(messages, reason, allowGaps = false) {
|
|
516
|
-
var _a, _b;
|
|
517
547
|
if (this.handler === undefined) {
|
|
518
548
|
// We did not setup handler yet.
|
|
519
549
|
// This happens when we connect to web socket faster than we get attributes for container
|
|
@@ -576,19 +606,32 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
576
606
|
// Do not report when pending fetch is in progress, as such reporting will not
|
|
577
607
|
// correctly take into account pending ops.
|
|
578
608
|
if (eventName !== undefined) {
|
|
579
|
-
this.logger.sendPerformanceEvent(
|
|
580
|
-
|
|
609
|
+
this.logger.sendPerformanceEvent({
|
|
610
|
+
eventName,
|
|
611
|
+
reason,
|
|
612
|
+
previousReason: this.prevEnqueueMessagesReason,
|
|
613
|
+
from,
|
|
614
|
+
to: last + 1,
|
|
615
|
+
length: messages.length,
|
|
616
|
+
fetchReason: this.fetchReason,
|
|
617
|
+
duplicate: duplicate > 0 ? duplicate : undefined,
|
|
618
|
+
initialGap: initialGap !== 0 ? initialGap : undefined,
|
|
619
|
+
gap: gap > 0 ? gap : undefined,
|
|
620
|
+
firstMissing,
|
|
621
|
+
dmInitialSeqNumber: this.initialSequenceNumber,
|
|
622
|
+
...this.connectionManager.connectionVerboseProps,
|
|
623
|
+
});
|
|
581
624
|
}
|
|
582
625
|
}
|
|
583
626
|
this.updateLatestKnownOpSeqNumber(messages[messages.length - 1].sequenceNumber);
|
|
584
|
-
const n =
|
|
627
|
+
const n = this.previouslyProcessedMessage?.sequenceNumber;
|
|
585
628
|
assert(n === undefined || n === this.lastQueuedSequenceNumber, 0x0ec /* "Unexpected value for previously processed message's sequence number" */);
|
|
586
629
|
for (const message of messages) {
|
|
587
630
|
// Check that the messages are arriving in the expected order
|
|
588
631
|
if (message.sequenceNumber <= this.lastQueuedSequenceNumber) {
|
|
589
632
|
// Validate that we do not have data loss, i.e. sequencing is reset and started again
|
|
590
633
|
// with numbers that this client already observed before.
|
|
591
|
-
if (
|
|
634
|
+
if (this.previouslyProcessedMessage?.sequenceNumber === message.sequenceNumber) {
|
|
592
635
|
const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);
|
|
593
636
|
const message2 = this.comparableMessagePayload(message);
|
|
594
637
|
if (message1 !== message2) {
|
|
@@ -601,7 +644,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
601
644
|
// instances such that the same sequence number is reused for two different ops.
|
|
602
645
|
// pre-0.58 error message: twoMessagesWithSameSeqNumAndDifferentPayload
|
|
603
646
|
"Found two messages with the same sequenceNumber but different payloads. Likely to be a " +
|
|
604
|
-
"service issue",
|
|
647
|
+
"service issue", DriverErrorTypes.fileOverwrittenInStorage, {
|
|
605
648
|
clientId: this.connectionManager.clientId,
|
|
606
649
|
sequenceNumber: message.sequenceNumber,
|
|
607
650
|
message1,
|
|
@@ -639,7 +682,10 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
639
682
|
// 1. (Legacy) We can see message.type === "attach" or "chunkedOp" for legacy files before RTM
|
|
640
683
|
// 2. Non-immediate noops (contents: null) can be sent by service without clientId
|
|
641
684
|
if (!isString && isClientMessage(message) && message.type !== MessageType.NoOp) {
|
|
642
|
-
throw new DataCorruptionError("Mismatch in clientId",
|
|
685
|
+
throw new DataCorruptionError("Mismatch in clientId", {
|
|
686
|
+
...extractSafePropertiesFromMessage(message),
|
|
687
|
+
messageType: message.type,
|
|
688
|
+
});
|
|
643
689
|
}
|
|
644
690
|
// TODO Remove after SPO picks up the latest build.
|
|
645
691
|
if (typeof message.contents === "string" &&
|
|
@@ -665,7 +711,10 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
665
711
|
// Watch the minimum sequence number and be ready to update as needed
|
|
666
712
|
if (this.minSequenceNumber > message.minimumSequenceNumber) {
|
|
667
713
|
// pre-0.58 error message: msnMovesBackwards
|
|
668
|
-
throw new DataCorruptionError("Found a lower minimumSequenceNumber (msn) than previously recorded",
|
|
714
|
+
throw new DataCorruptionError("Found a lower minimumSequenceNumber (msn) than previously recorded", {
|
|
715
|
+
...extractSafePropertiesFromMessage(message),
|
|
716
|
+
clientId: this.connectionManager.clientId,
|
|
717
|
+
});
|
|
669
718
|
}
|
|
670
719
|
// Client ops: MSN has to be lower than sequence #, as client can continue to send ops with same
|
|
671
720
|
// reference sequence number as this op.
|
|
@@ -677,7 +726,10 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
677
726
|
this.minSequenceNumber = message.minimumSequenceNumber;
|
|
678
727
|
if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {
|
|
679
728
|
// pre-0.58 error message: nonSequentialSequenceNumber
|
|
680
|
-
throw new DataCorruptionError("Found a non-Sequential sequenceNumber",
|
|
729
|
+
throw new DataCorruptionError("Found a non-Sequential sequenceNumber", {
|
|
730
|
+
...extractSafePropertiesFromMessage(message),
|
|
731
|
+
clientId: this.connectionManager.clientId,
|
|
732
|
+
});
|
|
681
733
|
}
|
|
682
734
|
this.lastProcessedSequenceNumber = message.sequenceNumber;
|
|
683
735
|
// a bunch of code assumes that this is true
|
|
@@ -708,7 +760,6 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
708
760
|
* Retrieves the missing deltas between the given sequence numbers
|
|
709
761
|
*/
|
|
710
762
|
async fetchMissingDeltasCore(reason, cacheOnly, to) {
|
|
711
|
-
var _a;
|
|
712
763
|
// Exit out early if we're already fetching deltas
|
|
713
764
|
if (this.fetchReason !== undefined) {
|
|
714
765
|
return;
|
|
@@ -727,7 +778,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
727
778
|
}
|
|
728
779
|
try {
|
|
729
780
|
let from = this.lastQueuedSequenceNumber + 1;
|
|
730
|
-
const n =
|
|
781
|
+
const n = this.previouslyProcessedMessage?.sequenceNumber;
|
|
731
782
|
if (n !== undefined) {
|
|
732
783
|
// If we already processed at least one op, then we have this.previouslyProcessedMessage populated
|
|
733
784
|
// and can use it to validate that we are operating on same file, i.e. it was not overwritten.
|