@fluidframework/driver-base 2.0.0-internal.5.4.2 → 2.0.0-internal.6.0.1
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/documentDeltaConnection.js +28 -20
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/driverUtils.js +1 -2
- package/dist/driverUtils.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/lib/documentDeltaConnection.js +28 -20
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/driverUtils.js +1 -2
- package/lib/driverUtils.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/package.json +8 -8
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @fluidframework/driver-base
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.6.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
8
|
+
|
|
9
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
10
|
+
|
|
3
11
|
## 2.0.0-internal.5.4.0
|
|
4
12
|
|
|
5
13
|
Dependency updates only.
|
|
@@ -78,9 +78,8 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
78
78
|
// Empty callback for tracking purposes in this class
|
|
79
79
|
this.trackedListeners.set("pong", () => { });
|
|
80
80
|
const sendPingLoop = () => {
|
|
81
|
-
var _a;
|
|
82
81
|
const start = Date.now();
|
|
83
|
-
|
|
82
|
+
this.socket.volatile?.emit("ping", () => {
|
|
84
83
|
this.emit("pong", Date.now() - start);
|
|
85
84
|
// Schedule another ping event in 1 minute
|
|
86
85
|
this.trackLatencyTimeout = setTimeout(() => {
|
|
@@ -268,7 +267,9 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
268
267
|
this.logger.sendTelemetryEvent({
|
|
269
268
|
eventName: "ClientClosingDeltaConnection",
|
|
270
269
|
driverVersion: packageVersion_1.pkgVersion,
|
|
271
|
-
details: JSON.stringify(
|
|
270
|
+
details: JSON.stringify({
|
|
271
|
+
...this.getConnectionDetailsProps(),
|
|
272
|
+
}),
|
|
272
273
|
});
|
|
273
274
|
this.disconnect((0, driver_utils_1.createGenericNetworkError)(
|
|
274
275
|
// pre-0.58 error message: clientClosingConnection
|
|
@@ -344,14 +345,13 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
344
345
|
}, timeout + 2000);
|
|
345
346
|
// Listen for connection issues
|
|
346
347
|
this.addConnectionListener("connect_error", (error) => {
|
|
347
|
-
var _a, _b, _c;
|
|
348
348
|
internalSocketConnectionFailureCount++;
|
|
349
349
|
let isWebSocketTransportError = false;
|
|
350
350
|
try {
|
|
351
|
-
const description = error
|
|
352
|
-
const context = error
|
|
351
|
+
const description = error?.description;
|
|
352
|
+
const context = error?.context;
|
|
353
353
|
if (context && typeof context === "object") {
|
|
354
|
-
const statusText =
|
|
354
|
+
const statusText = context.statusText?.code;
|
|
355
355
|
// Self-Signed Certificate ErrorCode Found in error.context
|
|
356
356
|
if (statusText === "DEPTH_ZERO_SELF_SIGNED_CERT") {
|
|
357
357
|
failAndCloseSocket(this.createErrorObject("connect_error", error, false));
|
|
@@ -359,7 +359,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
else if (description && typeof description === "object") {
|
|
362
|
-
const errorCode =
|
|
362
|
+
const errorCode = description.error?.code;
|
|
363
363
|
// Self-Signed Certificate ErrorCode Found in error.description
|
|
364
364
|
if (errorCode === "DEPTH_ZERO_SELF_SIGNED_CERT") {
|
|
365
365
|
failAndCloseSocket(this.createErrorObject("connect_error", error, false));
|
|
@@ -376,7 +376,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
376
376
|
// Handle socket transport downgrading when not offline.
|
|
377
377
|
if (isWebSocketTransportError &&
|
|
378
378
|
this.enableLongPollingDowngrades &&
|
|
379
|
-
|
|
379
|
+
this.socket.io.opts.transports?.[0] !== "polling") {
|
|
380
380
|
// Downgrade transports to polling upgrade mechanism.
|
|
381
381
|
this.socket.io.opts.transports = ["polling", "websocket"];
|
|
382
382
|
// Don't alter reconnection behavior if already enabled.
|
|
@@ -431,11 +431,10 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
431
431
|
// (connect_document_error / connect_document_success), as well as before DeltaManager
|
|
432
432
|
// had a chance to register its handlers.
|
|
433
433
|
this.addTrackedListener("disconnect", (reason, details) => {
|
|
434
|
-
var _a, _b;
|
|
435
434
|
failAndCloseSocket(this.createErrorObjectWithProps("disconnect", reason, {
|
|
436
|
-
socketErrorType:
|
|
435
|
+
socketErrorType: details?.context?.type,
|
|
437
436
|
// https://www.rfc-editor.org/rfc/rfc6455#section-7.4
|
|
438
|
-
socketCode:
|
|
437
|
+
socketCode: details?.context?.code,
|
|
439
438
|
}));
|
|
440
439
|
});
|
|
441
440
|
this.addTrackedListener("error", (error) => {
|
|
@@ -462,17 +461,18 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
462
461
|
addPropsToError(errorToBeNormalized) {
|
|
463
462
|
const normalizedError = (0, telemetry_utils_1.normalizeError)(errorToBeNormalized, {
|
|
464
463
|
props: {
|
|
465
|
-
details: JSON.stringify(
|
|
464
|
+
details: JSON.stringify({
|
|
465
|
+
...this.getConnectionDetailsProps(),
|
|
466
|
+
}),
|
|
466
467
|
},
|
|
467
468
|
});
|
|
468
469
|
return normalizedError;
|
|
469
470
|
}
|
|
470
471
|
getConnectionDetailsProps() {
|
|
471
|
-
var _a, _b;
|
|
472
472
|
return {
|
|
473
473
|
disposed: this._disposed,
|
|
474
|
-
socketConnected:
|
|
475
|
-
clientId:
|
|
474
|
+
socketConnected: this.socket?.connected,
|
|
475
|
+
clientId: this._details?.clientId,
|
|
476
476
|
connectionId: this.connectionId,
|
|
477
477
|
};
|
|
478
478
|
}
|
|
@@ -515,18 +515,24 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
515
515
|
this.connectionListeners.clear();
|
|
516
516
|
}
|
|
517
517
|
getErrorMessage(error) {
|
|
518
|
-
if (
|
|
518
|
+
if (error?.type !== "TransportError") {
|
|
519
519
|
return (0, telemetry_utils_1.extractLogSafeErrorProperties)(error, true).message;
|
|
520
520
|
}
|
|
521
521
|
// JSON.stringify drops Error.message
|
|
522
|
-
const messagePrefix =
|
|
522
|
+
const messagePrefix = error?.message !== undefined ? `${error.message}: ` : "";
|
|
523
523
|
// Websocket errors reported by engine.io-client.
|
|
524
524
|
// They are Error objects with description containing WS error and description = "TransportError"
|
|
525
525
|
// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,
|
|
526
526
|
return `${messagePrefix}${JSON.stringify(error, (0, telemetry_utils_1.getCircularReplacer)())}`;
|
|
527
527
|
}
|
|
528
528
|
createErrorObjectWithProps(handler, error, props, canRetry = true) {
|
|
529
|
-
return (0, driver_utils_1.createGenericNetworkError)(`socket.io (${handler}): ${this.getErrorMessage(error)}`, { canRetry },
|
|
529
|
+
return (0, driver_utils_1.createGenericNetworkError)(`socket.io (${handler}): ${this.getErrorMessage(error)}`, { canRetry }, {
|
|
530
|
+
...props,
|
|
531
|
+
driverVersion: packageVersion_1.pkgVersion,
|
|
532
|
+
details: JSON.stringify({
|
|
533
|
+
...this.getConnectionDetailsProps(),
|
|
534
|
+
}),
|
|
535
|
+
});
|
|
530
536
|
}
|
|
531
537
|
/**
|
|
532
538
|
* Error raising for socket.io issues
|
|
@@ -534,7 +540,9 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
534
540
|
createErrorObject(handler, error, canRetry = true) {
|
|
535
541
|
return (0, driver_utils_1.createGenericNetworkError)(`socket.io (${handler}): ${this.getErrorMessage(error)}`, { canRetry }, {
|
|
536
542
|
driverVersion: packageVersion_1.pkgVersion,
|
|
537
|
-
details: JSON.stringify(
|
|
543
|
+
details: JSON.stringify({
|
|
544
|
+
...this.getConnectionDetailsProps(),
|
|
545
|
+
}),
|
|
538
546
|
});
|
|
539
547
|
}
|
|
540
548
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAMtD,+DAAyE;AACzE,+EAW8C;AAE9C,qEAQyC;AAEzC,sFAAsF;AACtF,qDAA+D;AAE/D;;GAEG;AACH,MAAa,uBACZ,SAAQ,+CAA6D;IAwErE;;;;;OAKG;IACH,YACoB,MAAc,EAC1B,UAAkB,EACzB,MAA2B,EACV,8BAAuC,KAAK,EAC1C,YAAqB;QAExC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACrB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAC5B,MAAM,CAAC,cAAc,CACpB;gBACC,SAAS,EAAE,gCAAgC;gBAC3C,IAAI;aACJ,EACD,KAAK,CACL,CAAC;QACH,CAAC,CAAC,CAAC;QAfgB,WAAM,GAAN,MAAM,CAAQ;QAC1B,eAAU,GAAV,UAAU,CAAQ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,GAAG,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAA,qCAAmB,GAAE,CAAC,EAAE,CAAC;IAC1E,CAAC;IAEO,0BAA0B,CACjC,OAAe,EACf,KAAW,EACX,KAA4B,EAC5B,QAAQ,GAAG,IAAI;QAEf,OAAO,IAAA,wCAAyB,EAC/B,cAAc,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,EACxD,EAAE,QAAQ,EAAE,kCAER,KAAK,KACR,aAAa,EAAb,2BAAa,EACb,OAAO,EAAE,IAAI,CAAC,SAAS,mBACnB,IAAI,CAAC,yBAAyB,EAAE,EAClC,IAEH,CAAC;IACH,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,OAAe,EAAE,KAAW,EAAE,QAAQ,GAAG,IAAI;QACxE,OAAO,IAAA,wCAAyB,EAC/B,cAAc,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,EACxD,EAAE,QAAQ,EAAE,EACZ;YACC,aAAa,EAAb,2BAAa;YACb,OAAO,EAAE,IAAI,CAAC,SAAS,mBACnB,IAAI,CAAC,yBAAyB,EAAE,EAClC;SACF,CACD,CAAC;IACH,CAAC;;AAhsBF,0DAisBC;AA7rBgB,uCAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEnE,mHAAmH;AACnH,oHAAoH;AACpG,6CAAqB,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIAnyDriverError,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnect,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\textractLogSafeErrorProperties,\n\tgetCircularReplacer,\n\tMonitoringContext,\n\tEventEmitterWithErrorHandling,\n\tnormalizeError,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport type { Socket } from \"socket.io-client\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class DocumentDeltaConnection\n\textends EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\tstatic readonly eventsToForward = [\"nack\", \"op\", \"signal\", \"pong\"];\n\n\t// WARNING: These are critical events that we can't miss, so registration for them has to be in place at all times!\n\t// Including before handshake is over, and after that (but before DeltaManager had a chance to put its own handlers)\n\tstatic readonly eventsAlwaysForwarded = [\"disconnect\", \"error\"];\n\n\t/**\n\t * Last known sequence number to ordering service at the time of connection\n\t * It may lap actual last sequence number (quite a bit, if container is very active).\n\t * But it's best information for client to figure out how far it is behind, at least\n\t * for \"read\" connections. \"write\" connections may use own \"join\" op to similar information,\n\t * that is likely to be more up-to-date.\n\t */\n\tpublic checkpointSequenceNumber: number | undefined;\n\n\t// Listen for ops sent before we receive a response to connect_document\n\tprotected readonly queuedMessages: ISequencedDocumentMessage[] = [];\n\tprotected readonly queuedSignals: ISignalMessage[] = [];\n\n\t/**\n\t * A flag to indicate whether we have our handler attached. If it's attached, we're queueing incoming ops\n\t * to later be retrieved via initialMessages.\n\t */\n\tprivate earlyOpHandlerAttached: boolean = false;\n\n\tprivate socketConnectionTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate _details: IConnected | undefined;\n\n\tprivate trackLatencyTimeout: number | undefined;\n\n\t// Listeners only needed while the connection is in progress\n\tprivate readonly connectionListeners: Map<string, (...args: any[]) => void> = new Map();\n\t// Listeners used throughout the lifetime of the DocumentDeltaConnection\n\tprivate readonly trackedListeners: Map<string, (...args: any[]) => void> = new Map();\n\n\tprotected get hasDetails(): boolean {\n\t\treturn !!this._details;\n\t}\n\n\tpublic get disposed() {\n\t\tassert(\n\t\t\tthis._disposed || this.socket.connected,\n\t\t\t0x244 /* \"Socket is closed, but connection is not!\" */,\n\t\t);\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Flag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages.\n\t * After disconnection, we flip this to prevent any stale messages from being emitted.\n\t */\n\tprotected _disposed: boolean = false;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * @deprecated Implementors should manage their own logger or monitoring context\n\t */\n\tprotected get logger(): ITelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic get details(): IConnected {\n\t\tif (!this._details) {\n\t\t\tthrow new Error(\"Internal error: calling method before _details is initialized!\");\n\t\t}\n\t\treturn this._details;\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param logger - for reporting telemetry events\n\t * @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure\n\t */\n\tprotected constructor(\n\t\tprotected readonly socket: Socket,\n\t\tpublic documentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableLongPollingDowngrades: boolean = false,\n\t\tprotected readonly connectionId?: string,\n\t) {\n\t\tsuper((name, error) => {\n\t\t\tthis.addPropsToError(error);\n\t\t\tlogger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DeltaConnection:EventException\",\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\tthis.mc = createChildMonitoringContext({ logger, namespace: \"DeltaConnection\" });\n\n\t\tthis.on(\"newListener\", (event, _listener) => {\n\t\t\tassert(!this.disposed, 0x20a /* \"register for event on disposed object\" */);\n\n\t\t\t// Some events are already forwarded - see this.addTrackedListener() calls in initialize().\n\t\t\tif (DocumentDeltaConnection.eventsAlwaysForwarded.includes(event)) {\n\t\t\t\tassert(this.trackedListeners.has(event), 0x245 /* \"tracked listener\" */);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!DocumentDeltaConnection.eventsToForward.includes(event)) {\n\t\t\t\tthrow new Error(`DocumentDeltaConnection: Registering for unknown event: ${event}`);\n\t\t\t}\n\n\t\t\t// Whenever listener is added, we should subscribe on same event on socket, so these two things\n\t\t\t// should be in sync. This currently assumes that nobody unregisters and registers back listeners,\n\t\t\t// and that there are no \"internal\" listeners installed (like \"error\" case we skip above)\n\t\t\t// Better flow might be to always unconditionally register all handlers on successful connection,\n\t\t\t// though some logic (naming assert in initialMessages getter) might need to be adjusted (it becomes noop)\n\t\t\tassert(\n\t\t\t\t(this.listeners(event).length !== 0) === this.trackedListeners.has(event),\n\t\t\t\t0x20b /* \"mismatch\" */,\n\t\t\t);\n\t\t\tif (!this.trackedListeners.has(event)) {\n\t\t\t\tif (event === \"pong\") {\n\t\t\t\t\t// Empty callback for tracking purposes in this class\n\t\t\t\t\tthis.trackedListeners.set(\"pong\", () => {});\n\n\t\t\t\t\tconst sendPingLoop = () => {\n\t\t\t\t\t\tconst start = Date.now();\n\n\t\t\t\t\t\tthis.socket.volatile?.emit(\"ping\", () => {\n\t\t\t\t\t\t\tthis.emit(\"pong\", Date.now() - start);\n\n\t\t\t\t\t\t\t// Schedule another ping event in 1 minute\n\t\t\t\t\t\t\tthis.trackLatencyTimeout = setTimeout(() => {\n\t\t\t\t\t\t\t\tsendPingLoop();\n\t\t\t\t\t\t\t}, 1000 * 60);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\n\t\t\t\t\tsendPingLoop();\n\t\t\t\t} else {\n\t\t\t\t\tthis.addTrackedListener(event, (...args: any[]) => {\n\t\t\t\t\t\tthis.emit(event, ...args);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Get the ID of the client who is sending the message\n\t *\n\t * @returns the client ID\n\t */\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\t/**\n\t * Get the mode of the client\n\t *\n\t * @returns the client mode\n\t */\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\t/**\n\t * Get the claims of the client who is sending the message\n\t *\n\t * @returns client claims\n\t */\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\t/**\n\t * Get whether or not this is an existing document\n\t *\n\t * @returns true if the document exists\n\t */\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\t/**\n\t * Get the maximum size of a message before chunking is required\n\t *\n\t * @returns the maximum size of a message before chunking is required\n\t */\n\tpublic get maxMessageSize(): number {\n\t\treturn this.details.serviceConfiguration.maxMessageSize;\n\t}\n\n\t/**\n\t * Semver of protocol being used with the service\n\t */\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\t/**\n\t * Configuration details provided by the service\n\t */\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tprivate checkNotDisposed() {\n\t\tassert(!this.disposed, 0x20c /* \"connection disposed\" */);\n\t}\n\n\t/**\n\t * Get messages sent during the connection\n\t *\n\t * @returns messages sent during the connection\n\t */\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\tthis.checkNotDisposed();\n\n\t\t// If we call this when the earlyOpHandler is not attached, then the queuedMessages may not include the\n\t\t// latest ops. This could possibly indicate that initialMessages was called twice.\n\t\tassert(this.earlyOpHandlerAttached, 0x08e /* \"Potentially missed initial messages\" */);\n\t\t// We will lose ops and perf will tank as we need to go to storage to become current!\n\t\tassert(this.listeners(\"op\").length !== 0, 0x08f /* \"No op handler is setup!\" */);\n\n\t\tthis.removeEarlyOpHandler();\n\n\t\tif (this.queuedMessages.length > 0) {\n\t\t\t// Some messages were queued.\n\t\t\t// add them to the list of initialMessages to be processed\n\t\t\tthis.details.initialMessages.push(...this.queuedMessages);\n\t\t\tthis.details.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tthis.queuedMessages.length = 0;\n\t\t}\n\t\treturn this.details.initialMessages;\n\t}\n\n\t/**\n\t * Get signals sent during the connection\n\t *\n\t * @returns signals sent during the connection\n\t */\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\tthis.checkNotDisposed();\n\t\tassert(this.listeners(\"signal\").length !== 0, 0x090 /* \"No signal handler is setup!\" */);\n\n\t\tthis.removeEarlySignalHandler();\n\n\t\tif (this.queuedSignals.length > 0) {\n\t\t\t// Some signals were queued.\n\t\t\t// add them to the list of initialSignals to be processed\n\t\t\tthis.details.initialSignals.push(...this.queuedSignals);\n\t\t\tthis.queuedSignals.length = 0;\n\t\t}\n\t\treturn this.details.initialSignals;\n\t}\n\n\t/**\n\t * Get initial client list\n\t *\n\t * @returns initial client list sent during the connection\n\t */\n\tpublic get initialClients(): ISignalClient[] {\n\t\tthis.checkNotDisposed();\n\t\treturn this.details.initialClients;\n\t}\n\n\tprotected emitMessages(type: string, messages: IDocumentMessage[][]) {\n\t\t// Although the implementation here disconnects the socket and does not reuse it, other subclasses\n\t\t// (e.g. OdspDocumentDeltaConnection) may reuse the socket. In these cases, we need to avoid emitting\n\t\t// on the still-live socket.\n\t\tif (!this.disposed) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t *\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param message - signal to submit\n\t */\n\tpublic submitSignal(message: IDocumentMessage): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitSignal\", [[message]]);\n\t}\n\n\t/**\n\t * Disconnect from the websocket and close the websocket too.\n\t */\n\tprivate closeSocket(error: IAnyDriverError) {\n\t\tif (this._disposed) {\n\t\t\t// This would be rare situation due to complexity around socket emitting events.\n\t\t\treturn;\n\t\t}\n\t\tthis.closeSocketCore(error);\n\t}\n\n\tprotected closeSocketCore(error: IAnyDriverError) {\n\t\tthis.disconnect(error);\n\t}\n\n\t/**\n\t * Disconnect from the websocket, and permanently disable this DocumentDeltaConnection and close the socket.\n\t * However the OdspDocumentDeltaConnection differ in dispose as in there we don't close the socket. There is no\n\t * multiplexing here, so we need to close the socket here.\n\t */\n\tpublic dispose() {\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"ClientClosingDeltaConnection\",\n\t\t\tdriverVersion,\n\t\t\tdetails: JSON.stringify({\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t}),\n\t\t});\n\t\tthis.disconnect(\n\t\t\tcreateGenericNetworkError(\n\t\t\t\t// pre-0.58 error message: clientClosingConnection\n\t\t\t\t\"Client closing delta connection\",\n\t\t\t\t{ canRetry: true },\n\t\t\t\t{ driverVersion },\n\t\t\t),\n\t\t);\n\t}\n\n\tprotected disconnect(err: IAnyDriverError) {\n\t\t// Can't check this.disposed here, as we get here on socket closure,\n\t\t// so _disposed & socket.connected might be not in sync while processing\n\t\t// \"dispose\" event.\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.trackLatencyTimeout !== undefined) {\n\t\t\tclearTimeout(this.trackLatencyTimeout);\n\t\t\tthis.trackLatencyTimeout = undefined;\n\t\t}\n\n\t\t// We set the disposed flag as a part of the contract for overriding the disconnect method. This is used by\n\t\t// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is\n\t\t// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that\n\t\t// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended\n\t\t// to prevent normal messages from being emitted.\n\t\tthis._disposed = true;\n\n\t\t// Remove all listeners listening on the socket. These are listeners on socket and not on this connection\n\t\t// object. Anyway since we have disposed this connection object, nobody should listen to event on socket\n\t\t// anymore.\n\t\tthis.removeTrackedListeners();\n\n\t\t// Clear the connection/socket before letting the deltaManager/connection manager know about the disconnect.\n\t\tthis.disconnectCore();\n\n\t\t// Let user of connection object know about disconnect.\n\t\tthis.emit(\"disconnect\", err);\n\t}\n\n\t/**\n\t * Disconnect from the websocket.\n\t * @param reason - reason for disconnect\n\t */\n\tprotected disconnectCore() {\n\t\tthis.socket.disconnect();\n\t}\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number) {\n\t\tthis.socket.on(\"op\", this.earlyOpHandler);\n\t\tthis.socket.on(\"signal\", this.earlySignalHandler);\n\t\tthis.earlyOpHandlerAttached = true;\n\n\t\t// Socket.io's reconnect_attempt event is unreliable, so we track connect_error count instead.\n\t\tlet internalSocketConnectionFailureCount: number = 0;\n\t\tconst isInternalSocketReconnectionEnabled = (): boolean => this.socket.io.reconnection();\n\t\tconst getMaxInternalSocketReconnectionAttempts = (): number =>\n\t\t\tisInternalSocketReconnectionEnabled() ? this.socket.io.reconnectionAttempts() : 0;\n\t\tconst getMaxAllowedInternalSocketConnectionFailures = (): number =>\n\t\t\tgetMaxInternalSocketReconnectionAttempts() + 1;\n\n\t\tthis._details = await new Promise<IConnected>((resolve, reject) => {\n\t\t\tconst failAndCloseSocket = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.closeSocket(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"CloseSocketError\" }, normalizedError);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\tconst failConnection = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.disconnect(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t\t{ eventName: \"FailConnectionError\" },\n\t\t\t\t\t\tnormalizedError,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\t// Immediately set the connection timeout.\n\t\t\t// Give extra 2 seconds for handshake on top of socket connection timeout.\n\t\t\tthis.socketConnectionTimeout = setTimeout(() => {\n\t\t\t\tfailConnection(this.createErrorObject(\"orderingServiceHandshakeTimeout\"));\n\t\t\t}, timeout + 2000);\n\n\t\t\t// Listen for connection issues\n\t\t\tthis.addConnectionListener(\"connect_error\", (error) => {\n\t\t\t\tinternalSocketConnectionFailureCount++;\n\t\t\t\tlet isWebSocketTransportError = false;\n\t\t\t\ttry {\n\t\t\t\t\tconst description = error?.description;\n\t\t\t\t\tconst context = error?.context;\n\n\t\t\t\t\tif (context && typeof context === \"object\") {\n\t\t\t\t\t\tconst statusText = context.statusText?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.context\n\t\t\t\t\t\tif (statusText === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (description && typeof description === \"object\") {\n\t\t\t\t\t\tconst errorCode = description.error?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.description\n\t\t\t\t\t\tif (errorCode === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (error.type === \"TransportError\") {\n\t\t\t\t\t\t\tisWebSocketTransportError = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// That's a WebSocket. Clear it as we can't log it.\n\t\t\t\t\t\tdescription.target = undefined;\n\t\t\t\t\t}\n\t\t\t\t} catch (_e) {}\n\n\t\t\t\t// Handle socket transport downgrading when not offline.\n\t\t\t\tif (\n\t\t\t\t\tisWebSocketTransportError &&\n\t\t\t\t\tthis.enableLongPollingDowngrades &&\n\t\t\t\t\tthis.socket.io.opts.transports?.[0] !== \"polling\"\n\t\t\t\t) {\n\t\t\t\t\t// Downgrade transports to polling upgrade mechanism.\n\t\t\t\t\tthis.socket.io.opts.transports = [\"polling\", \"websocket\"];\n\t\t\t\t\t// Don't alter reconnection behavior if already enabled.\n\t\t\t\t\tif (!isInternalSocketReconnectionEnabled()) {\n\t\t\t\t\t\t// Allow single reconnection attempt using polling upgrade mechanism.\n\t\t\t\t\t\tthis.socket.io.reconnection(true);\n\t\t\t\t\t\tthis.socket.io.reconnectionAttempts(1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Allow built-in socket.io reconnection handling.\n\t\t\t\tif (\n\t\t\t\t\tisInternalSocketReconnectionEnabled() &&\n\t\t\t\t\tinternalSocketConnectionFailureCount <\n\t\t\t\t\t\tgetMaxAllowedInternalSocketConnectionFailures()\n\t\t\t\t) {\n\t\t\t\t\t// Reconnection is enabled and maximum reconnect attempts have not been reached.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_error\", error));\n\t\t\t});\n\n\t\t\t// Listen for timeouts\n\t\t\tthis.addConnectionListener(\"connect_timeout\", () => {\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_timeout\"));\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_success\", (response: IConnected) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst requestedMode = connectMessage.mode;\n\t\t\t\tconst actualMode = response.mode;\n\t\t\t\tconst writingPermitted = response.claims.scopes.includes(ScopeType.DocWrite);\n\n\t\t\t\tif (writingPermitted) {\n\t\t\t\t\t// The only time we expect a mismatch in requested/actual is if we lack write permissions\n\t\t\t\t\t// In this case we will get \"read\", even if we requested \"write\"\n\t\t\t\t\tif (actualMode !== requestedMode) {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in a different mode than was requested\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (actualMode === \"write\") {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in write mode without write permissions\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.checkpointSequenceNumber = response.checkpointSequenceNumber;\n\n\t\t\t\tthis.removeConnectionListeners();\n\t\t\t\tresolve(response);\n\t\t\t});\n\n\t\t\t// Socket can be disconnected while waiting for Fluid protocol messages\n\t\t\t// (connect_document_error / connect_document_success), as well as before DeltaManager\n\t\t\t// had a chance to register its handlers.\n\t\t\tthis.addTrackedListener(\"disconnect\", (reason, details) => {\n\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\tthis.createErrorObjectWithProps(\"disconnect\", reason, {\n\t\t\t\t\t\tsocketErrorType: details?.context?.type,\n\t\t\t\t\t\t// https://www.rfc-editor.org/rfc/rfc6455#section-7.4\n\t\t\t\t\t\tsocketCode: details?.context?.code,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tthis.addTrackedListener(\"error\", (error) => {\n\t\t\t\t// This includes \"Invalid namespace\" error, which we consider critical (reconnecting will not help)\n\t\t\t\tconst err = this.createErrorObject(\"error\", error, error !== \"Invalid namespace\");\n\t\t\t\t// Disconnect socket - required if happened before initial handshake\n\t\t\t\tfailAndCloseSocket(err);\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_error\", (error) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// This is not an socket.io error - it's Fluid protocol error.\n\t\t\t\t// In this case fail connection and indicate that we were unable to create connection\n\t\t\t\tfailConnection(this.createErrorObject(\"connect_document_error\", error));\n\t\t\t});\n\n\t\t\tthis.socket.emit(\"connect_document\", connectMessage);\n\t\t});\n\n\t\tassert(!this.disposed, 0x246 /* \"checking consistency of socket & _disposed flags\" */);\n\t}\n\n\tprivate addPropsToError(errorToBeNormalized: unknown) {\n\t\tconst normalizedError = normalizeError(errorToBeNormalized, {\n\t\t\tprops: {\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t});\n\t\treturn normalizedError;\n\t}\n\n\tprotected getConnectionDetailsProps() {\n\t\treturn {\n\t\t\tdisposed: this._disposed,\n\t\t\tsocketConnected: this.socket?.connected,\n\t\t\tclientId: this._details?.clientId,\n\t\t\tconnectionId: this.connectionId,\n\t\t};\n\t}\n\n\tprotected earlyOpHandler = (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\tthis.queuedMessages.push(...msgs);\n\t};\n\n\tprotected earlySignalHandler = (msg: ISignalMessage) => {\n\t\tthis.queuedSignals.push(msg);\n\t};\n\n\tprivate removeEarlyOpHandler() {\n\t\tthis.socket.removeListener(\"op\", this.earlyOpHandler);\n\t\tthis.earlyOpHandlerAttached = false;\n\t}\n\n\tprivate removeEarlySignalHandler() {\n\t\tthis.socket.removeListener(\"signal\", this.earlySignalHandler);\n\t}\n\n\tprivate addConnectionListener(event: string, listener: (...args: any[]) => void) {\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsAlwaysForwarded.includes(event),\n\t\t\t0x247 /* \"Use addTrackedListener instead\" */,\n\t\t);\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsToForward.includes(event),\n\t\t\t0x248 /* \"should not subscribe to forwarded events\" */,\n\t\t);\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.connectionListeners.has(event), 0x20d /* \"double connection listener\" */);\n\t\tthis.connectionListeners.set(event, listener);\n\t}\n\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.trackedListeners.has(event), 0x20e /* \"double tracked listener\" */);\n\t\tthis.trackedListeners.set(event, listener);\n\t}\n\n\tprivate removeTrackedListeners() {\n\t\tfor (const [event, listener] of this.trackedListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\t// removeTrackedListeners removes all listeners, including connection listeners\n\t\tthis.removeConnectionListeners();\n\n\t\tthis.removeEarlyOpHandler();\n\t\tthis.removeEarlySignalHandler();\n\n\t\tthis.trackedListeners.clear();\n\t}\n\n\tprivate removeConnectionListeners() {\n\t\tif (this.socketConnectionTimeout !== undefined) {\n\t\t\tclearTimeout(this.socketConnectionTimeout);\n\t\t}\n\n\t\tfor (const [event, listener] of this.connectionListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\tthis.connectionListeners.clear();\n\t}\n\n\tprivate getErrorMessage(error?: any): string {\n\t\tif (error?.type !== \"TransportError\") {\n\t\t\treturn extractLogSafeErrorProperties(error, true).message;\n\t\t}\n\t\t// JSON.stringify drops Error.message\n\t\tconst messagePrefix = error?.message !== undefined ? `${error.message}: ` : \"\";\n\n\t\t// Websocket errors reported by engine.io-client.\n\t\t// They are Error objects with description containing WS error and description = \"TransportError\"\n\t\t// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,\n\t\treturn `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;\n\t}\n\n\tprivate createErrorObjectWithProps(\n\t\thandler: string,\n\t\terror?: any,\n\t\tprops?: ITelemetryProperties,\n\t\tcanRetry = true,\n\t): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\t...props,\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAMtD,+DAAyE;AACzE,+EAW8C;AAE9C,qEAQ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qB,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIAnyDriverError,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnect,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\textractLogSafeErrorProperties,\n\tgetCircularReplacer,\n\tMonitoringContext,\n\tEventEmitterWithErrorHandling,\n\tnormalizeError,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport type { Socket } from \"socket.io-client\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class DocumentDeltaConnection\n\textends EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\tstatic readonly eventsToForward = [\"nack\", \"op\", \"signal\", \"pong\"];\n\n\t// WARNING: These are critical events that we can't miss, so registration for them has to be in place at all times!\n\t// Including before handshake is over, and after that (but before DeltaManager had a chance to put its own handlers)\n\tstatic readonly eventsAlwaysForwarded = [\"disconnect\", \"error\"];\n\n\t/**\n\t * Last known sequence number to ordering service at the time of connection\n\t * It may lap actual last sequence number (quite a bit, if container is very active).\n\t * But it's best information for client to figure out how far it is behind, at least\n\t * for \"read\" connections. \"write\" connections may use own \"join\" op to similar information,\n\t * that is likely to be more up-to-date.\n\t */\n\tpublic checkpointSequenceNumber: number | undefined;\n\n\t// Listen for ops sent before we receive a response to connect_document\n\tprotected readonly queuedMessages: ISequencedDocumentMessage[] = [];\n\tprotected readonly queuedSignals: ISignalMessage[] = [];\n\n\t/**\n\t * A flag to indicate whether we have our handler attached. If it's attached, we're queueing incoming ops\n\t * to later be retrieved via initialMessages.\n\t */\n\tprivate earlyOpHandlerAttached: boolean = false;\n\n\tprivate socketConnectionTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate _details: IConnected | undefined;\n\n\tprivate trackLatencyTimeout: number | undefined;\n\n\t// Listeners only needed while the connection is in progress\n\tprivate readonly connectionListeners: Map<string, (...args: any[]) => void> = new Map();\n\t// Listeners used throughout the lifetime of the DocumentDeltaConnection\n\tprivate readonly trackedListeners: Map<string, (...args: any[]) => void> = new Map();\n\n\tprotected get hasDetails(): boolean {\n\t\treturn !!this._details;\n\t}\n\n\tpublic get disposed() {\n\t\tassert(\n\t\t\tthis._disposed || this.socket.connected,\n\t\t\t0x244 /* \"Socket is closed, but connection is not!\" */,\n\t\t);\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Flag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages.\n\t * After disconnection, we flip this to prevent any stale messages from being emitted.\n\t */\n\tprotected _disposed: boolean = false;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * @deprecated Implementors should manage their own logger or monitoring context\n\t */\n\tprotected get logger(): ITelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic get details(): IConnected {\n\t\tif (!this._details) {\n\t\t\tthrow new Error(\"Internal error: calling method before _details is initialized!\");\n\t\t}\n\t\treturn this._details;\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param logger - for reporting telemetry events\n\t * @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure\n\t */\n\tprotected constructor(\n\t\tprotected readonly socket: Socket,\n\t\tpublic documentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableLongPollingDowngrades: boolean = false,\n\t\tprotected readonly connectionId?: string,\n\t) {\n\t\tsuper((name, error) => {\n\t\t\tthis.addPropsToError(error);\n\t\t\tlogger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DeltaConnection:EventException\",\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\tthis.mc = createChildMonitoringContext({ logger, namespace: \"DeltaConnection\" });\n\n\t\tthis.on(\"newListener\", (event, _listener) => {\n\t\t\tassert(!this.disposed, 0x20a /* \"register for event on disposed object\" */);\n\n\t\t\t// Some events are already forwarded - see this.addTrackedListener() calls in initialize().\n\t\t\tif (DocumentDeltaConnection.eventsAlwaysForwarded.includes(event)) {\n\t\t\t\tassert(this.trackedListeners.has(event), 0x245 /* \"tracked listener\" */);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!DocumentDeltaConnection.eventsToForward.includes(event)) {\n\t\t\t\tthrow new Error(`DocumentDeltaConnection: Registering for unknown event: ${event}`);\n\t\t\t}\n\n\t\t\t// Whenever listener is added, we should subscribe on same event on socket, so these two things\n\t\t\t// should be in sync. This currently assumes that nobody unregisters and registers back listeners,\n\t\t\t// and that there are no \"internal\" listeners installed (like \"error\" case we skip above)\n\t\t\t// Better flow might be to always unconditionally register all handlers on successful connection,\n\t\t\t// though some logic (naming assert in initialMessages getter) might need to be adjusted (it becomes noop)\n\t\t\tassert(\n\t\t\t\t(this.listeners(event).length !== 0) === this.trackedListeners.has(event),\n\t\t\t\t0x20b /* \"mismatch\" */,\n\t\t\t);\n\t\t\tif (!this.trackedListeners.has(event)) {\n\t\t\t\tif (event === \"pong\") {\n\t\t\t\t\t// Empty callback for tracking purposes in this class\n\t\t\t\t\tthis.trackedListeners.set(\"pong\", () => {});\n\n\t\t\t\t\tconst sendPingLoop = () => {\n\t\t\t\t\t\tconst start = Date.now();\n\n\t\t\t\t\t\tthis.socket.volatile?.emit(\"ping\", () => {\n\t\t\t\t\t\t\tthis.emit(\"pong\", Date.now() - start);\n\n\t\t\t\t\t\t\t// Schedule another ping event in 1 minute\n\t\t\t\t\t\t\tthis.trackLatencyTimeout = setTimeout(() => {\n\t\t\t\t\t\t\t\tsendPingLoop();\n\t\t\t\t\t\t\t}, 1000 * 60);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\n\t\t\t\t\tsendPingLoop();\n\t\t\t\t} else {\n\t\t\t\t\tthis.addTrackedListener(event, (...args: any[]) => {\n\t\t\t\t\t\tthis.emit(event, ...args);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Get the ID of the client who is sending the message\n\t *\n\t * @returns the client ID\n\t */\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\t/**\n\t * Get the mode of the client\n\t *\n\t * @returns the client mode\n\t */\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\t/**\n\t * Get the claims of the client who is sending the message\n\t *\n\t * @returns client claims\n\t */\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\t/**\n\t * Get whether or not this is an existing document\n\t *\n\t * @returns true if the document exists\n\t */\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\t/**\n\t * Get the maximum size of a message before chunking is required\n\t *\n\t * @returns the maximum size of a message before chunking is required\n\t */\n\tpublic get maxMessageSize(): number {\n\t\treturn this.details.serviceConfiguration.maxMessageSize;\n\t}\n\n\t/**\n\t * Semver of protocol being used with the service\n\t */\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\t/**\n\t * Configuration details provided by the service\n\t */\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tprivate checkNotDisposed() {\n\t\tassert(!this.disposed, 0x20c /* \"connection disposed\" */);\n\t}\n\n\t/**\n\t * Get messages sent during the connection\n\t *\n\t * @returns messages sent during the connection\n\t */\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\tthis.checkNotDisposed();\n\n\t\t// If we call this when the earlyOpHandler is not attached, then the queuedMessages may not include the\n\t\t// latest ops. This could possibly indicate that initialMessages was called twice.\n\t\tassert(this.earlyOpHandlerAttached, 0x08e /* \"Potentially missed initial messages\" */);\n\t\t// We will lose ops and perf will tank as we need to go to storage to become current!\n\t\tassert(this.listeners(\"op\").length !== 0, 0x08f /* \"No op handler is setup!\" */);\n\n\t\tthis.removeEarlyOpHandler();\n\n\t\tif (this.queuedMessages.length > 0) {\n\t\t\t// Some messages were queued.\n\t\t\t// add them to the list of initialMessages to be processed\n\t\t\tthis.details.initialMessages.push(...this.queuedMessages);\n\t\t\tthis.details.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tthis.queuedMessages.length = 0;\n\t\t}\n\t\treturn this.details.initialMessages;\n\t}\n\n\t/**\n\t * Get signals sent during the connection\n\t *\n\t * @returns signals sent during the connection\n\t */\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\tthis.checkNotDisposed();\n\t\tassert(this.listeners(\"signal\").length !== 0, 0x090 /* \"No signal handler is setup!\" */);\n\n\t\tthis.removeEarlySignalHandler();\n\n\t\tif (this.queuedSignals.length > 0) {\n\t\t\t// Some signals were queued.\n\t\t\t// add them to the list of initialSignals to be processed\n\t\t\tthis.details.initialSignals.push(...this.queuedSignals);\n\t\t\tthis.queuedSignals.length = 0;\n\t\t}\n\t\treturn this.details.initialSignals;\n\t}\n\n\t/**\n\t * Get initial client list\n\t *\n\t * @returns initial client list sent during the connection\n\t */\n\tpublic get initialClients(): ISignalClient[] {\n\t\tthis.checkNotDisposed();\n\t\treturn this.details.initialClients;\n\t}\n\n\tprotected emitMessages(type: string, messages: IDocumentMessage[][]) {\n\t\t// Although the implementation here disconnects the socket and does not reuse it, other subclasses\n\t\t// (e.g. OdspDocumentDeltaConnection) may reuse the socket. In these cases, we need to avoid emitting\n\t\t// on the still-live socket.\n\t\tif (!this.disposed) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t *\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param message - signal to submit\n\t */\n\tpublic submitSignal(message: IDocumentMessage): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitSignal\", [[message]]);\n\t}\n\n\t/**\n\t * Disconnect from the websocket and close the websocket too.\n\t */\n\tprivate closeSocket(error: IAnyDriverError) {\n\t\tif (this._disposed) {\n\t\t\t// This would be rare situation due to complexity around socket emitting events.\n\t\t\treturn;\n\t\t}\n\t\tthis.closeSocketCore(error);\n\t}\n\n\tprotected closeSocketCore(error: IAnyDriverError) {\n\t\tthis.disconnect(error);\n\t}\n\n\t/**\n\t * Disconnect from the websocket, and permanently disable this DocumentDeltaConnection and close the socket.\n\t * However the OdspDocumentDeltaConnection differ in dispose as in there we don't close the socket. There is no\n\t * multiplexing here, so we need to close the socket here.\n\t */\n\tpublic dispose() {\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"ClientClosingDeltaConnection\",\n\t\t\tdriverVersion,\n\t\t\tdetails: JSON.stringify({\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t}),\n\t\t});\n\t\tthis.disconnect(\n\t\t\tcreateGenericNetworkError(\n\t\t\t\t// pre-0.58 error message: clientClosingConnection\n\t\t\t\t\"Client closing delta connection\",\n\t\t\t\t{ canRetry: true },\n\t\t\t\t{ driverVersion },\n\t\t\t),\n\t\t);\n\t}\n\n\tprotected disconnect(err: IAnyDriverError) {\n\t\t// Can't check this.disposed here, as we get here on socket closure,\n\t\t// so _disposed & socket.connected might be not in sync while processing\n\t\t// \"dispose\" event.\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.trackLatencyTimeout !== undefined) {\n\t\t\tclearTimeout(this.trackLatencyTimeout);\n\t\t\tthis.trackLatencyTimeout = undefined;\n\t\t}\n\n\t\t// We set the disposed flag as a part of the contract for overriding the disconnect method. This is used by\n\t\t// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is\n\t\t// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that\n\t\t// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended\n\t\t// to prevent normal messages from being emitted.\n\t\tthis._disposed = true;\n\n\t\t// Remove all listeners listening on the socket. These are listeners on socket and not on this connection\n\t\t// object. Anyway since we have disposed this connection object, nobody should listen to event on socket\n\t\t// anymore.\n\t\tthis.removeTrackedListeners();\n\n\t\t// Clear the connection/socket before letting the deltaManager/connection manager know about the disconnect.\n\t\tthis.disconnectCore();\n\n\t\t// Let user of connection object know about disconnect.\n\t\tthis.emit(\"disconnect\", err);\n\t}\n\n\t/**\n\t * Disconnect from the websocket.\n\t * @param reason - reason for disconnect\n\t */\n\tprotected disconnectCore() {\n\t\tthis.socket.disconnect();\n\t}\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number) {\n\t\tthis.socket.on(\"op\", this.earlyOpHandler);\n\t\tthis.socket.on(\"signal\", this.earlySignalHandler);\n\t\tthis.earlyOpHandlerAttached = true;\n\n\t\t// Socket.io's reconnect_attempt event is unreliable, so we track connect_error count instead.\n\t\tlet internalSocketConnectionFailureCount: number = 0;\n\t\tconst isInternalSocketReconnectionEnabled = (): boolean => this.socket.io.reconnection();\n\t\tconst getMaxInternalSocketReconnectionAttempts = (): number =>\n\t\t\tisInternalSocketReconnectionEnabled() ? this.socket.io.reconnectionAttempts() : 0;\n\t\tconst getMaxAllowedInternalSocketConnectionFailures = (): number =>\n\t\t\tgetMaxInternalSocketReconnectionAttempts() + 1;\n\n\t\tthis._details = await new Promise<IConnected>((resolve, reject) => {\n\t\t\tconst failAndCloseSocket = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.closeSocket(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"CloseSocketError\" }, normalizedError);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\tconst failConnection = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.disconnect(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t\t{ eventName: \"FailConnectionError\" },\n\t\t\t\t\t\tnormalizedError,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\t// Immediately set the connection timeout.\n\t\t\t// Give extra 2 seconds for handshake on top of socket connection timeout.\n\t\t\tthis.socketConnectionTimeout = setTimeout(() => {\n\t\t\t\tfailConnection(this.createErrorObject(\"orderingServiceHandshakeTimeout\"));\n\t\t\t}, timeout + 2000);\n\n\t\t\t// Listen for connection issues\n\t\t\tthis.addConnectionListener(\"connect_error\", (error) => {\n\t\t\t\tinternalSocketConnectionFailureCount++;\n\t\t\t\tlet isWebSocketTransportError = false;\n\t\t\t\ttry {\n\t\t\t\t\tconst description = error?.description;\n\t\t\t\t\tconst context = error?.context;\n\n\t\t\t\t\tif (context && typeof context === \"object\") {\n\t\t\t\t\t\tconst statusText = context.statusText?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.context\n\t\t\t\t\t\tif (statusText === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (description && typeof description === \"object\") {\n\t\t\t\t\t\tconst errorCode = description.error?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.description\n\t\t\t\t\t\tif (errorCode === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (error.type === \"TransportError\") {\n\t\t\t\t\t\t\tisWebSocketTransportError = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// That's a WebSocket. Clear it as we can't log it.\n\t\t\t\t\t\tdescription.target = undefined;\n\t\t\t\t\t}\n\t\t\t\t} catch (_e) {}\n\n\t\t\t\t// Handle socket transport downgrading when not offline.\n\t\t\t\tif (\n\t\t\t\t\tisWebSocketTransportError &&\n\t\t\t\t\tthis.enableLongPollingDowngrades &&\n\t\t\t\t\tthis.socket.io.opts.transports?.[0] !== \"polling\"\n\t\t\t\t) {\n\t\t\t\t\t// Downgrade transports to polling upgrade mechanism.\n\t\t\t\t\tthis.socket.io.opts.transports = [\"polling\", \"websocket\"];\n\t\t\t\t\t// Don't alter reconnection behavior if already enabled.\n\t\t\t\t\tif (!isInternalSocketReconnectionEnabled()) {\n\t\t\t\t\t\t// Allow single reconnection attempt using polling upgrade mechanism.\n\t\t\t\t\t\tthis.socket.io.reconnection(true);\n\t\t\t\t\t\tthis.socket.io.reconnectionAttempts(1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Allow built-in socket.io reconnection handling.\n\t\t\t\tif (\n\t\t\t\t\tisInternalSocketReconnectionEnabled() &&\n\t\t\t\t\tinternalSocketConnectionFailureCount <\n\t\t\t\t\t\tgetMaxAllowedInternalSocketConnectionFailures()\n\t\t\t\t) {\n\t\t\t\t\t// Reconnection is enabled and maximum reconnect attempts have not been reached.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_error\", error));\n\t\t\t});\n\n\t\t\t// Listen for timeouts\n\t\t\tthis.addConnectionListener(\"connect_timeout\", () => {\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_timeout\"));\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_success\", (response: IConnected) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst requestedMode = connectMessage.mode;\n\t\t\t\tconst actualMode = response.mode;\n\t\t\t\tconst writingPermitted = response.claims.scopes.includes(ScopeType.DocWrite);\n\n\t\t\t\tif (writingPermitted) {\n\t\t\t\t\t// The only time we expect a mismatch in requested/actual is if we lack write permissions\n\t\t\t\t\t// In this case we will get \"read\", even if we requested \"write\"\n\t\t\t\t\tif (actualMode !== requestedMode) {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in a different mode than was requested\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (actualMode === \"write\") {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in write mode without write permissions\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.checkpointSequenceNumber = response.checkpointSequenceNumber;\n\n\t\t\t\tthis.removeConnectionListeners();\n\t\t\t\tresolve(response);\n\t\t\t});\n\n\t\t\t// Socket can be disconnected while waiting for Fluid protocol messages\n\t\t\t// (connect_document_error / connect_document_success), as well as before DeltaManager\n\t\t\t// had a chance to register its handlers.\n\t\t\tthis.addTrackedListener(\"disconnect\", (reason, details) => {\n\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\tthis.createErrorObjectWithProps(\"disconnect\", reason, {\n\t\t\t\t\t\tsocketErrorType: details?.context?.type,\n\t\t\t\t\t\t// https://www.rfc-editor.org/rfc/rfc6455#section-7.4\n\t\t\t\t\t\tsocketCode: details?.context?.code,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tthis.addTrackedListener(\"error\", (error) => {\n\t\t\t\t// This includes \"Invalid namespace\" error, which we consider critical (reconnecting will not help)\n\t\t\t\tconst err = this.createErrorObject(\"error\", error, error !== \"Invalid namespace\");\n\t\t\t\t// Disconnect socket - required if happened before initial handshake\n\t\t\t\tfailAndCloseSocket(err);\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_error\", (error) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// This is not an socket.io error - it's Fluid protocol error.\n\t\t\t\t// In this case fail connection and indicate that we were unable to create connection\n\t\t\t\tfailConnection(this.createErrorObject(\"connect_document_error\", error));\n\t\t\t});\n\n\t\t\tthis.socket.emit(\"connect_document\", connectMessage);\n\t\t});\n\n\t\tassert(!this.disposed, 0x246 /* \"checking consistency of socket & _disposed flags\" */);\n\t}\n\n\tprivate addPropsToError(errorToBeNormalized: unknown) {\n\t\tconst normalizedError = normalizeError(errorToBeNormalized, {\n\t\t\tprops: {\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t});\n\t\treturn normalizedError;\n\t}\n\n\tprotected getConnectionDetailsProps() {\n\t\treturn {\n\t\t\tdisposed: this._disposed,\n\t\t\tsocketConnected: this.socket?.connected,\n\t\t\tclientId: this._details?.clientId,\n\t\t\tconnectionId: this.connectionId,\n\t\t};\n\t}\n\n\tprotected earlyOpHandler = (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\tthis.queuedMessages.push(...msgs);\n\t};\n\n\tprotected earlySignalHandler = (msg: ISignalMessage) => {\n\t\tthis.queuedSignals.push(msg);\n\t};\n\n\tprivate removeEarlyOpHandler() {\n\t\tthis.socket.removeListener(\"op\", this.earlyOpHandler);\n\t\tthis.earlyOpHandlerAttached = false;\n\t}\n\n\tprivate removeEarlySignalHandler() {\n\t\tthis.socket.removeListener(\"signal\", this.earlySignalHandler);\n\t}\n\n\tprivate addConnectionListener(event: string, listener: (...args: any[]) => void) {\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsAlwaysForwarded.includes(event),\n\t\t\t0x247 /* \"Use addTrackedListener instead\" */,\n\t\t);\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsToForward.includes(event),\n\t\t\t0x248 /* \"should not subscribe to forwarded events\" */,\n\t\t);\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.connectionListeners.has(event), 0x20d /* \"double connection listener\" */);\n\t\tthis.connectionListeners.set(event, listener);\n\t}\n\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.trackedListeners.has(event), 0x20e /* \"double tracked listener\" */);\n\t\tthis.trackedListeners.set(event, listener);\n\t}\n\n\tprivate removeTrackedListeners() {\n\t\tfor (const [event, listener] of this.trackedListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\t// removeTrackedListeners removes all listeners, including connection listeners\n\t\tthis.removeConnectionListeners();\n\n\t\tthis.removeEarlyOpHandler();\n\t\tthis.removeEarlySignalHandler();\n\n\t\tthis.trackedListeners.clear();\n\t}\n\n\tprivate removeConnectionListeners() {\n\t\tif (this.socketConnectionTimeout !== undefined) {\n\t\t\tclearTimeout(this.socketConnectionTimeout);\n\t\t}\n\n\t\tfor (const [event, listener] of this.connectionListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\tthis.connectionListeners.clear();\n\t}\n\n\tprivate getErrorMessage(error?: any): string {\n\t\tif (error?.type !== \"TransportError\") {\n\t\t\treturn extractLogSafeErrorProperties(error, true).message;\n\t\t}\n\t\t// JSON.stringify drops Error.message\n\t\tconst messagePrefix = error?.message !== undefined ? `${error.message}: ` : \"\";\n\n\t\t// Websocket errors reported by engine.io-client.\n\t\t// They are Error objects with description containing WS error and description = \"TransportError\"\n\t\t// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,\n\t\treturn `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;\n\t}\n\n\tprivate createErrorObjectWithProps(\n\t\thandler: string,\n\t\terror?: any,\n\t\tprops?: ITelemetryProperties,\n\t\tcanRetry = true,\n\t): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\t...props,\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
|
package/dist/driverUtils.js
CHANGED
|
@@ -25,7 +25,6 @@ function getW3CData(url, initiatorType) {
|
|
|
25
25
|
// domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.
|
|
26
26
|
// redirectStart: start time of the fetch which that initiates the redirect.
|
|
27
27
|
// redirectEnd: immediately after receiving the last byte of the response of the last redirect.
|
|
28
|
-
var _a, _b;
|
|
29
28
|
// Interval between start and finish of the domain name lookup for the resource.
|
|
30
29
|
let dnsLookupTime; // domainLookupEnd - domainLookupStart
|
|
31
30
|
// Interval between the first fetch until the last byte of the last redirect.
|
|
@@ -45,7 +44,7 @@ function getW3CData(url, initiatorType) {
|
|
|
45
44
|
let reqStartToResponseEndTime; // responseEnd - requestStart
|
|
46
45
|
let w3cStartTime; // W3C Start time = fetchStart time
|
|
47
46
|
// getEntriesByType is only available in browser performance object
|
|
48
|
-
const resources1 =
|
|
47
|
+
const resources1 = common_utils_1.performance.getEntriesByType?.("resource") ?? [];
|
|
49
48
|
// Usually the latest fetch call is to the end of resources, so we start from the end.
|
|
50
49
|
for (let i = resources1.length - 1; i > 0; i--) {
|
|
51
50
|
const indResTime = resources1[i];
|
package/dist/driverUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driverUtils.js","sourceRoot":"","sources":["../src/driverUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAI3D;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,aAAqB;IAC5D,mFAAmF;IACnF,2EAA2E;IAC3E,8FAA8F;IAC9F,wGAAwG;IACxG,oFAAoF;IACpF,gGAAgG;IAChG,mGAAmG;IACnG,mGAAmG;IACnG,2FAA2F;IAC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;iBACN,CAAC;aACF,CAAC,CAAC;SACH;KACD;AACF,CAAC;AA7CD,4CA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\n/**\n * Extract and return the w3c data.\n * @param url - request url for which w3c data needs to be reported.\n * @param initiatorType - type of the network call\n */\nexport function getW3CData(url: string, initiatorType: string) {\n\t// From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n\t// fetchStart: immediately before the browser starts to fetch the resource.\n\t// requestStart: immediately before the browser starts requesting the resource from the server\n\t// responseStart: immediately after the browser receives the first byte of the response from the server.\n\t// responseEnd: immediately after the browser receives the last byte of the resource\n\t// or immediately before the transport connection is closed, whichever comes first.\n\t// secureConnectionStart: immediately before the browser starts the handshake process to secure the\n\t// current connection. If a secure connection is not used, this property returns zero.\n\t// startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n\t// domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n\t// domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n\t// redirectStart: start time of the fetch which that initiates the redirect.\n\t// redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n\n\t// Interval between start and finish of the domain name lookup for the resource.\n\tlet dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n\t// Interval between the first fetch until the last byte of the last redirect.\n\tlet redirectTime: number | undefined; // redirectEnd - redirectStart\n\t// Time to establish the connection to the server to retrieve the resource.\n\tlet tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n\t// Time from the end of the connection until the inital handshake process to secure the connection.\n\t// If 0, then no time is spent here.\n\tlet secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n\t// Interval to receive all (first to last) bytes form the server.\n\tlet responseNetworkTime: number | undefined; // responsEnd - responseStart\n\t// Interval between the initial fetch until the last byte is received.\n\t// Likely same as fetchTime + receiveContentTime.\n\tlet fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n\t// reqStartToResponseEndTime = fetchStartToResponseEndTime - <initial TCP handshake>\n\t// Interval between starting the request for the resource until receiving the last byte.\n\tlet reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n\tlet w3cStartTime: number | undefined; // W3C Start time = fetchStart time\n\n\t// getEntriesByType is only available in browser performance object\n\tconst resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n\t// Usually the latest fetch call is to the end of resources, so we start from the end.\n\tfor (let i = resources1.length - 1; i > 0; i--) {\n\t\tconst indResTime = resources1[i] as PerformanceResourceTiming;\n\t\tconst resource_name = indResTime.name.toString();\n\t\tconst resource_initiatortype = indResTime.initiatorType;\n\t\tif (\n\t\t\tresource_initiatortype.localeCompare(initiatorType) === 0 &&\n\t\t\tresource_name.includes(url)\n\t\t) {\n\t\t\tredirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n\t\t\tw3cStartTime = indResTime.fetchStart;\n\t\t\tdnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n\t\t\ttcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n\t\t\tsecureConnectionTime =\n\t\t\t\tindResTime.secureConnectionStart > 0\n\t\t\t\t\t? indResTime.connectEnd - indResTime.secureConnectionStart\n\t\t\t\t\t: 0;\n\t\t\tresponseNetworkTime =\n\t\t\t\tindResTime.responseStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.responseStart\n\t\t\t\t\t: undefined;\n\t\t\tfetchStartToResponseEndTime =\n\t\t\t\tindResTime.fetchStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.fetchStart\n\t\t\t\t\t: undefined;\n\t\t\treqStartToResponseEndTime =\n\t\t\t\tindResTime.requestStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.requestStart\n\t\t\t\t\t: undefined;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn {\n\t\tdnsLookupTime,\n\t\tw3cStartTime,\n\t\tredirectTime,\n\t\ttcpHandshakeTime,\n\t\tsecureConnectionTime,\n\t\tresponseNetworkTime,\n\t\tfetchStartToResponseEndTime,\n\t\treqStartToResponseEndTime,\n\t};\n}\n\n/*\n * An implementation of Promise.race that gives you the winner of the promise race.\n * If one of the promises is rejected before any other is resolved, this method will return the error/reason from that rejection.\n */\nexport async function promiseRaceWithWinner<T>(\n\tpromises: Promise<T>[],\n): Promise<{ index: number; value: T }> {\n\treturn new Promise((resolve, reject) => {\n\t\tpromises.forEach((p, index) => {\n\t\t\tp.then((v) => resolve({ index, value: v })).catch(reject);\n\t\t});\n\t});\n}\n\nexport function validateMessages(\n\treason: string,\n\tmessages: ISequencedDocumentMessage[],\n\tfrom: number,\n\tlogger: ITelemetryLoggerExt,\n\tstrict: boolean = true,\n) {\n\tif (messages.length !== 0) {\n\t\tconst start = messages[0].sequenceNumber;\n\t\tconst length = messages.length;\n\t\tconst last = messages[length - 1].sequenceNumber;\n\t\tif (last + 1 !== from + length) {\n\t\t\t// If not strict, then return the first consecutive sub-block. If strict or start\n\t\t\t// seq number is not what we expected, then return no ops.\n\t\t\tif (strict || from !== start) {\n\t\t\t\tmessages.length = 0;\n\t\t\t} else {\n\t\t\t\tlet validOpsCount = 1;\n\t\t\t\twhile (\n\t\t\t\t\tvalidOpsCount < messages.length &&\n\t\t\t\t\tmessages[validOpsCount].sequenceNumber ===\n\t\t\t\t\t\tmessages[validOpsCount - 1].sequenceNumber + 1\n\t\t\t\t) {\n\t\t\t\t\tvalidOpsCount++;\n\t\t\t\t}\n\t\t\t\tmessages.length = validOpsCount;\n\t\t\t}\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"OpsFetchViolation\",\n\t\t\t\treason,\n\t\t\t\tfrom,\n\t\t\t\tstart,\n\t\t\t\tlast,\n\t\t\t\tlength,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tvalidLength: messages.length,\n\t\t\t\t\tlastValidOpSeqNumber:\n\t\t\t\t\t\tmessages.length > 0\n\t\t\t\t\t\t\t? messages[messages.length - 1].sequenceNumber\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tstrict,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"driverUtils.js","sourceRoot":"","sources":["../src/driverUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAI3D;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,aAAqB;IAC5D,mFAAmF;IACnF,2EAA2E;IAC3E,8FAA8F;IAC9F,wGAAwG;IACxG,oFAAoF;IACpF,gGAAgG;IAChG,mGAAmG;IACnG,mGAAmG;IACnG,2FAA2F;IAC3F,oGAAoG;IACpG,mGAAmG;IACnG,4EAA4E;IAC5E,+FAA+F;IAE/F,gFAAgF;IAChF,IAAI,aAAiC,CAAC,CAAC,sCAAsC;IAC7E,6EAA6E;IAC7E,IAAI,YAAgC,CAAC,CAAC,8BAA8B;IACpE,2EAA2E;IAC3E,IAAI,gBAAoC,CAAC,CAAC,6BAA6B;IACvE,mGAAmG;IACnG,oCAAoC;IACpC,IAAI,oBAAwC,CAAC,CAAC,sCAAsC;IACpF,iEAAiE;IACjE,IAAI,mBAAuC,CAAC,CAAC,6BAA6B;IAC1E,sEAAsE;IACtE,iDAAiD;IACjD,IAAI,2BAA+C,CAAC,CAAC,4BAA4B;IACjF,oFAAoF;IACpF,wFAAwF;IACxF,IAAI,yBAA6C,CAAC,CAAC,6BAA6B;IAChF,IAAI,YAAgC,CAAC,CAAC,mCAAmC;IAEzE,mEAAmE;IACnE,MAAM,UAAU,GAAG,0BAAW,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IACpE,sFAAsF;IACtF,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CA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C,CAAC,cAAc,GAAG,CAAC,EAC9C;oBACD,aAAa,EAAE,CAAC;iBAChB;gBACD,QAAQ,CAAC,MAAM,GAAG,aAAa,CAAC;aAChC;YACD,MAAM,CAAC,cAAc,CAAC;gBACrB,SAAS,EAAE,mBAAmB;gBAC9B,MAAM;gBACN,IAAI;gBACJ,KAAK;gBACL,IAAI;gBACJ,MAAM;gBACN,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,WAAW,EAAE,QAAQ,CAAC,MAAM;oBAC5B,oBAAoB,EACnB,QAAQ,CAAC,MAAM,GAAG,CAAC;wBAClB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;wBAC9C,CAAC,CAAC,SAAS;oBACb,MAAM;iBACN,CAAC;aACF,CAAC,CAAC;SACH;KACD;AACF,CAAC;AA7CD,4CA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\n/**\n * Extract and return the w3c data.\n * @param url - request url for which w3c data needs to be reported.\n * @param initiatorType - type of the network call\n */\nexport function getW3CData(url: string, initiatorType: string) {\n\t// From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n\t// fetchStart: immediately before the browser starts to fetch the resource.\n\t// requestStart: immediately before the browser starts requesting the resource from the server\n\t// responseStart: immediately after the browser receives the first byte of the response from the server.\n\t// responseEnd: immediately after the browser receives the last byte of the resource\n\t// or immediately before the transport connection is closed, whichever comes first.\n\t// secureConnectionStart: immediately before the browser starts the handshake process to secure the\n\t// current connection. If a secure connection is not used, this property returns zero.\n\t// startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n\t// domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n\t// domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n\t// redirectStart: start time of the fetch which that initiates the redirect.\n\t// redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n\n\t// Interval between start and finish of the domain name lookup for the resource.\n\tlet dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n\t// Interval between the first fetch until the last byte of the last redirect.\n\tlet redirectTime: number | undefined; // redirectEnd - redirectStart\n\t// Time to establish the connection to the server to retrieve the resource.\n\tlet tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n\t// Time from the end of the connection until the inital handshake process to secure the connection.\n\t// If 0, then no time is spent here.\n\tlet secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n\t// Interval to receive all (first to last) bytes form the server.\n\tlet responseNetworkTime: number | undefined; // responsEnd - responseStart\n\t// Interval between the initial fetch until the last byte is received.\n\t// Likely same as fetchTime + receiveContentTime.\n\tlet fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n\t// reqStartToResponseEndTime = fetchStartToResponseEndTime - <initial TCP handshake>\n\t// Interval between starting the request for the resource until receiving the last byte.\n\tlet reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n\tlet w3cStartTime: number | undefined; // W3C Start time = fetchStart time\n\n\t// getEntriesByType is only available in browser performance object\n\tconst resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n\t// Usually the latest fetch call is to the end of resources, so we start from the end.\n\tfor (let i = resources1.length - 1; i > 0; i--) {\n\t\tconst indResTime = resources1[i] as PerformanceResourceTiming;\n\t\tconst resource_name = indResTime.name.toString();\n\t\tconst resource_initiatortype = indResTime.initiatorType;\n\t\tif (\n\t\t\tresource_initiatortype.localeCompare(initiatorType) === 0 &&\n\t\t\tresource_name.includes(url)\n\t\t) {\n\t\t\tredirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n\t\t\tw3cStartTime = indResTime.fetchStart;\n\t\t\tdnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n\t\t\ttcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n\t\t\tsecureConnectionTime =\n\t\t\t\tindResTime.secureConnectionStart > 0\n\t\t\t\t\t? indResTime.connectEnd - indResTime.secureConnectionStart\n\t\t\t\t\t: 0;\n\t\t\tresponseNetworkTime =\n\t\t\t\tindResTime.responseStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.responseStart\n\t\t\t\t\t: undefined;\n\t\t\tfetchStartToResponseEndTime =\n\t\t\t\tindResTime.fetchStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.fetchStart\n\t\t\t\t\t: undefined;\n\t\t\treqStartToResponseEndTime =\n\t\t\t\tindResTime.requestStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.requestStart\n\t\t\t\t\t: undefined;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn {\n\t\tdnsLookupTime,\n\t\tw3cStartTime,\n\t\tredirectTime,\n\t\ttcpHandshakeTime,\n\t\tsecureConnectionTime,\n\t\tresponseNetworkTime,\n\t\tfetchStartToResponseEndTime,\n\t\treqStartToResponseEndTime,\n\t};\n}\n\n/*\n * An implementation of Promise.race that gives you the winner of the promise race.\n * If one of the promises is rejected before any other is resolved, this method will return the error/reason from that rejection.\n */\nexport async function promiseRaceWithWinner<T>(\n\tpromises: Promise<T>[],\n): Promise<{ index: number; value: T }> {\n\treturn new Promise((resolve, reject) => {\n\t\tpromises.forEach((p, index) => {\n\t\t\tp.then((v) => resolve({ index, value: v })).catch(reject);\n\t\t});\n\t});\n}\n\nexport function validateMessages(\n\treason: string,\n\tmessages: ISequencedDocumentMessage[],\n\tfrom: number,\n\tlogger: ITelemetryLoggerExt,\n\tstrict: boolean = true,\n) {\n\tif (messages.length !== 0) {\n\t\tconst start = messages[0].sequenceNumber;\n\t\tconst length = messages.length;\n\t\tconst last = messages[length - 1].sequenceNumber;\n\t\tif (last + 1 !== from + length) {\n\t\t\t// If not strict, then return the first consecutive sub-block. If strict or start\n\t\t\t// seq number is not what we expected, then return no ops.\n\t\t\tif (strict || from !== start) {\n\t\t\t\tmessages.length = 0;\n\t\t\t} else {\n\t\t\t\tlet validOpsCount = 1;\n\t\t\t\twhile (\n\t\t\t\t\tvalidOpsCount < messages.length &&\n\t\t\t\t\tmessages[validOpsCount].sequenceNumber ===\n\t\t\t\t\t\tmessages[validOpsCount - 1].sequenceNumber + 1\n\t\t\t\t) {\n\t\t\t\t\tvalidOpsCount++;\n\t\t\t\t}\n\t\t\t\tmessages.length = validOpsCount;\n\t\t\t}\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"OpsFetchViolation\",\n\t\t\t\treason,\n\t\t\t\tfrom,\n\t\t\t\tstart,\n\t\t\t\tlast,\n\t\t\t\tlength,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tvalidLength: messages.length,\n\t\t\t\t\tlastValidOpSeqNumber:\n\t\t\t\t\t\tmessages.length > 0\n\t\t\t\t\t\t\t? messages[messages.length - 1].sequenceNumber\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tstrict,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\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/driver-base";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.0.1";
|
|
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/driver-base";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.6.0.1";
|
|
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,6BAA6B,CAAC;AACxC,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/driver-base\";\nexport const pkgVersion = \"2.0.0-internal.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,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/driver-base\";\nexport const pkgVersion = \"2.0.0-internal.6.0.1\";\n"]}
|
|
@@ -75,9 +75,8 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
75
75
|
// Empty callback for tracking purposes in this class
|
|
76
76
|
this.trackedListeners.set("pong", () => { });
|
|
77
77
|
const sendPingLoop = () => {
|
|
78
|
-
var _a;
|
|
79
78
|
const start = Date.now();
|
|
80
|
-
|
|
79
|
+
this.socket.volatile?.emit("ping", () => {
|
|
81
80
|
this.emit("pong", Date.now() - start);
|
|
82
81
|
// Schedule another ping event in 1 minute
|
|
83
82
|
this.trackLatencyTimeout = setTimeout(() => {
|
|
@@ -265,7 +264,9 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
265
264
|
this.logger.sendTelemetryEvent({
|
|
266
265
|
eventName: "ClientClosingDeltaConnection",
|
|
267
266
|
driverVersion,
|
|
268
|
-
details: JSON.stringify(
|
|
267
|
+
details: JSON.stringify({
|
|
268
|
+
...this.getConnectionDetailsProps(),
|
|
269
|
+
}),
|
|
269
270
|
});
|
|
270
271
|
this.disconnect(createGenericNetworkError(
|
|
271
272
|
// pre-0.58 error message: clientClosingConnection
|
|
@@ -341,14 +342,13 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
341
342
|
}, timeout + 2000);
|
|
342
343
|
// Listen for connection issues
|
|
343
344
|
this.addConnectionListener("connect_error", (error) => {
|
|
344
|
-
var _a, _b, _c;
|
|
345
345
|
internalSocketConnectionFailureCount++;
|
|
346
346
|
let isWebSocketTransportError = false;
|
|
347
347
|
try {
|
|
348
|
-
const description = error
|
|
349
|
-
const context = error
|
|
348
|
+
const description = error?.description;
|
|
349
|
+
const context = error?.context;
|
|
350
350
|
if (context && typeof context === "object") {
|
|
351
|
-
const statusText =
|
|
351
|
+
const statusText = context.statusText?.code;
|
|
352
352
|
// Self-Signed Certificate ErrorCode Found in error.context
|
|
353
353
|
if (statusText === "DEPTH_ZERO_SELF_SIGNED_CERT") {
|
|
354
354
|
failAndCloseSocket(this.createErrorObject("connect_error", error, false));
|
|
@@ -356,7 +356,7 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
else if (description && typeof description === "object") {
|
|
359
|
-
const errorCode =
|
|
359
|
+
const errorCode = description.error?.code;
|
|
360
360
|
// Self-Signed Certificate ErrorCode Found in error.description
|
|
361
361
|
if (errorCode === "DEPTH_ZERO_SELF_SIGNED_CERT") {
|
|
362
362
|
failAndCloseSocket(this.createErrorObject("connect_error", error, false));
|
|
@@ -373,7 +373,7 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
373
373
|
// Handle socket transport downgrading when not offline.
|
|
374
374
|
if (isWebSocketTransportError &&
|
|
375
375
|
this.enableLongPollingDowngrades &&
|
|
376
|
-
|
|
376
|
+
this.socket.io.opts.transports?.[0] !== "polling") {
|
|
377
377
|
// Downgrade transports to polling upgrade mechanism.
|
|
378
378
|
this.socket.io.opts.transports = ["polling", "websocket"];
|
|
379
379
|
// Don't alter reconnection behavior if already enabled.
|
|
@@ -428,11 +428,10 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
428
428
|
// (connect_document_error / connect_document_success), as well as before DeltaManager
|
|
429
429
|
// had a chance to register its handlers.
|
|
430
430
|
this.addTrackedListener("disconnect", (reason, details) => {
|
|
431
|
-
var _a, _b;
|
|
432
431
|
failAndCloseSocket(this.createErrorObjectWithProps("disconnect", reason, {
|
|
433
|
-
socketErrorType:
|
|
432
|
+
socketErrorType: details?.context?.type,
|
|
434
433
|
// https://www.rfc-editor.org/rfc/rfc6455#section-7.4
|
|
435
|
-
socketCode:
|
|
434
|
+
socketCode: details?.context?.code,
|
|
436
435
|
}));
|
|
437
436
|
});
|
|
438
437
|
this.addTrackedListener("error", (error) => {
|
|
@@ -459,17 +458,18 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
459
458
|
addPropsToError(errorToBeNormalized) {
|
|
460
459
|
const normalizedError = normalizeError(errorToBeNormalized, {
|
|
461
460
|
props: {
|
|
462
|
-
details: JSON.stringify(
|
|
461
|
+
details: JSON.stringify({
|
|
462
|
+
...this.getConnectionDetailsProps(),
|
|
463
|
+
}),
|
|
463
464
|
},
|
|
464
465
|
});
|
|
465
466
|
return normalizedError;
|
|
466
467
|
}
|
|
467
468
|
getConnectionDetailsProps() {
|
|
468
|
-
var _a, _b;
|
|
469
469
|
return {
|
|
470
470
|
disposed: this._disposed,
|
|
471
|
-
socketConnected:
|
|
472
|
-
clientId:
|
|
471
|
+
socketConnected: this.socket?.connected,
|
|
472
|
+
clientId: this._details?.clientId,
|
|
473
473
|
connectionId: this.connectionId,
|
|
474
474
|
};
|
|
475
475
|
}
|
|
@@ -512,18 +512,24 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
512
512
|
this.connectionListeners.clear();
|
|
513
513
|
}
|
|
514
514
|
getErrorMessage(error) {
|
|
515
|
-
if (
|
|
515
|
+
if (error?.type !== "TransportError") {
|
|
516
516
|
return extractLogSafeErrorProperties(error, true).message;
|
|
517
517
|
}
|
|
518
518
|
// JSON.stringify drops Error.message
|
|
519
|
-
const messagePrefix =
|
|
519
|
+
const messagePrefix = error?.message !== undefined ? `${error.message}: ` : "";
|
|
520
520
|
// Websocket errors reported by engine.io-client.
|
|
521
521
|
// They are Error objects with description containing WS error and description = "TransportError"
|
|
522
522
|
// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,
|
|
523
523
|
return `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;
|
|
524
524
|
}
|
|
525
525
|
createErrorObjectWithProps(handler, error, props, canRetry = true) {
|
|
526
|
-
return createGenericNetworkError(`socket.io (${handler}): ${this.getErrorMessage(error)}`, { canRetry },
|
|
526
|
+
return createGenericNetworkError(`socket.io (${handler}): ${this.getErrorMessage(error)}`, { canRetry }, {
|
|
527
|
+
...props,
|
|
528
|
+
driverVersion,
|
|
529
|
+
details: JSON.stringify({
|
|
530
|
+
...this.getConnectionDetailsProps(),
|
|
531
|
+
}),
|
|
532
|
+
});
|
|
527
533
|
}
|
|
528
534
|
/**
|
|
529
535
|
* Error raising for socket.io issues
|
|
@@ -531,7 +537,9 @@ export class DocumentDeltaConnection extends EventEmitterWithErrorHandling {
|
|
|
531
537
|
createErrorObject(handler, error, canRetry = true) {
|
|
532
538
|
return createGenericNetworkError(`socket.io (${handler}): ${this.getErrorMessage(error)}`, { canRetry }, {
|
|
533
539
|
driverVersion,
|
|
534
|
-
details: JSON.stringify(
|
|
540
|
+
details: JSON.stringify({
|
|
541
|
+
...this.getConnectionDetailsProps(),
|
|
542
|
+
}),
|
|
535
543
|
});
|
|
536
544
|
}
|
|
537
545
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAMtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAUN,SAAS,GACT,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAEN,6BAA6B,EAC7B,mBAAmB,EAEnB,6BAA6B,EAC7B,cAAc,EACd,4BAA4B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,sFAAsF;AACtF,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,uBACZ,SAAQ,6BAA6D;IAwErE;;;;;OAKG;IACH,YACoB,MAAc,EAC1B,UAAkB,EACzB,MAA2B,EACV,8BAAuC,KAAK,EAC1C,YAAqB;QAExC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACrB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAC5B,MAAM,CAAC,cAAc,CACpB;gBACC,SAAS,EAAE,gCAAgC;gBAC3C,IAAI;aACJ,EACD,KAAK,CACL,CAAC;QACH,CAAC,CAAC,CAAC;QAfgB,WAAM,GAAN,MAAM,CAAQ;QAC1B,eAAU,GAAV,UAAU,CAAQ;QAER,gCAA2B,GAA3B,2BAA2B,CAAiB;QAC1C,iBAAY,GAAZ,YAAY,CAAS;QAjEzC,uEAAuE;QACpD,mBAAc,GAAgC,EAAE,CAAC;QACjD,kBAAa,GAAqB,EAAE,CAAC;QAExD;;;WAGG;QACK,2BAAsB,GAAY,KAAK,CAAC;QAQhD,4DAA4D;QAC3C,wBAAmB,GAA0C,IAAI,GAAG,EAAE,CAAC;QACxF,wEAAwE;QAC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O,iBAAiB,CAAC,OAAe,EAAE,KAAW,EAAE,QAAQ,GAAG,IAAI;QACxE,OAAO,yBAAyB,CAC/B,cAAc,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,EACxD,EAAE,QAAQ,EAAE,EACZ;YACC,aAAa;YACb,OAAO,EAAE,IAAI,CAAC,SAAS,mBACnB,IAAI,CAAC,yBAAyB,EAAE,EAClC;SACF,CACD,CAAC;IACH,CAAC;;AA5rBe,uCAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEnE,mHAAmH;AACnH,oHAAoH;AACpG,6CAAqB,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIAnyDriverError,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnect,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\textractLogSafeErrorProperties,\n\tgetCircularReplacer,\n\tMonitoringContext,\n\tEventEmitterWithErrorHandling,\n\tnormalizeError,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport type { Socket } from \"socket.io-client\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class DocumentDeltaConnection\n\textends EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\tstatic readonly eventsToForward = [\"nack\", \"op\", \"signal\", \"pong\"];\n\n\t// WARNING: These are critical events that we can't miss, so registration for them has to be in place at all times!\n\t// Including before handshake is over, and after that (but before DeltaManager had a chance to put its own handlers)\n\tstatic readonly eventsAlwaysForwarded = [\"disconnect\", \"error\"];\n\n\t/**\n\t * Last known sequence number to ordering service at the time of connection\n\t * It may lap actual last sequence number (quite a bit, if container is very active).\n\t * But it's best information for client to figure out how far it is behind, at least\n\t * for \"read\" connections. \"write\" connections may use own \"join\" op to similar information,\n\t * that is likely to be more up-to-date.\n\t */\n\tpublic checkpointSequenceNumber: number | undefined;\n\n\t// Listen for ops sent before we receive a response to connect_document\n\tprotected readonly queuedMessages: ISequencedDocumentMessage[] = [];\n\tprotected readonly queuedSignals: ISignalMessage[] = [];\n\n\t/**\n\t * A flag to indicate whether we have our handler attached. If it's attached, we're queueing incoming ops\n\t * to later be retrieved via initialMessages.\n\t */\n\tprivate earlyOpHandlerAttached: boolean = false;\n\n\tprivate socketConnectionTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate _details: IConnected | undefined;\n\n\tprivate trackLatencyTimeout: number | undefined;\n\n\t// Listeners only needed while the connection is in progress\n\tprivate readonly connectionListeners: Map<string, (...args: any[]) => void> = new Map();\n\t// Listeners used throughout the lifetime of the DocumentDeltaConnection\n\tprivate readonly trackedListeners: Map<string, (...args: any[]) => void> = new Map();\n\n\tprotected get hasDetails(): boolean {\n\t\treturn !!this._details;\n\t}\n\n\tpublic get disposed() {\n\t\tassert(\n\t\t\tthis._disposed || this.socket.connected,\n\t\t\t0x244 /* \"Socket is closed, but connection is not!\" */,\n\t\t);\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Flag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages.\n\t * After disconnection, we flip this to prevent any stale messages from being emitted.\n\t */\n\tprotected _disposed: boolean = false;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * @deprecated Implementors should manage their own logger or monitoring context\n\t */\n\tprotected get logger(): ITelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic get details(): IConnected {\n\t\tif (!this._details) {\n\t\t\tthrow new Error(\"Internal error: calling method before _details is initialized!\");\n\t\t}\n\t\treturn this._details;\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param logger - for reporting telemetry events\n\t * @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure\n\t */\n\tprotected constructor(\n\t\tprotected readonly socket: Socket,\n\t\tpublic documentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableLongPollingDowngrades: boolean = false,\n\t\tprotected readonly connectionId?: string,\n\t) {\n\t\tsuper((name, error) => {\n\t\t\tthis.addPropsToError(error);\n\t\t\tlogger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DeltaConnection:EventException\",\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\tthis.mc = createChildMonitoringContext({ logger, namespace: \"DeltaConnection\" });\n\n\t\tthis.on(\"newListener\", (event, _listener) => {\n\t\t\tassert(!this.disposed, 0x20a /* \"register for event on disposed object\" */);\n\n\t\t\t// Some events are already forwarded - see this.addTrackedListener() calls in initialize().\n\t\t\tif (DocumentDeltaConnection.eventsAlwaysForwarded.includes(event)) {\n\t\t\t\tassert(this.trackedListeners.has(event), 0x245 /* \"tracked listener\" */);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!DocumentDeltaConnection.eventsToForward.includes(event)) {\n\t\t\t\tthrow new Error(`DocumentDeltaConnection: Registering for unknown event: ${event}`);\n\t\t\t}\n\n\t\t\t// Whenever listener is added, we should subscribe on same event on socket, so these two things\n\t\t\t// should be in sync. This currently assumes that nobody unregisters and registers back listeners,\n\t\t\t// and that there are no \"internal\" listeners installed (like \"error\" case we skip above)\n\t\t\t// Better flow might be to always unconditionally register all handlers on successful connection,\n\t\t\t// though some logic (naming assert in initialMessages getter) might need to be adjusted (it becomes noop)\n\t\t\tassert(\n\t\t\t\t(this.listeners(event).length !== 0) === this.trackedListeners.has(event),\n\t\t\t\t0x20b /* \"mismatch\" */,\n\t\t\t);\n\t\t\tif (!this.trackedListeners.has(event)) {\n\t\t\t\tif (event === \"pong\") {\n\t\t\t\t\t// Empty callback for tracking purposes in this class\n\t\t\t\t\tthis.trackedListeners.set(\"pong\", () => {});\n\n\t\t\t\t\tconst sendPingLoop = () => {\n\t\t\t\t\t\tconst start = Date.now();\n\n\t\t\t\t\t\tthis.socket.volatile?.emit(\"ping\", () => {\n\t\t\t\t\t\t\tthis.emit(\"pong\", Date.now() - start);\n\n\t\t\t\t\t\t\t// Schedule another ping event in 1 minute\n\t\t\t\t\t\t\tthis.trackLatencyTimeout = setTimeout(() => {\n\t\t\t\t\t\t\t\tsendPingLoop();\n\t\t\t\t\t\t\t}, 1000 * 60);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\n\t\t\t\t\tsendPingLoop();\n\t\t\t\t} else {\n\t\t\t\t\tthis.addTrackedListener(event, (...args: any[]) => {\n\t\t\t\t\t\tthis.emit(event, ...args);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Get the ID of the client who is sending the message\n\t *\n\t * @returns the client ID\n\t */\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\t/**\n\t * Get the mode of the client\n\t *\n\t * @returns the client mode\n\t */\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\t/**\n\t * Get the claims of the client who is sending the message\n\t *\n\t * @returns client claims\n\t */\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\t/**\n\t * Get whether or not this is an existing document\n\t *\n\t * @returns true if the document exists\n\t */\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\t/**\n\t * Get the maximum size of a message before chunking is required\n\t *\n\t * @returns the maximum size of a message before chunking is required\n\t */\n\tpublic get maxMessageSize(): number {\n\t\treturn this.details.serviceConfiguration.maxMessageSize;\n\t}\n\n\t/**\n\t * Semver of protocol being used with the service\n\t */\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\t/**\n\t * Configuration details provided by the service\n\t */\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tprivate checkNotDisposed() {\n\t\tassert(!this.disposed, 0x20c /* \"connection disposed\" */);\n\t}\n\n\t/**\n\t * Get messages sent during the connection\n\t *\n\t * @returns messages sent during the connection\n\t */\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\tthis.checkNotDisposed();\n\n\t\t// If we call this when the earlyOpHandler is not attached, then the queuedMessages may not include the\n\t\t// latest ops. This could possibly indicate that initialMessages was called twice.\n\t\tassert(this.earlyOpHandlerAttached, 0x08e /* \"Potentially missed initial messages\" */);\n\t\t// We will lose ops and perf will tank as we need to go to storage to become current!\n\t\tassert(this.listeners(\"op\").length !== 0, 0x08f /* \"No op handler is setup!\" */);\n\n\t\tthis.removeEarlyOpHandler();\n\n\t\tif (this.queuedMessages.length > 0) {\n\t\t\t// Some messages were queued.\n\t\t\t// add them to the list of initialMessages to be processed\n\t\t\tthis.details.initialMessages.push(...this.queuedMessages);\n\t\t\tthis.details.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tthis.queuedMessages.length = 0;\n\t\t}\n\t\treturn this.details.initialMessages;\n\t}\n\n\t/**\n\t * Get signals sent during the connection\n\t *\n\t * @returns signals sent during the connection\n\t */\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\tthis.checkNotDisposed();\n\t\tassert(this.listeners(\"signal\").length !== 0, 0x090 /* \"No signal handler is setup!\" */);\n\n\t\tthis.removeEarlySignalHandler();\n\n\t\tif (this.queuedSignals.length > 0) {\n\t\t\t// Some signals were queued.\n\t\t\t// add them to the list of initialSignals to be processed\n\t\t\tthis.details.initialSignals.push(...this.queuedSignals);\n\t\t\tthis.queuedSignals.length = 0;\n\t\t}\n\t\treturn this.details.initialSignals;\n\t}\n\n\t/**\n\t * Get initial client list\n\t *\n\t * @returns initial client list sent during the connection\n\t */\n\tpublic get initialClients(): ISignalClient[] {\n\t\tthis.checkNotDisposed();\n\t\treturn this.details.initialClients;\n\t}\n\n\tprotected emitMessages(type: string, messages: IDocumentMessage[][]) {\n\t\t// Although the implementation here disconnects the socket and does not reuse it, other subclasses\n\t\t// (e.g. OdspDocumentDeltaConnection) may reuse the socket. In these cases, we need to avoid emitting\n\t\t// on the still-live socket.\n\t\tif (!this.disposed) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t *\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param message - signal to submit\n\t */\n\tpublic submitSignal(message: IDocumentMessage): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitSignal\", [[message]]);\n\t}\n\n\t/**\n\t * Disconnect from the websocket and close the websocket too.\n\t */\n\tprivate closeSocket(error: IAnyDriverError) {\n\t\tif (this._disposed) {\n\t\t\t// This would be rare situation due to complexity around socket emitting events.\n\t\t\treturn;\n\t\t}\n\t\tthis.closeSocketCore(error);\n\t}\n\n\tprotected closeSocketCore(error: IAnyDriverError) {\n\t\tthis.disconnect(error);\n\t}\n\n\t/**\n\t * Disconnect from the websocket, and permanently disable this DocumentDeltaConnection and close the socket.\n\t * However the OdspDocumentDeltaConnection differ in dispose as in there we don't close the socket. There is no\n\t * multiplexing here, so we need to close the socket here.\n\t */\n\tpublic dispose() {\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"ClientClosingDeltaConnection\",\n\t\t\tdriverVersion,\n\t\t\tdetails: JSON.stringify({\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t}),\n\t\t});\n\t\tthis.disconnect(\n\t\t\tcreateGenericNetworkError(\n\t\t\t\t// pre-0.58 error message: clientClosingConnection\n\t\t\t\t\"Client closing delta connection\",\n\t\t\t\t{ canRetry: true },\n\t\t\t\t{ driverVersion },\n\t\t\t),\n\t\t);\n\t}\n\n\tprotected disconnect(err: IAnyDriverError) {\n\t\t// Can't check this.disposed here, as we get here on socket closure,\n\t\t// so _disposed & socket.connected might be not in sync while processing\n\t\t// \"dispose\" event.\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.trackLatencyTimeout !== undefined) {\n\t\t\tclearTimeout(this.trackLatencyTimeout);\n\t\t\tthis.trackLatencyTimeout = undefined;\n\t\t}\n\n\t\t// We set the disposed flag as a part of the contract for overriding the disconnect method. This is used by\n\t\t// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is\n\t\t// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that\n\t\t// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended\n\t\t// to prevent normal messages from being emitted.\n\t\tthis._disposed = true;\n\n\t\t// Remove all listeners listening on the socket. These are listeners on socket and not on this connection\n\t\t// object. Anyway since we have disposed this connection object, nobody should listen to event on socket\n\t\t// anymore.\n\t\tthis.removeTrackedListeners();\n\n\t\t// Clear the connection/socket before letting the deltaManager/connection manager know about the disconnect.\n\t\tthis.disconnectCore();\n\n\t\t// Let user of connection object know about disconnect.\n\t\tthis.emit(\"disconnect\", err);\n\t}\n\n\t/**\n\t * Disconnect from the websocket.\n\t * @param reason - reason for disconnect\n\t */\n\tprotected disconnectCore() {\n\t\tthis.socket.disconnect();\n\t}\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number) {\n\t\tthis.socket.on(\"op\", this.earlyOpHandler);\n\t\tthis.socket.on(\"signal\", this.earlySignalHandler);\n\t\tthis.earlyOpHandlerAttached = true;\n\n\t\t// Socket.io's reconnect_attempt event is unreliable, so we track connect_error count instead.\n\t\tlet internalSocketConnectionFailureCount: number = 0;\n\t\tconst isInternalSocketReconnectionEnabled = (): boolean => this.socket.io.reconnection();\n\t\tconst getMaxInternalSocketReconnectionAttempts = (): number =>\n\t\t\tisInternalSocketReconnectionEnabled() ? this.socket.io.reconnectionAttempts() : 0;\n\t\tconst getMaxAllowedInternalSocketConnectionFailures = (): number =>\n\t\t\tgetMaxInternalSocketReconnectionAttempts() + 1;\n\n\t\tthis._details = await new Promise<IConnected>((resolve, reject) => {\n\t\t\tconst failAndCloseSocket = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.closeSocket(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"CloseSocketError\" }, normalizedError);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\tconst failConnection = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.disconnect(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t\t{ eventName: \"FailConnectionError\" },\n\t\t\t\t\t\tnormalizedError,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\t// Immediately set the connection timeout.\n\t\t\t// Give extra 2 seconds for handshake on top of socket connection timeout.\n\t\t\tthis.socketConnectionTimeout = setTimeout(() => {\n\t\t\t\tfailConnection(this.createErrorObject(\"orderingServiceHandshakeTimeout\"));\n\t\t\t}, timeout + 2000);\n\n\t\t\t// Listen for connection issues\n\t\t\tthis.addConnectionListener(\"connect_error\", (error) => {\n\t\t\t\tinternalSocketConnectionFailureCount++;\n\t\t\t\tlet isWebSocketTransportError = false;\n\t\t\t\ttry {\n\t\t\t\t\tconst description = error?.description;\n\t\t\t\t\tconst context = error?.context;\n\n\t\t\t\t\tif (context && typeof context === \"object\") {\n\t\t\t\t\t\tconst statusText = context.statusText?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.context\n\t\t\t\t\t\tif (statusText === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (description && typeof description === \"object\") {\n\t\t\t\t\t\tconst errorCode = description.error?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.description\n\t\t\t\t\t\tif (errorCode === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (error.type === \"TransportError\") {\n\t\t\t\t\t\t\tisWebSocketTransportError = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// That's a WebSocket. Clear it as we can't log it.\n\t\t\t\t\t\tdescription.target = undefined;\n\t\t\t\t\t}\n\t\t\t\t} catch (_e) {}\n\n\t\t\t\t// Handle socket transport downgrading when not offline.\n\t\t\t\tif (\n\t\t\t\t\tisWebSocketTransportError &&\n\t\t\t\t\tthis.enableLongPollingDowngrades &&\n\t\t\t\t\tthis.socket.io.opts.transports?.[0] !== \"polling\"\n\t\t\t\t) {\n\t\t\t\t\t// Downgrade transports to polling upgrade mechanism.\n\t\t\t\t\tthis.socket.io.opts.transports = [\"polling\", \"websocket\"];\n\t\t\t\t\t// Don't alter reconnection behavior if already enabled.\n\t\t\t\t\tif (!isInternalSocketReconnectionEnabled()) {\n\t\t\t\t\t\t// Allow single reconnection attempt using polling upgrade mechanism.\n\t\t\t\t\t\tthis.socket.io.reconnection(true);\n\t\t\t\t\t\tthis.socket.io.reconnectionAttempts(1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Allow built-in socket.io reconnection handling.\n\t\t\t\tif (\n\t\t\t\t\tisInternalSocketReconnectionEnabled() &&\n\t\t\t\t\tinternalSocketConnectionFailureCount <\n\t\t\t\t\t\tgetMaxAllowedInternalSocketConnectionFailures()\n\t\t\t\t) {\n\t\t\t\t\t// Reconnection is enabled and maximum reconnect attempts have not been reached.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_error\", error));\n\t\t\t});\n\n\t\t\t// Listen for timeouts\n\t\t\tthis.addConnectionListener(\"connect_timeout\", () => {\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_timeout\"));\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_success\", (response: IConnected) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst requestedMode = connectMessage.mode;\n\t\t\t\tconst actualMode = response.mode;\n\t\t\t\tconst writingPermitted = response.claims.scopes.includes(ScopeType.DocWrite);\n\n\t\t\t\tif (writingPermitted) {\n\t\t\t\t\t// The only time we expect a mismatch in requested/actual is if we lack write permissions\n\t\t\t\t\t// In this case we will get \"read\", even if we requested \"write\"\n\t\t\t\t\tif (actualMode !== requestedMode) {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in a different mode than was requested\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (actualMode === \"write\") {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in write mode without write permissions\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.checkpointSequenceNumber = response.checkpointSequenceNumber;\n\n\t\t\t\tthis.removeConnectionListeners();\n\t\t\t\tresolve(response);\n\t\t\t});\n\n\t\t\t// Socket can be disconnected while waiting for Fluid protocol messages\n\t\t\t// (connect_document_error / connect_document_success), as well as before DeltaManager\n\t\t\t// had a chance to register its handlers.\n\t\t\tthis.addTrackedListener(\"disconnect\", (reason, details) => {\n\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\tthis.createErrorObjectWithProps(\"disconnect\", reason, {\n\t\t\t\t\t\tsocketErrorType: details?.context?.type,\n\t\t\t\t\t\t// https://www.rfc-editor.org/rfc/rfc6455#section-7.4\n\t\t\t\t\t\tsocketCode: details?.context?.code,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tthis.addTrackedListener(\"error\", (error) => {\n\t\t\t\t// This includes \"Invalid namespace\" error, which we consider critical (reconnecting will not help)\n\t\t\t\tconst err = this.createErrorObject(\"error\", error, error !== \"Invalid namespace\");\n\t\t\t\t// Disconnect socket - required if happened before initial handshake\n\t\t\t\tfailAndCloseSocket(err);\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_error\", (error) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// This is not an socket.io error - it's Fluid protocol error.\n\t\t\t\t// In this case fail connection and indicate that we were unable to create connection\n\t\t\t\tfailConnection(this.createErrorObject(\"connect_document_error\", error));\n\t\t\t});\n\n\t\t\tthis.socket.emit(\"connect_document\", connectMessage);\n\t\t});\n\n\t\tassert(!this.disposed, 0x246 /* \"checking consistency of socket & _disposed flags\" */);\n\t}\n\n\tprivate addPropsToError(errorToBeNormalized: unknown) {\n\t\tconst normalizedError = normalizeError(errorToBeNormalized, {\n\t\t\tprops: {\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t});\n\t\treturn normalizedError;\n\t}\n\n\tprotected getConnectionDetailsProps() {\n\t\treturn {\n\t\t\tdisposed: this._disposed,\n\t\t\tsocketConnected: this.socket?.connected,\n\t\t\tclientId: this._details?.clientId,\n\t\t\tconnectionId: this.connectionId,\n\t\t};\n\t}\n\n\tprotected earlyOpHandler = (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\tthis.queuedMessages.push(...msgs);\n\t};\n\n\tprotected earlySignalHandler = (msg: ISignalMessage) => {\n\t\tthis.queuedSignals.push(msg);\n\t};\n\n\tprivate removeEarlyOpHandler() {\n\t\tthis.socket.removeListener(\"op\", this.earlyOpHandler);\n\t\tthis.earlyOpHandlerAttached = false;\n\t}\n\n\tprivate removeEarlySignalHandler() {\n\t\tthis.socket.removeListener(\"signal\", this.earlySignalHandler);\n\t}\n\n\tprivate addConnectionListener(event: string, listener: (...args: any[]) => void) {\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsAlwaysForwarded.includes(event),\n\t\t\t0x247 /* \"Use addTrackedListener instead\" */,\n\t\t);\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsToForward.includes(event),\n\t\t\t0x248 /* \"should not subscribe to forwarded events\" */,\n\t\t);\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.connectionListeners.has(event), 0x20d /* \"double connection listener\" */);\n\t\tthis.connectionListeners.set(event, listener);\n\t}\n\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.trackedListeners.has(event), 0x20e /* \"double tracked listener\" */);\n\t\tthis.trackedListeners.set(event, listener);\n\t}\n\n\tprivate removeTrackedListeners() {\n\t\tfor (const [event, listener] of this.trackedListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\t// removeTrackedListeners removes all listeners, including connection listeners\n\t\tthis.removeConnectionListeners();\n\n\t\tthis.removeEarlyOpHandler();\n\t\tthis.removeEarlySignalHandler();\n\n\t\tthis.trackedListeners.clear();\n\t}\n\n\tprivate removeConnectionListeners() {\n\t\tif (this.socketConnectionTimeout !== undefined) {\n\t\t\tclearTimeout(this.socketConnectionTimeout);\n\t\t}\n\n\t\tfor (const [event, listener] of this.connectionListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\tthis.connectionListeners.clear();\n\t}\n\n\tprivate getErrorMessage(error?: any): string {\n\t\tif (error?.type !== \"TransportError\") {\n\t\t\treturn extractLogSafeErrorProperties(error, true).message;\n\t\t}\n\t\t// JSON.stringify drops Error.message\n\t\tconst messagePrefix = error?.message !== undefined ? `${error.message}: ` : \"\";\n\n\t\t// Websocket errors reported by engine.io-client.\n\t\t// They are Error objects with description containing WS error and description = \"TransportError\"\n\t\t// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,\n\t\treturn `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;\n\t}\n\n\tprivate createErrorObjectWithProps(\n\t\thandler: string,\n\t\terror?: any,\n\t\tprops?: ITelemetryProperties,\n\t\tcanRetry = true,\n\t): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\t...props,\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAMtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAUN,SAAS,GACT,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAEN,6BAA6B,EAC7B,mBAAmB,EAEnB,6BAA6B,EAC7B,cAAc,EACd,4BAA4B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,sFAAsF;AACtF,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,uBACZ,SAAQ,6BAA6D;IAwErE;;;;;OAKG;IACH,YACoB,MAAc,EAC1B,UAAkB,EACzB,MAA2B,EACV,8BAAuC,KAAK,EAC1C,YAAqB;QAExC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EA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AC;IAEO,0BAA0B,CACjC,OAAe,EACf,KAAW,EACX,KAA4B,EAC5B,QAAQ,GAAG,IAAI;QAEf,OAAO,yBAAyB,CAC/B,cAAc,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,EACxD,EAAE,QAAQ,EAAE,EACZ;YACC,GAAG,KAAK;YACR,aAAa;YACb,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;gBACvB,GAAG,IAAI,CAAC,yBAAyB,EAAE;aACnC,CAAC;SACF,CACD,CAAC;IACH,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,OAAe,EAAE,KAAW,EAAE,QAAQ,GAAG,IAAI;QACxE,OAAO,yBAAyB,CAC/B,cAAc,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,EACxD,EAAE,QAAQ,EAAE,EACZ;YACC,aAAa;YACb,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;gBACvB,GAAG,IAAI,CAAC,yBAAyB,EAAE;aACnC,CAAC;SACF,CACD,CAAC;IACH,CAAC;;AA5rBe,uCAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEnE,mHAAmH;AACnH,oHAAoH;AACpG,6CAAqB,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIAnyDriverError,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnect,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\textractLogSafeErrorProperties,\n\tgetCircularReplacer,\n\tMonitoringContext,\n\tEventEmitterWithErrorHandling,\n\tnormalizeError,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport type { Socket } from \"socket.io-client\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class DocumentDeltaConnection\n\textends EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\tstatic readonly eventsToForward = [\"nack\", \"op\", \"signal\", \"pong\"];\n\n\t// WARNING: These are critical events that we can't miss, so registration for them has to be in place at all times!\n\t// Including before handshake is over, and after that (but before DeltaManager had a chance to put its own handlers)\n\tstatic readonly eventsAlwaysForwarded = [\"disconnect\", \"error\"];\n\n\t/**\n\t * Last known sequence number to ordering service at the time of connection\n\t * It may lap actual last sequence number (quite a bit, if container is very active).\n\t * But it's best information for client to figure out how far it is behind, at least\n\t * for \"read\" connections. \"write\" connections may use own \"join\" op to similar information,\n\t * that is likely to be more up-to-date.\n\t */\n\tpublic checkpointSequenceNumber: number | undefined;\n\n\t// Listen for ops sent before we receive a response to connect_document\n\tprotected readonly queuedMessages: ISequencedDocumentMessage[] = [];\n\tprotected readonly queuedSignals: ISignalMessage[] = [];\n\n\t/**\n\t * A flag to indicate whether we have our handler attached. If it's attached, we're queueing incoming ops\n\t * to later be retrieved via initialMessages.\n\t */\n\tprivate earlyOpHandlerAttached: boolean = false;\n\n\tprivate socketConnectionTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate _details: IConnected | undefined;\n\n\tprivate trackLatencyTimeout: number | undefined;\n\n\t// Listeners only needed while the connection is in progress\n\tprivate readonly connectionListeners: Map<string, (...args: any[]) => void> = new Map();\n\t// Listeners used throughout the lifetime of the DocumentDeltaConnection\n\tprivate readonly trackedListeners: Map<string, (...args: any[]) => void> = new Map();\n\n\tprotected get hasDetails(): boolean {\n\t\treturn !!this._details;\n\t}\n\n\tpublic get disposed() {\n\t\tassert(\n\t\t\tthis._disposed || this.socket.connected,\n\t\t\t0x244 /* \"Socket is closed, but connection is not!\" */,\n\t\t);\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Flag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages.\n\t * After disconnection, we flip this to prevent any stale messages from being emitted.\n\t */\n\tprotected _disposed: boolean = false;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * @deprecated Implementors should manage their own logger or monitoring context\n\t */\n\tprotected get logger(): ITelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\n\n\tpublic get details(): IConnected {\n\t\tif (!this._details) {\n\t\t\tthrow new Error(\"Internal error: calling method before _details is initialized!\");\n\t\t}\n\t\treturn this._details;\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param logger - for reporting telemetry events\n\t * @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure\n\t */\n\tprotected constructor(\n\t\tprotected readonly socket: Socket,\n\t\tpublic documentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableLongPollingDowngrades: boolean = false,\n\t\tprotected readonly connectionId?: string,\n\t) {\n\t\tsuper((name, error) => {\n\t\t\tthis.addPropsToError(error);\n\t\t\tlogger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DeltaConnection:EventException\",\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\tthis.mc = createChildMonitoringContext({ logger, namespace: \"DeltaConnection\" });\n\n\t\tthis.on(\"newListener\", (event, _listener) => {\n\t\t\tassert(!this.disposed, 0x20a /* \"register for event on disposed object\" */);\n\n\t\t\t// Some events are already forwarded - see this.addTrackedListener() calls in initialize().\n\t\t\tif (DocumentDeltaConnection.eventsAlwaysForwarded.includes(event)) {\n\t\t\t\tassert(this.trackedListeners.has(event), 0x245 /* \"tracked listener\" */);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!DocumentDeltaConnection.eventsToForward.includes(event)) {\n\t\t\t\tthrow new Error(`DocumentDeltaConnection: Registering for unknown event: ${event}`);\n\t\t\t}\n\n\t\t\t// Whenever listener is added, we should subscribe on same event on socket, so these two things\n\t\t\t// should be in sync. This currently assumes that nobody unregisters and registers back listeners,\n\t\t\t// and that there are no \"internal\" listeners installed (like \"error\" case we skip above)\n\t\t\t// Better flow might be to always unconditionally register all handlers on successful connection,\n\t\t\t// though some logic (naming assert in initialMessages getter) might need to be adjusted (it becomes noop)\n\t\t\tassert(\n\t\t\t\t(this.listeners(event).length !== 0) === this.trackedListeners.has(event),\n\t\t\t\t0x20b /* \"mismatch\" */,\n\t\t\t);\n\t\t\tif (!this.trackedListeners.has(event)) {\n\t\t\t\tif (event === \"pong\") {\n\t\t\t\t\t// Empty callback for tracking purposes in this class\n\t\t\t\t\tthis.trackedListeners.set(\"pong\", () => {});\n\n\t\t\t\t\tconst sendPingLoop = () => {\n\t\t\t\t\t\tconst start = Date.now();\n\n\t\t\t\t\t\tthis.socket.volatile?.emit(\"ping\", () => {\n\t\t\t\t\t\t\tthis.emit(\"pong\", Date.now() - start);\n\n\t\t\t\t\t\t\t// Schedule another ping event in 1 minute\n\t\t\t\t\t\t\tthis.trackLatencyTimeout = setTimeout(() => {\n\t\t\t\t\t\t\t\tsendPingLoop();\n\t\t\t\t\t\t\t}, 1000 * 60);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\n\t\t\t\t\tsendPingLoop();\n\t\t\t\t} else {\n\t\t\t\t\tthis.addTrackedListener(event, (...args: any[]) => {\n\t\t\t\t\t\tthis.emit(event, ...args);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Get the ID of the client who is sending the message\n\t *\n\t * @returns the client ID\n\t */\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\t/**\n\t * Get the mode of the client\n\t *\n\t * @returns the client mode\n\t */\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\t/**\n\t * Get the claims of the client who is sending the message\n\t *\n\t * @returns client claims\n\t */\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\t/**\n\t * Get whether or not this is an existing document\n\t *\n\t * @returns true if the document exists\n\t */\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\t/**\n\t * Get the maximum size of a message before chunking is required\n\t *\n\t * @returns the maximum size of a message before chunking is required\n\t */\n\tpublic get maxMessageSize(): number {\n\t\treturn this.details.serviceConfiguration.maxMessageSize;\n\t}\n\n\t/**\n\t * Semver of protocol being used with the service\n\t */\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\t/**\n\t * Configuration details provided by the service\n\t */\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tprivate checkNotDisposed() {\n\t\tassert(!this.disposed, 0x20c /* \"connection disposed\" */);\n\t}\n\n\t/**\n\t * Get messages sent during the connection\n\t *\n\t * @returns messages sent during the connection\n\t */\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\tthis.checkNotDisposed();\n\n\t\t// If we call this when the earlyOpHandler is not attached, then the queuedMessages may not include the\n\t\t// latest ops. This could possibly indicate that initialMessages was called twice.\n\t\tassert(this.earlyOpHandlerAttached, 0x08e /* \"Potentially missed initial messages\" */);\n\t\t// We will lose ops and perf will tank as we need to go to storage to become current!\n\t\tassert(this.listeners(\"op\").length !== 0, 0x08f /* \"No op handler is setup!\" */);\n\n\t\tthis.removeEarlyOpHandler();\n\n\t\tif (this.queuedMessages.length > 0) {\n\t\t\t// Some messages were queued.\n\t\t\t// add them to the list of initialMessages to be processed\n\t\t\tthis.details.initialMessages.push(...this.queuedMessages);\n\t\t\tthis.details.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n\t\t\tthis.queuedMessages.length = 0;\n\t\t}\n\t\treturn this.details.initialMessages;\n\t}\n\n\t/**\n\t * Get signals sent during the connection\n\t *\n\t * @returns signals sent during the connection\n\t */\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\tthis.checkNotDisposed();\n\t\tassert(this.listeners(\"signal\").length !== 0, 0x090 /* \"No signal handler is setup!\" */);\n\n\t\tthis.removeEarlySignalHandler();\n\n\t\tif (this.queuedSignals.length > 0) {\n\t\t\t// Some signals were queued.\n\t\t\t// add them to the list of initialSignals to be processed\n\t\t\tthis.details.initialSignals.push(...this.queuedSignals);\n\t\t\tthis.queuedSignals.length = 0;\n\t\t}\n\t\treturn this.details.initialSignals;\n\t}\n\n\t/**\n\t * Get initial client list\n\t *\n\t * @returns initial client list sent during the connection\n\t */\n\tpublic get initialClients(): ISignalClient[] {\n\t\tthis.checkNotDisposed();\n\t\treturn this.details.initialClients;\n\t}\n\n\tprotected emitMessages(type: string, messages: IDocumentMessage[][]) {\n\t\t// Although the implementation here disconnects the socket and does not reuse it, other subclasses\n\t\t// (e.g. OdspDocumentDeltaConnection) may reuse the socket. In these cases, we need to avoid emitting\n\t\t// on the still-live socket.\n\t\tif (!this.disposed) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t *\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param message - signal to submit\n\t */\n\tpublic submitSignal(message: IDocumentMessage): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.emitMessages(\"submitSignal\", [[message]]);\n\t}\n\n\t/**\n\t * Disconnect from the websocket and close the websocket too.\n\t */\n\tprivate closeSocket(error: IAnyDriverError) {\n\t\tif (this._disposed) {\n\t\t\t// This would be rare situation due to complexity around socket emitting events.\n\t\t\treturn;\n\t\t}\n\t\tthis.closeSocketCore(error);\n\t}\n\n\tprotected closeSocketCore(error: IAnyDriverError) {\n\t\tthis.disconnect(error);\n\t}\n\n\t/**\n\t * Disconnect from the websocket, and permanently disable this DocumentDeltaConnection and close the socket.\n\t * However the OdspDocumentDeltaConnection differ in dispose as in there we don't close the socket. There is no\n\t * multiplexing here, so we need to close the socket here.\n\t */\n\tpublic dispose() {\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"ClientClosingDeltaConnection\",\n\t\t\tdriverVersion,\n\t\t\tdetails: JSON.stringify({\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t}),\n\t\t});\n\t\tthis.disconnect(\n\t\t\tcreateGenericNetworkError(\n\t\t\t\t// pre-0.58 error message: clientClosingConnection\n\t\t\t\t\"Client closing delta connection\",\n\t\t\t\t{ canRetry: true },\n\t\t\t\t{ driverVersion },\n\t\t\t),\n\t\t);\n\t}\n\n\tprotected disconnect(err: IAnyDriverError) {\n\t\t// Can't check this.disposed here, as we get here on socket closure,\n\t\t// so _disposed & socket.connected might be not in sync while processing\n\t\t// \"dispose\" event.\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.trackLatencyTimeout !== undefined) {\n\t\t\tclearTimeout(this.trackLatencyTimeout);\n\t\t\tthis.trackLatencyTimeout = undefined;\n\t\t}\n\n\t\t// We set the disposed flag as a part of the contract for overriding the disconnect method. This is used by\n\t\t// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is\n\t\t// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that\n\t\t// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended\n\t\t// to prevent normal messages from being emitted.\n\t\tthis._disposed = true;\n\n\t\t// Remove all listeners listening on the socket. These are listeners on socket and not on this connection\n\t\t// object. Anyway since we have disposed this connection object, nobody should listen to event on socket\n\t\t// anymore.\n\t\tthis.removeTrackedListeners();\n\n\t\t// Clear the connection/socket before letting the deltaManager/connection manager know about the disconnect.\n\t\tthis.disconnectCore();\n\n\t\t// Let user of connection object know about disconnect.\n\t\tthis.emit(\"disconnect\", err);\n\t}\n\n\t/**\n\t * Disconnect from the websocket.\n\t * @param reason - reason for disconnect\n\t */\n\tprotected disconnectCore() {\n\t\tthis.socket.disconnect();\n\t}\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number) {\n\t\tthis.socket.on(\"op\", this.earlyOpHandler);\n\t\tthis.socket.on(\"signal\", this.earlySignalHandler);\n\t\tthis.earlyOpHandlerAttached = true;\n\n\t\t// Socket.io's reconnect_attempt event is unreliable, so we track connect_error count instead.\n\t\tlet internalSocketConnectionFailureCount: number = 0;\n\t\tconst isInternalSocketReconnectionEnabled = (): boolean => this.socket.io.reconnection();\n\t\tconst getMaxInternalSocketReconnectionAttempts = (): number =>\n\t\t\tisInternalSocketReconnectionEnabled() ? this.socket.io.reconnectionAttempts() : 0;\n\t\tconst getMaxAllowedInternalSocketConnectionFailures = (): number =>\n\t\t\tgetMaxInternalSocketReconnectionAttempts() + 1;\n\n\t\tthis._details = await new Promise<IConnected>((resolve, reject) => {\n\t\t\tconst failAndCloseSocket = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.closeSocket(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"CloseSocketError\" }, normalizedError);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\tconst failConnection = (err: IAnyDriverError) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.disconnect(err);\n\t\t\t\t} catch (failError) {\n\t\t\t\t\tconst normalizedError = this.addPropsToError(failError);\n\t\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t\t{ eventName: \"FailConnectionError\" },\n\t\t\t\t\t\tnormalizedError,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\t// Immediately set the connection timeout.\n\t\t\t// Give extra 2 seconds for handshake on top of socket connection timeout.\n\t\t\tthis.socketConnectionTimeout = setTimeout(() => {\n\t\t\t\tfailConnection(this.createErrorObject(\"orderingServiceHandshakeTimeout\"));\n\t\t\t}, timeout + 2000);\n\n\t\t\t// Listen for connection issues\n\t\t\tthis.addConnectionListener(\"connect_error\", (error) => {\n\t\t\t\tinternalSocketConnectionFailureCount++;\n\t\t\t\tlet isWebSocketTransportError = false;\n\t\t\t\ttry {\n\t\t\t\t\tconst description = error?.description;\n\t\t\t\t\tconst context = error?.context;\n\n\t\t\t\t\tif (context && typeof context === \"object\") {\n\t\t\t\t\t\tconst statusText = context.statusText?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.context\n\t\t\t\t\t\tif (statusText === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (description && typeof description === \"object\") {\n\t\t\t\t\t\tconst errorCode = description.error?.code;\n\n\t\t\t\t\t\t// Self-Signed Certificate ErrorCode Found in error.description\n\t\t\t\t\t\tif (errorCode === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n\t\t\t\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\t\t\t\tthis.createErrorObject(\"connect_error\", error, false),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (error.type === \"TransportError\") {\n\t\t\t\t\t\t\tisWebSocketTransportError = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// That's a WebSocket. Clear it as we can't log it.\n\t\t\t\t\t\tdescription.target = undefined;\n\t\t\t\t\t}\n\t\t\t\t} catch (_e) {}\n\n\t\t\t\t// Handle socket transport downgrading when not offline.\n\t\t\t\tif (\n\t\t\t\t\tisWebSocketTransportError &&\n\t\t\t\t\tthis.enableLongPollingDowngrades &&\n\t\t\t\t\tthis.socket.io.opts.transports?.[0] !== \"polling\"\n\t\t\t\t) {\n\t\t\t\t\t// Downgrade transports to polling upgrade mechanism.\n\t\t\t\t\tthis.socket.io.opts.transports = [\"polling\", \"websocket\"];\n\t\t\t\t\t// Don't alter reconnection behavior if already enabled.\n\t\t\t\t\tif (!isInternalSocketReconnectionEnabled()) {\n\t\t\t\t\t\t// Allow single reconnection attempt using polling upgrade mechanism.\n\t\t\t\t\t\tthis.socket.io.reconnection(true);\n\t\t\t\t\t\tthis.socket.io.reconnectionAttempts(1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Allow built-in socket.io reconnection handling.\n\t\t\t\tif (\n\t\t\t\t\tisInternalSocketReconnectionEnabled() &&\n\t\t\t\t\tinternalSocketConnectionFailureCount <\n\t\t\t\t\t\tgetMaxAllowedInternalSocketConnectionFailures()\n\t\t\t\t) {\n\t\t\t\t\t// Reconnection is enabled and maximum reconnect attempts have not been reached.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_error\", error));\n\t\t\t});\n\n\t\t\t// Listen for timeouts\n\t\t\tthis.addConnectionListener(\"connect_timeout\", () => {\n\t\t\t\tfailAndCloseSocket(this.createErrorObject(\"connect_timeout\"));\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_success\", (response: IConnected) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== undefined &&\n\t\t\t\t\tresponse.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst requestedMode = connectMessage.mode;\n\t\t\t\tconst actualMode = response.mode;\n\t\t\t\tconst writingPermitted = response.claims.scopes.includes(ScopeType.DocWrite);\n\n\t\t\t\tif (writingPermitted) {\n\t\t\t\t\t// The only time we expect a mismatch in requested/actual is if we lack write permissions\n\t\t\t\t\t// In this case we will get \"read\", even if we requested \"write\"\n\t\t\t\t\tif (actualMode !== requestedMode) {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in a different mode than was requested\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (actualMode === \"write\") {\n\t\t\t\t\t\tfailConnection(\n\t\t\t\t\t\t\tthis.createErrorObject(\n\t\t\t\t\t\t\t\t\"connect_document_success\",\n\t\t\t\t\t\t\t\t\"Connected in write mode without write permissions\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.checkpointSequenceNumber = response.checkpointSequenceNumber;\n\n\t\t\t\tthis.removeConnectionListeners();\n\t\t\t\tresolve(response);\n\t\t\t});\n\n\t\t\t// Socket can be disconnected while waiting for Fluid protocol messages\n\t\t\t// (connect_document_error / connect_document_success), as well as before DeltaManager\n\t\t\t// had a chance to register its handlers.\n\t\t\tthis.addTrackedListener(\"disconnect\", (reason, details) => {\n\t\t\t\tfailAndCloseSocket(\n\t\t\t\t\tthis.createErrorObjectWithProps(\"disconnect\", reason, {\n\t\t\t\t\t\tsocketErrorType: details?.context?.type,\n\t\t\t\t\t\t// https://www.rfc-editor.org/rfc/rfc6455#section-7.4\n\t\t\t\t\t\tsocketCode: details?.context?.code,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tthis.addTrackedListener(\"error\", (error) => {\n\t\t\t\t// This includes \"Invalid namespace\" error, which we consider critical (reconnecting will not help)\n\t\t\t\tconst err = this.createErrorObject(\"error\", error, error !== \"Invalid namespace\");\n\t\t\t\t// Disconnect socket - required if happened before initial handshake\n\t\t\t\tfailAndCloseSocket(err);\n\t\t\t});\n\n\t\t\tthis.addConnectionListener(\"connect_document_error\", (error) => {\n\t\t\t\t// If we sent a nonce and the server supports nonces, check that the nonces match\n\t\t\t\tif (\n\t\t\t\t\tconnectMessage.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== undefined &&\n\t\t\t\t\terror.nonce !== connectMessage.nonce\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// This is not an socket.io error - it's Fluid protocol error.\n\t\t\t\t// In this case fail connection and indicate that we were unable to create connection\n\t\t\t\tfailConnection(this.createErrorObject(\"connect_document_error\", error));\n\t\t\t});\n\n\t\t\tthis.socket.emit(\"connect_document\", connectMessage);\n\t\t});\n\n\t\tassert(!this.disposed, 0x246 /* \"checking consistency of socket & _disposed flags\" */);\n\t}\n\n\tprivate addPropsToError(errorToBeNormalized: unknown) {\n\t\tconst normalizedError = normalizeError(errorToBeNormalized, {\n\t\t\tprops: {\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t});\n\t\treturn normalizedError;\n\t}\n\n\tprotected getConnectionDetailsProps() {\n\t\treturn {\n\t\t\tdisposed: this._disposed,\n\t\t\tsocketConnected: this.socket?.connected,\n\t\t\tclientId: this._details?.clientId,\n\t\t\tconnectionId: this.connectionId,\n\t\t};\n\t}\n\n\tprotected earlyOpHandler = (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\tthis.queuedMessages.push(...msgs);\n\t};\n\n\tprotected earlySignalHandler = (msg: ISignalMessage) => {\n\t\tthis.queuedSignals.push(msg);\n\t};\n\n\tprivate removeEarlyOpHandler() {\n\t\tthis.socket.removeListener(\"op\", this.earlyOpHandler);\n\t\tthis.earlyOpHandlerAttached = false;\n\t}\n\n\tprivate removeEarlySignalHandler() {\n\t\tthis.socket.removeListener(\"signal\", this.earlySignalHandler);\n\t}\n\n\tprivate addConnectionListener(event: string, listener: (...args: any[]) => void) {\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsAlwaysForwarded.includes(event),\n\t\t\t0x247 /* \"Use addTrackedListener instead\" */,\n\t\t);\n\t\tassert(\n\t\t\t!DocumentDeltaConnection.eventsToForward.includes(event),\n\t\t\t0x248 /* \"should not subscribe to forwarded events\" */,\n\t\t);\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.connectionListeners.has(event), 0x20d /* \"double connection listener\" */);\n\t\tthis.connectionListeners.set(event, listener);\n\t}\n\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n\t\tthis.socket.on(event, listener);\n\t\tassert(!this.trackedListeners.has(event), 0x20e /* \"double tracked listener\" */);\n\t\tthis.trackedListeners.set(event, listener);\n\t}\n\n\tprivate removeTrackedListeners() {\n\t\tfor (const [event, listener] of this.trackedListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\t// removeTrackedListeners removes all listeners, including connection listeners\n\t\tthis.removeConnectionListeners();\n\n\t\tthis.removeEarlyOpHandler();\n\t\tthis.removeEarlySignalHandler();\n\n\t\tthis.trackedListeners.clear();\n\t}\n\n\tprivate removeConnectionListeners() {\n\t\tif (this.socketConnectionTimeout !== undefined) {\n\t\t\tclearTimeout(this.socketConnectionTimeout);\n\t\t}\n\n\t\tfor (const [event, listener] of this.connectionListeners.entries()) {\n\t\t\tthis.socket.off(event, listener);\n\t\t}\n\t\tthis.connectionListeners.clear();\n\t}\n\n\tprivate getErrorMessage(error?: any): string {\n\t\tif (error?.type !== \"TransportError\") {\n\t\t\treturn extractLogSafeErrorProperties(error, true).message;\n\t\t}\n\t\t// JSON.stringify drops Error.message\n\t\tconst messagePrefix = error?.message !== undefined ? `${error.message}: ` : \"\";\n\n\t\t// Websocket errors reported by engine.io-client.\n\t\t// They are Error objects with description containing WS error and description = \"TransportError\"\n\t\t// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,\n\t\treturn `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;\n\t}\n\n\tprivate createErrorObjectWithProps(\n\t\thandler: string,\n\t\terror?: any,\n\t\tprops?: ITelemetryProperties,\n\t\tcanRetry = true,\n\t): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\t...props,\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\treturn createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${this.getErrorMessage(error)}`,\n\t\t\t{ canRetry },\n\t\t\t{\n\t\t\t\tdriverVersion,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
|
package/lib/driverUtils.js
CHANGED
|
@@ -22,7 +22,6 @@ export function getW3CData(url, initiatorType) {
|
|
|
22
22
|
// domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.
|
|
23
23
|
// redirectStart: start time of the fetch which that initiates the redirect.
|
|
24
24
|
// redirectEnd: immediately after receiving the last byte of the response of the last redirect.
|
|
25
|
-
var _a, _b;
|
|
26
25
|
// Interval between start and finish of the domain name lookup for the resource.
|
|
27
26
|
let dnsLookupTime; // domainLookupEnd - domainLookupStart
|
|
28
27
|
// Interval between the first fetch until the last byte of the last redirect.
|
|
@@ -42,7 +41,7 @@ export function getW3CData(url, initiatorType) {
|
|
|
42
41
|
let reqStartToResponseEndTime; // responseEnd - requestStart
|
|
43
42
|
let w3cStartTime; // W3C Start time = fetchStart time
|
|
44
43
|
// getEntriesByType is only available in browser performance object
|
|
45
|
-
const resources1 =
|
|
44
|
+
const resources1 = performance.getEntriesByType?.("resource") ?? [];
|
|
46
45
|
// Usually the latest fetch call is to the end of resources, so we start from the end.
|
|
47
46
|
for (let i = resources1.length - 1; i > 0; i--) {
|
|
48
47
|
const indResTime = resources1[i];
|
package/lib/driverUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driverUtils.js","sourceRoot":"","sources":["../src/driverUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,aAAqB;IAC5D,mFAAmF;IACnF,2EAA2E;IAC3E,8FAA8F;IAC9F,wGAAwG;IACxG,oFAAoF;IACpF,gGAAgG;IAChG,mGAAmG;IACnG,mGAAmG;IACnG,2FAA2F;IAC3F,oGAAoG;IACpG,mGAAmG;IACnG,4EAA4E;IAC5E,+FAA+F;;IAE/F,gFAAgF;IAChF,IAAI,aAAiC,CAAC,CAAC,sCAAsC;IAC7E,6EAA6E;IAC7E,IAAI,YAAgC,CAAC,CAAC,8BAA8B;IACpE,2EAA2E;IAC3E,IAAI,gBAAoC,CAAC,CAAC,6BAA6B;IACvE,mGAAmG;IACnG,oCAAoC;IACpC,IAAI,oBAAwC,CAAC,CAAC,sCAAsC;IACpF,iEAAiE;IACjE,IAAI,mBAAuC,CAAC,CAAC,6BAA6B;IAC1E,sEAAsE;IACtE,iDAAiD;IACjD,IAAI,2BAA+C,CAA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GAAG,MAAM,EAAE;YAC/B,iFAAiF;YACjF,0DAA0D;YAC1D,IAAI,MAAM,IAAI,IAAI,KAAK,KAAK,EAAE;gBAC7B,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;aACpB;iBAAM;gBACN,IAAI,aAAa,GAAG,CAAC,CAAC;gBACtB,OACC,aAAa,GAAG,QAAQ,CAAC,MAAM;oBAC/B,QAAQ,CAAC,aAAa,CAAC,CAAC,cAAc;wBACrC,QAAQ,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,EAC9C;oBACD,aAAa,EAAE,CAAC;iBAChB;gBACD,QAAQ,CAAC,MAAM,GAAG,aAAa,CAAC;aAChC;YACD,MAAM,CAAC,cAAc,CAAC;gBACrB,SAAS,EAAE,mBAAmB;gBAC9B,MAAM;gBACN,IAAI;gBACJ,KAAK;gBACL,IAAI;gBACJ,MAAM;gBACN,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,WAAW,EAAE,QAAQ,CAAC,MAAM;oBAC5B,oBAAoB,EACnB,QAAQ,CAAC,MAAM,GAAG,CAAC;wBAClB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;wBAC9C,CAAC,CAAC,SAAS;oBACb,MAAM;iBACN,CAAC;aACF,CAAC,CAAC;SACH;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\n/**\n * Extract and return the w3c data.\n * @param url - request url for which w3c data needs to be reported.\n * @param initiatorType - type of the network call\n */\nexport function getW3CData(url: string, initiatorType: string) {\n\t// From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n\t// fetchStart: immediately before the browser starts to fetch the resource.\n\t// requestStart: immediately before the browser starts requesting the resource from the server\n\t// responseStart: immediately after the browser receives the first byte of the response from the server.\n\t// responseEnd: immediately after the browser receives the last byte of the resource\n\t// or immediately before the transport connection is closed, whichever comes first.\n\t// secureConnectionStart: immediately before the browser starts the handshake process to secure the\n\t// current connection. If a secure connection is not used, this property returns zero.\n\t// startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n\t// domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n\t// domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n\t// redirectStart: start time of the fetch which that initiates the redirect.\n\t// redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n\n\t// Interval between start and finish of the domain name lookup for the resource.\n\tlet dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n\t// Interval between the first fetch until the last byte of the last redirect.\n\tlet redirectTime: number | undefined; // redirectEnd - redirectStart\n\t// Time to establish the connection to the server to retrieve the resource.\n\tlet tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n\t// Time from the end of the connection until the inital handshake process to secure the connection.\n\t// If 0, then no time is spent here.\n\tlet secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n\t// Interval to receive all (first to last) bytes form the server.\n\tlet responseNetworkTime: number | undefined; // responsEnd - responseStart\n\t// Interval between the initial fetch until the last byte is received.\n\t// Likely same as fetchTime + receiveContentTime.\n\tlet fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n\t// reqStartToResponseEndTime = fetchStartToResponseEndTime - <initial TCP handshake>\n\t// Interval between starting the request for the resource until receiving the last byte.\n\tlet reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n\tlet w3cStartTime: number | undefined; // W3C Start time = fetchStart time\n\n\t// getEntriesByType is only available in browser performance object\n\tconst resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n\t// Usually the latest fetch call is to the end of resources, so we start from the end.\n\tfor (let i = resources1.length - 1; i > 0; i--) {\n\t\tconst indResTime = resources1[i] as PerformanceResourceTiming;\n\t\tconst resource_name = indResTime.name.toString();\n\t\tconst resource_initiatortype = indResTime.initiatorType;\n\t\tif (\n\t\t\tresource_initiatortype.localeCompare(initiatorType) === 0 &&\n\t\t\tresource_name.includes(url)\n\t\t) {\n\t\t\tredirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n\t\t\tw3cStartTime = indResTime.fetchStart;\n\t\t\tdnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n\t\t\ttcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n\t\t\tsecureConnectionTime =\n\t\t\t\tindResTime.secureConnectionStart > 0\n\t\t\t\t\t? indResTime.connectEnd - indResTime.secureConnectionStart\n\t\t\t\t\t: 0;\n\t\t\tresponseNetworkTime =\n\t\t\t\tindResTime.responseStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.responseStart\n\t\t\t\t\t: undefined;\n\t\t\tfetchStartToResponseEndTime =\n\t\t\t\tindResTime.fetchStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.fetchStart\n\t\t\t\t\t: undefined;\n\t\t\treqStartToResponseEndTime =\n\t\t\t\tindResTime.requestStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.requestStart\n\t\t\t\t\t: undefined;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn {\n\t\tdnsLookupTime,\n\t\tw3cStartTime,\n\t\tredirectTime,\n\t\ttcpHandshakeTime,\n\t\tsecureConnectionTime,\n\t\tresponseNetworkTime,\n\t\tfetchStartToResponseEndTime,\n\t\treqStartToResponseEndTime,\n\t};\n}\n\n/*\n * An implementation of Promise.race that gives you the winner of the promise race.\n * If one of the promises is rejected before any other is resolved, this method will return the error/reason from that rejection.\n */\nexport async function promiseRaceWithWinner<T>(\n\tpromises: Promise<T>[],\n): Promise<{ index: number; value: T }> {\n\treturn new Promise((resolve, reject) => {\n\t\tpromises.forEach((p, index) => {\n\t\t\tp.then((v) => resolve({ index, value: v })).catch(reject);\n\t\t});\n\t});\n}\n\nexport function validateMessages(\n\treason: string,\n\tmessages: ISequencedDocumentMessage[],\n\tfrom: number,\n\tlogger: ITelemetryLoggerExt,\n\tstrict: boolean = true,\n) {\n\tif (messages.length !== 0) {\n\t\tconst start = messages[0].sequenceNumber;\n\t\tconst length = messages.length;\n\t\tconst last = messages[length - 1].sequenceNumber;\n\t\tif (last + 1 !== from + length) {\n\t\t\t// If not strict, then return the first consecutive sub-block. If strict or start\n\t\t\t// seq number is not what we expected, then return no ops.\n\t\t\tif (strict || from !== start) {\n\t\t\t\tmessages.length = 0;\n\t\t\t} else {\n\t\t\t\tlet validOpsCount = 1;\n\t\t\t\twhile (\n\t\t\t\t\tvalidOpsCount < messages.length &&\n\t\t\t\t\tmessages[validOpsCount].sequenceNumber ===\n\t\t\t\t\t\tmessages[validOpsCount - 1].sequenceNumber + 1\n\t\t\t\t) {\n\t\t\t\t\tvalidOpsCount++;\n\t\t\t\t}\n\t\t\t\tmessages.length = validOpsCount;\n\t\t\t}\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"OpsFetchViolation\",\n\t\t\t\treason,\n\t\t\t\tfrom,\n\t\t\t\tstart,\n\t\t\t\tlast,\n\t\t\t\tlength,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tvalidLength: messages.length,\n\t\t\t\t\tlastValidOpSeqNumber:\n\t\t\t\t\t\tmessages.length > 0\n\t\t\t\t\t\t\t? messages[messages.length - 1].sequenceNumber\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tstrict,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"driverUtils.js","sourceRoot":"","sources":["../src/driverUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,aAAqB;IAC5D,mFAAmF;IAC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,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;wBAC9C,CAAC,CAAC,SAAS;oBACb,MAAM;iBACN,CAAC;aACF,CAAC,CAAC;SACH;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\n\n/**\n * Extract and return the w3c data.\n * @param url - request url for which w3c data needs to be reported.\n * @param initiatorType - type of the network call\n */\nexport function getW3CData(url: string, initiatorType: string) {\n\t// From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n\t// fetchStart: immediately before the browser starts to fetch the resource.\n\t// requestStart: immediately before the browser starts requesting the resource from the server\n\t// responseStart: immediately after the browser receives the first byte of the response from the server.\n\t// responseEnd: immediately after the browser receives the last byte of the resource\n\t// or immediately before the transport connection is closed, whichever comes first.\n\t// secureConnectionStart: immediately before the browser starts the handshake process to secure the\n\t// current connection. If a secure connection is not used, this property returns zero.\n\t// startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n\t// domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n\t// domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n\t// redirectStart: start time of the fetch which that initiates the redirect.\n\t// redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n\n\t// Interval between start and finish of the domain name lookup for the resource.\n\tlet dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n\t// Interval between the first fetch until the last byte of the last redirect.\n\tlet redirectTime: number | undefined; // redirectEnd - redirectStart\n\t// Time to establish the connection to the server to retrieve the resource.\n\tlet tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n\t// Time from the end of the connection until the inital handshake process to secure the connection.\n\t// If 0, then no time is spent here.\n\tlet secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n\t// Interval to receive all (first to last) bytes form the server.\n\tlet responseNetworkTime: number | undefined; // responsEnd - responseStart\n\t// Interval between the initial fetch until the last byte is received.\n\t// Likely same as fetchTime + receiveContentTime.\n\tlet fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n\t// reqStartToResponseEndTime = fetchStartToResponseEndTime - <initial TCP handshake>\n\t// Interval between starting the request for the resource until receiving the last byte.\n\tlet reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n\tlet w3cStartTime: number | undefined; // W3C Start time = fetchStart time\n\n\t// getEntriesByType is only available in browser performance object\n\tconst resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n\t// Usually the latest fetch call is to the end of resources, so we start from the end.\n\tfor (let i = resources1.length - 1; i > 0; i--) {\n\t\tconst indResTime = resources1[i] as PerformanceResourceTiming;\n\t\tconst resource_name = indResTime.name.toString();\n\t\tconst resource_initiatortype = indResTime.initiatorType;\n\t\tif (\n\t\t\tresource_initiatortype.localeCompare(initiatorType) === 0 &&\n\t\t\tresource_name.includes(url)\n\t\t) {\n\t\t\tredirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n\t\t\tw3cStartTime = indResTime.fetchStart;\n\t\t\tdnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n\t\t\ttcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n\t\t\tsecureConnectionTime =\n\t\t\t\tindResTime.secureConnectionStart > 0\n\t\t\t\t\t? indResTime.connectEnd - indResTime.secureConnectionStart\n\t\t\t\t\t: 0;\n\t\t\tresponseNetworkTime =\n\t\t\t\tindResTime.responseStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.responseStart\n\t\t\t\t\t: undefined;\n\t\t\tfetchStartToResponseEndTime =\n\t\t\t\tindResTime.fetchStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.fetchStart\n\t\t\t\t\t: undefined;\n\t\t\treqStartToResponseEndTime =\n\t\t\t\tindResTime.requestStart > 0\n\t\t\t\t\t? indResTime.responseEnd - indResTime.requestStart\n\t\t\t\t\t: undefined;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn {\n\t\tdnsLookupTime,\n\t\tw3cStartTime,\n\t\tredirectTime,\n\t\ttcpHandshakeTime,\n\t\tsecureConnectionTime,\n\t\tresponseNetworkTime,\n\t\tfetchStartToResponseEndTime,\n\t\treqStartToResponseEndTime,\n\t};\n}\n\n/*\n * An implementation of Promise.race that gives you the winner of the promise race.\n * If one of the promises is rejected before any other is resolved, this method will return the error/reason from that rejection.\n */\nexport async function promiseRaceWithWinner<T>(\n\tpromises: Promise<T>[],\n): Promise<{ index: number; value: T }> {\n\treturn new Promise((resolve, reject) => {\n\t\tpromises.forEach((p, index) => {\n\t\t\tp.then((v) => resolve({ index, value: v })).catch(reject);\n\t\t});\n\t});\n}\n\nexport function validateMessages(\n\treason: string,\n\tmessages: ISequencedDocumentMessage[],\n\tfrom: number,\n\tlogger: ITelemetryLoggerExt,\n\tstrict: boolean = true,\n) {\n\tif (messages.length !== 0) {\n\t\tconst start = messages[0].sequenceNumber;\n\t\tconst length = messages.length;\n\t\tconst last = messages[length - 1].sequenceNumber;\n\t\tif (last + 1 !== from + length) {\n\t\t\t// If not strict, then return the first consecutive sub-block. If strict or start\n\t\t\t// seq number is not what we expected, then return no ops.\n\t\t\tif (strict || from !== start) {\n\t\t\t\tmessages.length = 0;\n\t\t\t} else {\n\t\t\t\tlet validOpsCount = 1;\n\t\t\t\twhile (\n\t\t\t\t\tvalidOpsCount < messages.length &&\n\t\t\t\t\tmessages[validOpsCount].sequenceNumber ===\n\t\t\t\t\t\tmessages[validOpsCount - 1].sequenceNumber + 1\n\t\t\t\t) {\n\t\t\t\t\tvalidOpsCount++;\n\t\t\t\t}\n\t\t\t\tmessages.length = validOpsCount;\n\t\t\t}\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"OpsFetchViolation\",\n\t\t\t\treason,\n\t\t\t\tfrom,\n\t\t\t\tstart,\n\t\t\t\tlast,\n\t\t\t\tlength,\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tvalidLength: messages.length,\n\t\t\t\t\tlastValidOpSeqNumber:\n\t\t\t\t\t\tmessages.length > 0\n\t\t\t\t\t\t\t? messages[messages.length - 1].sequenceNumber\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tstrict,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
package/lib/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/driver-base";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.0.1";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/driver-base";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.6.0.1";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,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/driver-base\";\nexport const pkgVersion = \"2.0.0-internal.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,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/driver-base\";\nexport const pkgVersion = \"2.0.0-internal.6.0.1\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/driver-base",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.6.0.1",
|
|
4
4
|
"description": "Shared driver code for Fluid driver implementations",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fluidframework/common-utils": "^1.1.1",
|
|
39
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.
|
|
40
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.
|
|
41
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.
|
|
39
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.0.1 <2.0.0-internal.6.1.0",
|
|
40
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.6.0.1 <2.0.0-internal.6.1.0",
|
|
41
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.6.0.1 <2.0.0-internal.6.1.0",
|
|
42
42
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
43
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.
|
|
43
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.6.0.1 <2.0.0-internal.6.1.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@fluid-tools/build-cli": "^0.21.0",
|
|
47
|
-
"@fluidframework/build-common": "^
|
|
47
|
+
"@fluidframework/build-common": "^2.0.0",
|
|
48
48
|
"@fluidframework/build-tools": "^0.21.0",
|
|
49
|
-
"@fluidframework/driver-base-previous": "npm:@fluidframework/driver-base@2.0.0-internal.
|
|
49
|
+
"@fluidframework/driver-base-previous": "npm:@fluidframework/driver-base@2.0.0-internal.6.0.0",
|
|
50
50
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
51
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
51
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.0.1 <2.0.0-internal.6.1.0",
|
|
52
52
|
"@microsoft/api-extractor": "^7.34.4",
|
|
53
53
|
"@types/mocha": "^9.1.1",
|
|
54
54
|
"@types/node": "^16.18.38",
|
package/src/packageVersion.ts
CHANGED