@fluidframework/driver-base 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.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/.eslintrc.js +5 -8
- package/api-extractor.json +2 -2
- package/dist/documentDeltaConnection.d.ts +1 -3
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js +18 -84
- package/dist/documentDeltaConnection.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.d.ts +1 -3
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js +19 -85
- package/lib/documentDeltaConnection.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 +65 -64
- package/prettier.config.cjs +1 -1
- package/src/documentDeltaConnection.ts +618 -658
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -13
package/.eslintrc.js
CHANGED
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"@typescript-eslint/strict-boolean-expressions": "off"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
rules: {
|
|
9
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
10
|
+
},
|
|
11
|
+
};
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
4
4
|
}
|
|
@@ -14,7 +14,6 @@ export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandli
|
|
|
14
14
|
protected readonly socket: Socket;
|
|
15
15
|
documentId: string;
|
|
16
16
|
private readonly enableLongPollingDowngrades;
|
|
17
|
-
protected readonly connectionId?: string | undefined;
|
|
18
17
|
static readonly eventsToForward: string[];
|
|
19
18
|
static readonly eventsAlwaysForwarded: string[];
|
|
20
19
|
/**
|
|
@@ -55,7 +54,7 @@ export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandli
|
|
|
55
54
|
* @param logger - for reporting telemetry events
|
|
56
55
|
* @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure
|
|
57
56
|
*/
|
|
58
|
-
protected constructor(socket: Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean
|
|
57
|
+
protected constructor(socket: Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean);
|
|
59
58
|
/**
|
|
60
59
|
* Get the ID of the client who is sending the message
|
|
61
60
|
*
|
|
@@ -145,7 +144,6 @@ export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandli
|
|
|
145
144
|
*/
|
|
146
145
|
protected disconnectCore(): void;
|
|
147
146
|
protected initialize(connectMessage: IConnect, timeout: number): Promise<void>;
|
|
148
|
-
private addPropsToError;
|
|
149
147
|
protected earlyOpHandler: (documentId: string, msgs: ISequencedDocumentMessage[]) => void;
|
|
150
148
|
protected earlySignalHandler: (msg: ISignalMessage) => void;
|
|
151
149
|
private removeEarlyOpHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],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AE,eAAe;IAIhD;;;;OAIG;IACI,OAAO;IAmBd,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,eAAe;IAkCzC;;;OAGG;IACH,SAAS,CAAC,cAAc;cAIR,UAAU,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM;IAsLpE,SAAS,CAAC,cAAc,eAAgB,MAAM,QAAQ,yBAAyB,EAAE,UAE/E;IAEF,SAAS,CAAC,kBAAkB,QAAS,cAAc,UAEjD;IAEF,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,qBAAqB;IAc7B,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;IAM9E,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,yBAAyB;IAWjC;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,UAAO,GAAG,eAAe;CAyB3F"}
|
|
@@ -21,7 +21,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
21
21
|
* @param logger - for reporting telemetry events
|
|
22
22
|
* @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure
|
|
23
23
|
*/
|
|
24
|
-
constructor(socket, documentId, logger, enableLongPollingDowngrades = false
|
|
24
|
+
constructor(socket, documentId, logger, enableLongPollingDowngrades = false) {
|
|
25
25
|
super((name, error) => {
|
|
26
26
|
logger.sendErrorEvent({
|
|
27
27
|
eventName: "DeltaConnection:EventException",
|
|
@@ -31,7 +31,6 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
31
31
|
this.socket = socket;
|
|
32
32
|
this.documentId = documentId;
|
|
33
33
|
this.enableLongPollingDowngrades = enableLongPollingDowngrades;
|
|
34
|
-
this.connectionId = connectionId;
|
|
35
34
|
// Listen for ops sent before we receive a response to connect_document
|
|
36
35
|
this.queuedMessages = [];
|
|
37
36
|
this.queuedSignals = [];
|
|
@@ -83,20 +82,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
83
82
|
return !!this._details;
|
|
84
83
|
}
|
|
85
84
|
get disposed() {
|
|
86
|
-
|
|
87
|
-
// We are seeing this in telemetry and we are unable to figure out why it is happening, so this should help.
|
|
88
|
-
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
89
|
-
try {
|
|
90
|
-
Error.stackTraceLimit = 50;
|
|
91
|
-
(0, common_utils_1.assert)(this._disposed || this.socket.connected, 0x244 /* "Socket is closed, but connection is not!" */);
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
const normalizedError = this.addPropsToError(error);
|
|
95
|
-
throw normalizedError;
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
Error.stackTraceLimit = originalStackTraceLimit;
|
|
99
|
-
}
|
|
85
|
+
(0, common_utils_1.assert)(this._disposed || this.socket.connected, 0x244 /* "Socket is closed, but connection is not!" */);
|
|
100
86
|
return this._disposed;
|
|
101
87
|
}
|
|
102
88
|
/**
|
|
@@ -164,20 +150,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
164
150
|
return this.details.serviceConfiguration;
|
|
165
151
|
}
|
|
166
152
|
checkNotClosed() {
|
|
167
|
-
|
|
168
|
-
// We are seeing this in telemetry and we are unable to figure out why it is happening, so this should help.
|
|
169
|
-
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
170
|
-
try {
|
|
171
|
-
Error.stackTraceLimit = 50;
|
|
172
|
-
(0, common_utils_1.assert)(!this.disposed, 0x20c /* "connection disposed" */);
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
const normalizedError = this.addPropsToError(error);
|
|
176
|
-
throw normalizedError;
|
|
177
|
-
}
|
|
178
|
-
finally {
|
|
179
|
-
Error.stackTraceLimit = originalStackTraceLimit;
|
|
180
|
-
}
|
|
153
|
+
(0, common_utils_1.assert)(!this.disposed, 0x20c /* "connection disposed" */);
|
|
181
154
|
}
|
|
182
155
|
/**
|
|
183
156
|
* Get messages sent during the connection
|
|
@@ -260,7 +233,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
260
233
|
* Disconnect from the websocket and close the websocket too.
|
|
261
234
|
*/
|
|
262
235
|
closeSocket(error) {
|
|
263
|
-
var _a
|
|
236
|
+
var _a;
|
|
264
237
|
if (this._disposed) {
|
|
265
238
|
// This would be rare situation due to complexity around socket emitting events.
|
|
266
239
|
this.logger.sendTelemetryEvent({
|
|
@@ -270,8 +243,6 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
270
243
|
disposed: this._disposed,
|
|
271
244
|
socketConnected: (_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected,
|
|
272
245
|
trackedListenerCount: this.trackedListeners.size,
|
|
273
|
-
clientId: (_b = this._details) === null || _b === void 0 ? void 0 : _b.clientId,
|
|
274
|
-
connectionId: this.connectionId,
|
|
275
246
|
}),
|
|
276
247
|
}, error);
|
|
277
248
|
return;
|
|
@@ -287,15 +258,12 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
287
258
|
* multiplexing here, so we need to close the socket here.
|
|
288
259
|
*/
|
|
289
260
|
dispose() {
|
|
290
|
-
var _a;
|
|
291
261
|
this.logger.sendTelemetryEvent({
|
|
292
262
|
eventName: "ClientClosingDeltaConnection",
|
|
293
263
|
driverVersion: packageVersion_1.pkgVersion,
|
|
294
264
|
details: JSON.stringify({
|
|
295
265
|
disposed: this._disposed,
|
|
296
266
|
socketConnected: this.socket.connected,
|
|
297
|
-
clientId: (_a = this._details) === null || _a === void 0 ? void 0 : _a.clientId,
|
|
298
|
-
connectionId: this.connectionId,
|
|
299
267
|
}),
|
|
300
268
|
});
|
|
301
269
|
this.disconnect((0, driver_utils_1.createGenericNetworkError)(
|
|
@@ -303,7 +271,6 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
303
271
|
"Client closing delta connection", { canRetry: true }, { driverVersion: packageVersion_1.pkgVersion }));
|
|
304
272
|
}
|
|
305
273
|
disconnect(err) {
|
|
306
|
-
var _a;
|
|
307
274
|
// Can't check this.disposed here, as we get here on socket closure,
|
|
308
275
|
// so _disposed & socket.connected might be not in sync while processing
|
|
309
276
|
// "dispose" event.
|
|
@@ -323,11 +290,8 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
323
290
|
eventName: "AfterDisconnectEvent",
|
|
324
291
|
driverVersion: packageVersion_1.pkgVersion,
|
|
325
292
|
details: JSON.stringify({
|
|
326
|
-
disposed: this._disposed,
|
|
327
|
-
clientId: (_a = this._details) === null || _a === void 0 ? void 0 : _a.clientId,
|
|
328
293
|
socketConnected: this.socket.connected,
|
|
329
294
|
disconnectListenerCount: this.listenerCount("disconnect"),
|
|
330
|
-
connectionId: this.connectionId,
|
|
331
295
|
}),
|
|
332
296
|
});
|
|
333
297
|
// user of DeltaConnection should have processed "disconnect" event and removed all listeners. Not clear
|
|
@@ -350,36 +314,17 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
350
314
|
// Socket.io's reconnect_attempt event is unreliable, so we track connect_error count instead.
|
|
351
315
|
let internalSocketConnectionFailureCount = 0;
|
|
352
316
|
const isInternalSocketReconnectionEnabled = () => this.socket.io.reconnection();
|
|
353
|
-
const getMaxInternalSocketReconnectionAttempts = () => isInternalSocketReconnectionEnabled()
|
|
354
|
-
? this.socket.io.reconnectionAttempts()
|
|
355
|
-
: 0;
|
|
317
|
+
const getMaxInternalSocketReconnectionAttempts = () => isInternalSocketReconnectionEnabled() ? this.socket.io.reconnectionAttempts() : 0;
|
|
356
318
|
const getMaxAllowedInternalSocketConnectionFailures = () => getMaxInternalSocketReconnectionAttempts() + 1;
|
|
357
319
|
this._details = await new Promise((resolve, reject) => {
|
|
358
320
|
const failAndCloseSocket = (err) => {
|
|
359
|
-
|
|
360
|
-
this.closeSocket(err);
|
|
361
|
-
}
|
|
362
|
-
catch (failError) {
|
|
363
|
-
const normalizedError = this.addPropsToError(failError);
|
|
364
|
-
this.logger.sendErrorEvent({ eventName: "CloseSocketError" }, normalizedError);
|
|
365
|
-
}
|
|
321
|
+
this.closeSocket(err);
|
|
366
322
|
reject(err);
|
|
367
323
|
};
|
|
368
324
|
const failConnection = (err) => {
|
|
369
|
-
|
|
370
|
-
this.disconnect(err);
|
|
371
|
-
}
|
|
372
|
-
catch (failError) {
|
|
373
|
-
const normalizedError = this.addPropsToError(failError);
|
|
374
|
-
this.logger.sendErrorEvent({ eventName: "FailConnectionError" }, normalizedError);
|
|
375
|
-
}
|
|
325
|
+
this.disconnect(err);
|
|
376
326
|
reject(err);
|
|
377
327
|
};
|
|
378
|
-
// Immediately set the connection timeout.
|
|
379
|
-
// Give extra 2 seconds for handshake on top of socket connection timeout.
|
|
380
|
-
this.socketConnectionTimeout = setTimeout(() => {
|
|
381
|
-
failConnection(this.createErrorObject("orderingServiceHandshakeTimeout"));
|
|
382
|
-
}, timeout + 2000);
|
|
383
328
|
// Listen for connection issues
|
|
384
329
|
this.addConnectionListener("connect_error", (error) => {
|
|
385
330
|
var _a, _b, _c;
|
|
@@ -426,7 +371,8 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
426
371
|
}
|
|
427
372
|
// Allow built-in socket.io reconnection handling.
|
|
428
373
|
if (isInternalSocketReconnectionEnabled() &&
|
|
429
|
-
internalSocketConnectionFailureCount <
|
|
374
|
+
internalSocketConnectionFailureCount <
|
|
375
|
+
getMaxAllowedInternalSocketConnectionFailures()) {
|
|
430
376
|
// Reconnection is enabled and maximum reconnect attempts have not been reached.
|
|
431
377
|
return;
|
|
432
378
|
}
|
|
@@ -471,13 +417,13 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
471
417
|
const err = this.createErrorObject("disconnect", reason);
|
|
472
418
|
failAndCloseSocket(err);
|
|
473
419
|
});
|
|
474
|
-
this.addTrackedListener("error", (
|
|
420
|
+
this.addTrackedListener("error", (error) => {
|
|
475
421
|
// This includes "Invalid namespace" error, which we consider critical (reconnecting will not help)
|
|
476
422
|
const err = this.createErrorObject("error", error, error !== "Invalid namespace");
|
|
477
423
|
// Disconnect socket - required if happened before initial handshake
|
|
478
424
|
failAndCloseSocket(err);
|
|
479
|
-
})
|
|
480
|
-
this.addConnectionListener("connect_document_error", (
|
|
425
|
+
});
|
|
426
|
+
this.addConnectionListener("connect_document_error", (error) => {
|
|
481
427
|
// If we sent a nonce and the server supports nonces, check that the nonces match
|
|
482
428
|
if (connectMessage.nonce !== undefined &&
|
|
483
429
|
error.nonce !== undefined &&
|
|
@@ -487,25 +433,15 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
487
433
|
// This is not an socket.io error - it's Fluid protocol error.
|
|
488
434
|
// In this case fail connection and indicate that we were unable to create connection
|
|
489
435
|
failConnection(this.createErrorObject("connect_document_error", error));
|
|
490
|
-
})
|
|
436
|
+
});
|
|
491
437
|
this.socket.emit("connect_document", connectMessage);
|
|
438
|
+
// Give extra 2 seconds for handshake on top of socket connection timeout
|
|
439
|
+
this.socketConnectionTimeout = setTimeout(() => {
|
|
440
|
+
failConnection(this.createErrorObject("orderingServiceHandshakeTimeout"));
|
|
441
|
+
}, timeout + 2000);
|
|
492
442
|
});
|
|
493
443
|
(0, common_utils_1.assert)(!this.disposed, 0x246 /* "checking consistency of socket & _disposed flags" */);
|
|
494
444
|
}
|
|
495
|
-
addPropsToError(errorToBeNormalized) {
|
|
496
|
-
var _a, _b;
|
|
497
|
-
const normalizedError = (0, telemetry_utils_1.normalizeError)(errorToBeNormalized, {
|
|
498
|
-
props: {
|
|
499
|
-
details: JSON.stringify({
|
|
500
|
-
disposed: this._disposed,
|
|
501
|
-
socketConnected: (_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected,
|
|
502
|
-
clientId: (_b = this._details) === null || _b === void 0 ? void 0 : _b.clientId,
|
|
503
|
-
conenctionId: this.connectionId,
|
|
504
|
-
}),
|
|
505
|
-
},
|
|
506
|
-
});
|
|
507
|
-
return normalizedError;
|
|
508
|
-
}
|
|
509
445
|
removeEarlyOpHandler() {
|
|
510
446
|
this.socket.removeListener("op", this.earlyOpHandler);
|
|
511
447
|
this.earlyOpHandlerAttached = false;
|
|
@@ -554,9 +490,7 @@ class DocumentDeltaConnection extends telemetry_utils_1.EventEmitterWithErrorHan
|
|
|
554
490
|
let message;
|
|
555
491
|
if ((error === null || error === void 0 ? void 0 : error.type) === "TransportError") {
|
|
556
492
|
// JSON.stringify drops Error.message
|
|
557
|
-
const messagePrefix = (
|
|
558
|
-
? `${error.message}: `
|
|
559
|
-
: "";
|
|
493
|
+
const messagePrefix = (error === null || error === void 0 ? void 0 : error.message) !== undefined ? `${error.message}: ` : "";
|
|
560
494
|
// Websocket errors reported by engine.io-client.
|
|
561
495
|
// They are Error objects with description containing WS error and description = "TransportError"
|
|
562
496
|
// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,
|
|
@@ -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,uBACT,SAAQ,+CAA6D;IAgFrE;;;;;OAKG;IACH,YACuB,MAAc,EAC1B,UAAkB,EACzB,MAAwB,EACP,8BAAuC,KAAK,EAChD,YAAqB;QAElC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE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AAc,OAAO,MAAM,OAAO,EAAE,EACpC,EAAE,QAAQ,EAAE,EACZ,EAAE,aAAa,EAAb,2BAAa,EAAE,CACpB,CAAC;QAEF,OAAO,QAAQ,CAAC;IACpB,CAAC;;AAvqBL,0DAwqBC;AArqBmB,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 IAnyDriverError,\n IDocumentDeltaConnection,\n IDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils\";\nimport {\n ConnectionMode,\n IClientConfiguration,\n IConnect,\n IConnected,\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISignalClient,\n ISignalMessage,\n ITokenClaims,\n ScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n ChildLogger,\n extractLogSafeErrorProperties,\n getCircularReplacer,\n loggerToMonitoringContext,\n MonitoringContext,\n EventEmitterWithErrorHandling,\n\tnormalizeError,\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 extends EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents>\n implements IDocumentDeltaConnection, IDisposable {\n static readonly eventsToForward = [\"nack\", \"op\", \"signal\", \"pong\"];\n\n // WARNING: These are critical events that we can't miss, so registration for them has to be in place at all times!\n // Including before handshake is over, and after that (but before DeltaManager had a chance to put its own handlers)\n static readonly eventsAlwaysForwarded = [\"disconnect\", \"error\"];\n\n /**\n * Last known sequence number to ordering service at the time of connection\n * It may lap actual last sequence number (quite a bit, if container is very active).\n * But it's best information for client to figure out how far it is behind, at least\n * for \"read\" connections. \"write\" connections may use own \"join\" op to similar information,\n * that is likely to be more up-to-date.\n */\n public checkpointSequenceNumber: number | undefined;\n\n // Listen for ops sent before we receive a response to connect_document\n protected readonly queuedMessages: ISequencedDocumentMessage[] = [];\n protected readonly queuedSignals: ISignalMessage[] = [];\n\n /**\n * A flag to indicate whether we have our handler attached. If it's attached, we're queueing incoming ops\n * to later be retrieved via initialMessages.\n */\n private earlyOpHandlerAttached: boolean = false;\n\n private socketConnectionTimeout: ReturnType<typeof setTimeout> | undefined;\n\n private _details: IConnected | undefined;\n\n // Listeners only needed while the connection is in progress\n private readonly connectionListeners: Map<string, (...args: any[]) => void> = new Map();\n // Listeners used throughout the lifetime of the DocumentDeltaConnection\n private readonly trackedListeners: Map<string, (...args: any[]) => void> = new Map();\n\n protected get hasDetails(): boolean {\n return !!this._details;\n }\n\n public get disposed() {\n\t\t// Increase the stack trace limit temporarily, so as to debug better in case it occurs.\n\t\t// We are seeing this in telemetry and we are unable to figure out why it is happening, so this should help.\n\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\ttry {\n\t\t\t(Error as any).stackTraceLimit = 50;\n\t\t\tassert(\n\t\t\t\tthis._disposed || this.socket.connected,\n\t\t\t\t0x244 /* \"Socket is closed, but connection is not!\" */,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst normalizedError = this.addPropsToError(error);\n\t\t\tthrow normalizedError;\n\t\t} finally {\n\t\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\t}\n return this._disposed;\n }\n\n /**\n * Flag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages.\n * After disconnection, we flip this to prevent any stale messages from being emitted.\n */\n protected _disposed: boolean = false;\n private readonly mc: MonitoringContext;\n\n /**\n * @deprecated Implementors should manage their own logger or monitoring context\n */\n protected get logger(): ITelemetryLogger {\n return this.mc.logger;\n }\n\n public get details(): IConnected {\n if (!this._details) {\n throw new Error(\"Internal error: calling method before _details is initialized!\");\n }\n return this._details;\n }\n\n /**\n * @param socket - websocket to be used\n * @param documentId - ID of the document\n * @param logger - for reporting telemetry events\n * @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure\n */\n protected constructor(\n protected readonly socket: Socket,\n public documentId: string,\n logger: ITelemetryLogger,\n private readonly enableLongPollingDowngrades: boolean = false,\n\t\tprotected readonly connectionId?: string,\n ) {\n super((name, error) => {\n logger.sendErrorEvent(\n {\n eventName: \"DeltaConnection:EventException\",\n name,\n },\n error);\n });\n\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(logger, \"DeltaConnection\"));\n\n this.on(\"newListener\", (event, listener) => {\n assert(!this.disposed, 0x20a /* \"register for event on disposed object\" */);\n\n // Some events are already forwarded - see this.addTrackedListener() calls in initialize().\n if (DocumentDeltaConnection.eventsAlwaysForwarded.includes(event)) {\n assert(this.trackedListeners.has(event), 0x245 /* \"tracked listener\" */);\n return;\n }\n\n if (!DocumentDeltaConnection.eventsToForward.includes(event)) {\n throw new Error(`DocumentDeltaConnection: Registering for unknown event: ${event}`);\n }\n\n // Whenever listener is added, we should subscribe on same event on socket, so these two things\n // should be in sync. This currently assumes that nobody unregisters and registers back listeners,\n // and that there are no \"internal\" listeners installed (like \"error\" case we skip above)\n // Better flow might be to always unconditionally register all handlers on successful connection,\n // though some logic (naming assert in initialMessages getter) might need to be adjusted (it becomes noop)\n assert((this.listeners(event).length !== 0) === this.trackedListeners.has(event), 0x20b /* \"mismatch\" */);\n if (!this.trackedListeners.has(event)) {\n this.addTrackedListener(\n event,\n (...args: any[]) => {\n this.emit(event, ...args);\n });\n }\n });\n }\n\n /**\n * Get the ID of the client who is sending the message\n *\n * @returns the client ID\n */\n public get clientId(): string {\n return this.details.clientId;\n }\n\n /**\n * Get the mode of the client\n *\n * @returns the client mode\n */\n public get mode(): ConnectionMode {\n return this.details.mode;\n }\n\n /**\n * Get the claims of the client who is sending the message\n *\n * @returns client claims\n */\n public get claims(): ITokenClaims {\n return this.details.claims;\n }\n\n /**\n * Get whether or not this is an existing document\n *\n * @returns true if the document exists\n */\n public get existing(): boolean {\n return this.details.existing;\n }\n\n /**\n * Get the maximum size of a message before chunking is required\n *\n * @returns the maximum size of a message before chunking is required\n */\n public get maxMessageSize(): number {\n return this.details.serviceConfiguration.maxMessageSize;\n }\n\n /**\n * Semver of protocol being used with the service\n */\n public get version(): string {\n return this.details.version;\n }\n\n /**\n * Configuration details provided by the service\n */\n public get serviceConfiguration(): IClientConfiguration {\n return this.details.serviceConfiguration;\n }\n\n private checkNotClosed() {\n\t\t// Increase the stack trace limit temporarily, so as to debug better in case it occurs.\n\t\t// We are seeing this in telemetry and we are unable to figure out why it is happening, so this should help.\n\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\ttry {\n\t\t\t(Error as any).stackTraceLimit = 50;\n\t\t\tassert(!this.disposed, 0x20c /* \"connection disposed\" */);\n\t\t} catch (error) {\n\t\t\tconst normalizedError = this.addPropsToError(error);\n\t\t\tthrow normalizedError;\n\t\t} finally {\n\t\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\t}\n }\n\n /**\n * Get messages sent during the connection\n *\n * @returns messages sent during the connection\n */\n public get initialMessages(): ISequencedDocumentMessage[] {\n this.checkNotClosed();\n\n // If we call this when the earlyOpHandler is not attached, then the queuedMessages may not include the\n // latest ops. This could possibly indicate that initialMessages was called twice.\n assert(this.earlyOpHandlerAttached, 0x08e /* \"Potentially missed initial messages\" */);\n // We will lose ops and perf will tank as we need to go to storage to become current!\n assert(this.listeners(\"op\").length !== 0, 0x08f /* \"No op handler is setup!\" */);\n\n this.removeEarlyOpHandler();\n\n if (this.queuedMessages.length > 0) {\n // Some messages were queued.\n // add them to the list of initialMessages to be processed\n this.details.initialMessages.push(...this.queuedMessages);\n this.details.initialMessages.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.queuedMessages.length = 0;\n }\n return this.details.initialMessages;\n }\n\n /**\n * Get signals sent during the connection\n *\n * @returns signals sent during the connection\n */\n public get initialSignals(): ISignalMessage[] {\n this.checkNotClosed();\n assert(this.listeners(\"signal\").length !== 0, 0x090 /* \"No signal handler is setup!\" */);\n\n this.removeEarlySignalHandler();\n\n if (this.queuedSignals.length > 0) {\n // Some signals were queued.\n // add them to the list of initialSignals to be processed\n this.details.initialSignals.push(...this.queuedSignals);\n this.queuedSignals.length = 0;\n }\n return this.details.initialSignals;\n }\n\n /**\n * Get initial client list\n *\n * @returns initial client list sent during the connection\n */\n public get initialClients(): ISignalClient[] {\n this.checkNotClosed();\n return this.details.initialClients;\n }\n\n protected emitMessages(type: string, messages: IDocumentMessage[][]) {\n // Although the implementation here disconnects the socket and does not reuse it, other subclasses\n // (e.g. OdspDocumentDeltaConnection) may reuse the socket. In these cases, we need to avoid emitting\n // on the still-live socket.\n if (!this.disposed) {\n this.socket.emit(type, this.clientId, messages);\n }\n }\n\n protected submitCore(type: string, messages: IDocumentMessage[]) {\n this.emitMessages(type, [messages]);\n }\n\n /**\n * Submits a new delta operation to the server\n *\n * @param message - delta operation to submit\n */\n public submit(messages: IDocumentMessage[]): void {\n this.checkNotClosed();\n this.submitCore(\"submitOp\", messages);\n }\n\n /**\n * Submits a new signal to the server\n *\n * @param message - signal to submit\n */\n public submitSignal(message: IDocumentMessage): void {\n this.checkNotClosed();\n this.submitCore(\"submitSignal\", [message]);\n }\n\n /**\n * Disconnect from the websocket and close the websocket too.\n */\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\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SocketCloseOnDisposedConnection\",\n\t\t\t\t\tdriverVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tdisposed: this._disposed,\n\t\t\t\t\t\tsocketConnected: this.socket?.connected,\n\t\t\t\t\t\ttrackedListenerCount: this.trackedListeners.size,\n\t\t\t\t\t\tclientId: this._details?.clientId,\n\t\t\t\t\t\tconnectionId: this.connectionId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\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 /**\n * Disconnect from the websocket, and permanently disable this DocumentDeltaConnection and close the socket.\n * However the OdspDocumentDeltaConnection differ in dispose as in there we don't close the socket. There is no\n * multiplexing here, so we need to close the socket here.\n */\n public dispose() {\n this.logger.sendTelemetryEvent({\n eventName: \"ClientClosingDeltaConnection\",\n driverVersion,\n details: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tdisposed: this._disposed,\n\t\t\t\t\tsocketConnected: this.socket.connected,\n\t\t\t\t\tclientId: this._details?.clientId,\n\t\t\t\t\tconnectionId: this.connectionId,\n\t\t\t\t}\n\t\t\t),\n });\n this.disconnect(createGenericNetworkError(\n // pre-0.58 error message: clientClosingConnection\n \"Client closing delta connection\", { canRetry: true }, { driverVersion }),\n );\n }\n\n protected disconnect(err: IAnyDriverError) {\n // Can't check this.disposed here, as we get here on socket closure,\n // so _disposed & socket.connected might be not in sync while processing\n // \"dispose\" event.\n if (this._disposed) {\n return;\n }\n\n // We set the disposed flag as a part of the contract for overriding the disconnect method. This is used by\n // DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is\n // important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that\n // OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended\n // to prevent normal messages from being emitted.\n this._disposed = true;\n\n // Let user of connection object know about disconnect. This has to happen in between setting _disposed and\n // removing all listeners!\n this.emit(\"disconnect\", err);\n this.logger.sendTelemetryEvent({\n eventName: \"AfterDisconnectEvent\",\n driverVersion,\n details: JSON.stringify({\n\t\t\t\tdisposed: this._disposed,\n\t\t\t\tclientId: this._details?.clientId,\n socketConnected: this.socket.connected,\n disconnectListenerCount: this.listenerCount(\"disconnect\"),\n\t\t\t\tconnectionId: this.connectionId,\n }),\n });\n // user of DeltaConnection should have processed \"disconnect\" event and removed all listeners. Not clear\n // if we want to enforce that, as some users (like LocalDocumentService) do not unregister any handlers\n // assert(this.listenerCount(\"disconnect\") === 0, \"'disconnect` events should be processed synchronously\");\n\n this.removeTrackedListeners();\n this.disconnectCore();\n }\n\n /**\n * Disconnect from the websocket.\n * @param reason - reason for disconnect\n */\n protected disconnectCore() {\n this.socket.disconnect();\n }\n\n protected async initialize(connectMessage: IConnect, timeout: number) {\n this.socket.on(\"op\", this.earlyOpHandler);\n this.socket.on(\"signal\", this.earlySignalHandler);\n this.earlyOpHandlerAttached = true;\n\n // Socket.io's reconnect_attempt event is unreliable, so we track connect_error count instead.\n let internalSocketConnectionFailureCount: number = 0;\n const isInternalSocketReconnectionEnabled = (): boolean => this.socket.io.reconnection();\n const getMaxInternalSocketReconnectionAttempts = (): number => isInternalSocketReconnectionEnabled()\n ? this.socket.io.reconnectionAttempts()\n : 0;\n const getMaxAllowedInternalSocketConnectionFailures = (): number =>\n getMaxInternalSocketReconnectionAttempts() + 1;\n\n this._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 // Listen for connection issues\n this.addConnectionListener(\"connect_error\", (error) => {\n internalSocketConnectionFailureCount++;\n let isWebSocketTransportError = false;\n try {\n const description = error?.description;\n const context = error?.context;\n\n if (context && typeof context === \"object\") {\n const statusText = context.statusText?.code;\n\n // Self-Signed Certificate ErrorCode Found in error.context\n if (statusText === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n failAndCloseSocket(this.createErrorObject(\"connect_error\", error, false));\n return;\n }\n }\n else if (description && typeof description === \"object\") {\n const errorCode = description.error?.code;\n\n // Self-Signed Certificate ErrorCode Found in error.description\n if (errorCode === \"DEPTH_ZERO_SELF_SIGNED_CERT\") {\n failAndCloseSocket(this.createErrorObject(\"connect_error\", error, false));\n return;\n }\n\n if (error.type === \"TransportError\") {\n isWebSocketTransportError = true;\n }\n\n // That's a WebSocket. Clear it as we can't log it.\n description.target = undefined;\n }\n } catch (_e) { }\n\n // Handle socket transport downgrading when not offline.\n if (\n isWebSocketTransportError &&\n this.enableLongPollingDowngrades &&\n this.socket.io.opts.transports?.[0] !== \"polling\") {\n // Downgrade transports to polling upgrade mechanism.\n this.socket.io.opts.transports = [\"polling\", \"websocket\"];\n // Don't alter reconnection behavior if already enabled.\n if (!isInternalSocketReconnectionEnabled()) {\n // Allow single reconnection attempt using polling upgrade mechanism.\n this.socket.io.reconnection(true);\n this.socket.io.reconnectionAttempts(1);\n }\n }\n\n // Allow built-in socket.io reconnection handling.\n if (isInternalSocketReconnectionEnabled() &&\n internalSocketConnectionFailureCount < getMaxAllowedInternalSocketConnectionFailures()) {\n // Reconnection is enabled and maximum reconnect attempts have not been reached.\n return;\n }\n\n failAndCloseSocket(this.createErrorObject(\"connect_error\", error));\n });\n\n // Listen for timeouts\n this.addConnectionListener(\"connect_timeout\", () => {\n failAndCloseSocket(this.createErrorObject(\"connect_timeout\"));\n });\n\n this.addConnectionListener(\"connect_document_success\", (response: IConnected) => {\n // If we sent a nonce and the server supports nonces, check that the nonces match\n if (connectMessage.nonce !== undefined &&\n response.nonce !== undefined &&\n response.nonce !== connectMessage.nonce) {\n return;\n }\n\n const requestedMode = connectMessage.mode;\n const actualMode = response.mode;\n const writingPermitted = response.claims.scopes.includes(ScopeType.DocWrite);\n\n if (writingPermitted) {\n // The only time we expect a mismatch in requested/actual is if we lack write permissions\n // In this case we will get \"read\", even if we requested \"write\"\n if (actualMode !== requestedMode) {\n failConnection(this.createErrorObject(\n \"connect_document_success\",\n \"Connected in a different mode than was requested\",\n false,\n ));\n return;\n }\n } else {\n if (actualMode === \"write\") {\n failConnection(this.createErrorObject(\n \"connect_document_success\",\n \"Connected in write mode without write permissions\",\n false,\n ));\n return;\n }\n }\n\n this.checkpointSequenceNumber = response.checkpointSequenceNumber;\n\n this.removeConnectionListeners();\n resolve(response);\n });\n\n // Socket can be disconnected while waiting for Fluid protocol messages\n // (connect_document_error / connect_document_success), as well as before DeltaManager\n // had a chance to register its handlers.\n this.addTrackedListener(\"disconnect\", (reason) => {\n const err = this.createErrorObject(\"disconnect\", reason);\n failAndCloseSocket(err);\n });\n\n this.addTrackedListener(\"error\", ((error) => {\n // This includes \"Invalid namespace\" error, which we consider critical (reconnecting will not help)\n const err = this.createErrorObject(\"error\", error, error !== \"Invalid namespace\");\n // Disconnect socket - required if happened before initial handshake\n failAndCloseSocket(err);\n }));\n\n this.addConnectionListener(\"connect_document_error\", ((error) => {\n // If we sent a nonce and the server supports nonces, check that the nonces match\n if (connectMessage.nonce !== undefined &&\n error.nonce !== undefined &&\n error.nonce !== connectMessage.nonce) {\n return;\n }\n\n // This is not an socket.io error - it's Fluid protocol error.\n // In this case fail connection and indicate that we were unable to create connection\n failConnection(this.createErrorObject(\"connect_document_error\", error));\n }));\n\n this.socket.emit(\"connect_document\", connectMessage);\n });\n\n assert(!this.disposed, 0x246 /* \"checking consistency of socket & _disposed flags\" */);\n }\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\tdisposed: this._disposed,\n\t\t\t\t\tsocketConnected: this.socket?.connected,\n\t\t\t\t\tclientId: this._details?.clientId,\n\t\t\t\t\tconenctionId: this.connectionId,\n\t\t\t\t}),\n\t\t\t},\n\t\t});\n\t\treturn normalizedError;\n\t}\n\n protected earlyOpHandler = (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n this.queuedMessages.push(...msgs);\n };\n\n protected earlySignalHandler = (msg: ISignalMessage) => {\n this.queuedSignals.push(msg);\n };\n\n private removeEarlyOpHandler() {\n this.socket.removeListener(\"op\", this.earlyOpHandler);\n this.earlyOpHandlerAttached = false;\n }\n\n private removeEarlySignalHandler() {\n this.socket.removeListener(\"signal\", this.earlySignalHandler);\n }\n\n private addConnectionListener(event: string, listener: (...args: any[]) => void) {\n assert(!DocumentDeltaConnection.eventsAlwaysForwarded.includes(event),\n 0x247 /* \"Use addTrackedListener instead\" */);\n assert(!DocumentDeltaConnection.eventsToForward.includes(event),\n 0x248 /* \"should not subscribe to forwarded events\" */);\n this.socket.on(event, listener);\n assert(!this.connectionListeners.has(event), 0x20d /* \"double connection listener\" */);\n this.connectionListeners.set(event, listener);\n }\n\n protected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n this.socket.on(event, listener);\n assert(!this.trackedListeners.has(event), 0x20e /* \"double tracked listener\" */);\n this.trackedListeners.set(event, listener);\n }\n\n private removeTrackedListeners() {\n for (const [event, listener] of this.trackedListeners.entries()) {\n this.socket.off(event, listener);\n }\n // removeTrackedListeners removes all listeners, including connection listeners\n this.removeConnectionListeners();\n\n this.removeEarlyOpHandler();\n this.removeEarlySignalHandler();\n\n this.trackedListeners.clear();\n }\n\n private removeConnectionListeners() {\n if (this.socketConnectionTimeout !== undefined) {\n clearTimeout(this.socketConnectionTimeout);\n }\n\n for (const [event, listener] of this.connectionListeners.entries()) {\n this.socket.off(event, listener);\n }\n this.connectionListeners.clear();\n }\n\n /**\n * Error raising for socket.io issues\n */\n protected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n // Note: we suspect the incoming error object is either:\n // - a string: log it in the message (if not a string, it may contain PII but will print as [object Object])\n // - an Error object thrown by socket.io engine. Be careful with not recording PII!\n let message: string;\n if (error?.type === \"TransportError\") {\n // JSON.stringify drops Error.message\n const messagePrefix = (error?.message !== undefined)\n ? `${error.message}: `\n : \"\";\n\n // Websocket errors reported by engine.io-client.\n // They are Error objects with description containing WS error and description = \"TransportError\"\n // Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,\n message = `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;\n } else {\n message = extractLogSafeErrorProperties(error, true).message;\n }\n\n const errorObj = createGenericNetworkError(\n `socket.io (${handler}): ${message}`,\n { canRetry },\n { driverVersion },\n );\n\n return errorObj;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAMtD,+DAAyE;AACzE,+EAW8C;AAE9C,qEAOyC;AAEzC,sFAAsF;AACtF,qDAA+D;AAE/D;;GAEG;AACH,MAAa,uBACZ,SAAQ,+CAA6D;IAsErE;;;;;OAKG;IACH,YACoB,MAAc,EAC1B,UAAkB,EACzB,MAAwB,EACP,8BAAuC,KAAK;QAE7D,KAAK,CAAC,CAAC,IAAI,EAAE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AAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,gBAAgB,EAAE;YACrC,qCAAqC;YACrC,MAAM,aAAa,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,MAAK,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAE/E,iDAAiD;YACjD,iGAAiG;YACjG,6FAA6F;YAC7F,OAAO,GAAG,GAAG,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAA,qCAAmB,GAAE,CAAC,EAAE,CAAC;SAC5E;aAAM;YACN,OAAO,GAAG,IAAA,+CAA6B,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC;SAC7D;QAED,MAAM,QAAQ,GAAG,IAAA,wCAAyB,EACzC,cAAc,OAAO,MAAM,OAAO,EAAE,EACpC,EAAE,QAAQ,EAAE,EACZ,EAAE,aAAa,EAAb,2BAAa,EAAE,CACjB,CAAC;QAEF,OAAO,QAAQ,CAAC;IACjB,CAAC;;AAhoBF,0DAioBC;AA7nBgB,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, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tChildLogger,\n\textractLogSafeErrorProperties,\n\tgetCircularReplacer,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tEventEmitterWithErrorHandling,\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\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(): ITelemetryLogger {\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: ITelemetryLogger,\n\t\tprivate readonly enableLongPollingDowngrades: boolean = false,\n\t) {\n\t\tsuper((name, 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 = loggerToMonitoringContext(ChildLogger.create(logger, \"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\tthis.addTrackedListener(event, (...args: any[]) => {\n\t\t\t\t\tthis.emit(event, ...args);\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 checkNotClosed() {\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.checkNotClosed();\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.checkNotClosed();\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.checkNotClosed();\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\tprotected submitCore(type: string, messages: IDocumentMessage[]) {\n\t\tthis.emitMessages(type, [messages]);\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.checkNotClosed();\n\t\tthis.submitCore(\"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.checkNotClosed();\n\t\tthis.submitCore(\"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\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SocketCloseOnDisposedConnection\",\n\t\t\t\t\tdriverVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tdisposed: this._disposed,\n\t\t\t\t\t\tsocketConnected: this.socket?.connected,\n\t\t\t\t\t\ttrackedListenerCount: this.trackedListeners.size,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\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\tdisposed: this._disposed,\n\t\t\t\tsocketConnected: this.socket.connected,\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\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// Let user of connection object know about disconnect. This has to happen in between setting _disposed and\n\t\t// removing all listeners!\n\t\tthis.emit(\"disconnect\", err);\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"AfterDisconnectEvent\",\n\t\t\tdriverVersion,\n\t\t\tdetails: JSON.stringify({\n\t\t\t\tsocketConnected: this.socket.connected,\n\t\t\t\tdisconnectListenerCount: this.listenerCount(\"disconnect\"),\n\t\t\t}),\n\t\t});\n\t\t// user of DeltaConnection should have processed \"disconnect\" event and removed all listeners. Not clear\n\t\t// if we want to enforce that, as some users (like LocalDocumentService) do not unregister any handlers\n\t\t// assert(this.listenerCount(\"disconnect\") === 0, \"'disconnect` events should be processed synchronously\");\n\n\t\tthis.removeTrackedListeners();\n\t\tthis.disconnectCore();\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\tthis.closeSocket(err);\n\t\t\t\treject(err);\n\t\t\t};\n\n\t\t\tconst failConnection = (err: IAnyDriverError) => {\n\t\t\t\tthis.disconnect(err);\n\t\t\t\treject(err);\n\t\t\t};\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) => {\n\t\t\t\tconst err = this.createErrorObject(\"disconnect\", reason);\n\t\t\t\tfailAndCloseSocket(err);\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\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\t\t});\n\n\t\tassert(!this.disposed, 0x246 /* \"checking consistency of socket & _disposed flags\" */);\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\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a string: log it in the message (if not a string, it may contain PII but will print as [object Object])\n\t\t// - an Error object thrown by socket.io engine. Be careful with not recording PII!\n\t\tlet message: string;\n\t\tif (error?.type === \"TransportError\") {\n\t\t\t// JSON.stringify drops Error.message\n\t\t\tconst messagePrefix = error?.message !== undefined ? `${error.message}: ` : \"\";\n\n\t\t\t// Websocket errors reported by engine.io-client.\n\t\t\t// They are Error objects with description containing WS error and description = \"TransportError\"\n\t\t\t// Please see https://github.com/socketio/engine.io-client/blob/7245b80/lib/transport.ts#L44,\n\t\t\tmessage = `${messagePrefix}${JSON.stringify(error, getCircularReplacer())}`;\n\t\t} else {\n\t\t\tmessage = extractLogSafeErrorProperties(error, true).message;\n\t\t}\n\n\t\tconst errorObj = createGenericNetworkError(\n\t\t\t`socket.io (${handler}): ${message}`,\n\t\t\t{ canRetry },\n\t\t\t{ driverVersion },\n\t\t);\n\n\t\treturn errorObj;\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.3.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.3.1.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.3.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.3.1.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.3.
|
|
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.3.1.1\";\n"]}
|
|
@@ -14,7 +14,6 @@ export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandli
|
|
|
14
14
|
protected readonly socket: Socket;
|
|
15
15
|
documentId: string;
|
|
16
16
|
private readonly enableLongPollingDowngrades;
|
|
17
|
-
protected readonly connectionId?: string | undefined;
|
|
18
17
|
static readonly eventsToForward: string[];
|
|
19
18
|
static readonly eventsAlwaysForwarded: string[];
|
|
20
19
|
/**
|
|
@@ -55,7 +54,7 @@ export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandli
|
|
|
55
54
|
* @param logger - for reporting telemetry events
|
|
56
55
|
* @param enableLongPollingDowngrades - allow connection to be downgraded to long-polling on websocket failure
|
|
57
56
|
*/
|
|
58
|
-
protected constructor(socket: Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean
|
|
57
|
+
protected constructor(socket: Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean);
|
|
59
58
|
/**
|
|
60
59
|
* Get the ID of the client who is sending the message
|
|
61
60
|
*
|
|
@@ -145,7 +144,6 @@ export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandli
|
|
|
145
144
|
*/
|
|
146
145
|
protected disconnectCore(): void;
|
|
147
146
|
protected initialize(connectMessage: IConnect, timeout: number): Promise<void>;
|
|
148
|
-
private addPropsToError;
|
|
149
147
|
protected earlyOpHandler: (documentId: string, msgs: ISequencedDocumentMessage[]) => void;
|
|
150
148
|
protected earlySignalHandler: (msg: ISignalMessage) => void;
|
|
151
149
|
private removeEarlyOpHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,eAAe,EACf,wBAAwB,EACxB,8BAA8B,EAC9B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,cAAc,EACd,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