@fluidframework/driver-base 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.3.0.115467
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 +2 -1
- package/dist/documentDeltaConnection.d.ts +10 -7
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js +46 -21
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -11
- package/dist/index.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 +10 -7
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js +46 -21
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/test/types/validateDriverBasePrevious.generated.d.ts +2 -0
- package/lib/test/types/validateDriverBasePrevious.generated.d.ts.map +1 -0
- package/lib/test/types/{validateDriverBasePrevious.js → validateDriverBasePrevious.generated.js} +1 -1
- package/lib/test/types/validateDriverBasePrevious.generated.js.map +1 -0
- package/package.json +18 -14
- package/prettier.config.cjs +8 -0
- package/src/documentDeltaConnection.ts +53 -25
- package/src/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/lib/test/types/validateDriverBasePrevious.d.ts +0 -2
- package/lib/test/types/validateDriverBasePrevious.d.ts.map +0 -1
- package/lib/test/types/validateDriverBasePrevious.js.map +0 -1
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/common-utils";
|
|
7
7
|
import {
|
|
8
|
+
IAnyDriverError,
|
|
8
9
|
IDocumentDeltaConnection,
|
|
9
10
|
IDocumentDeltaConnectionEvents,
|
|
10
11
|
} from "@fluidframework/driver-definitions";
|
|
11
|
-
import { createGenericNetworkError
|
|
12
|
+
import { createGenericNetworkError } from "@fluidframework/driver-utils";
|
|
12
13
|
import {
|
|
13
14
|
ConnectionMode,
|
|
14
15
|
IClientConfiguration,
|
|
@@ -310,17 +311,30 @@ export class DocumentDeltaConnection
|
|
|
310
311
|
}
|
|
311
312
|
|
|
312
313
|
/**
|
|
313
|
-
* Disconnect from the websocket
|
|
314
|
+
* Disconnect from the websocket and close the websocket too.
|
|
315
|
+
*/
|
|
316
|
+
protected closeSocket(error: IAnyDriverError) {
|
|
317
|
+
this.disconnect(error);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Disconnect from the websocket, and permanently disable this DocumentDeltaConnection and close the socket.
|
|
322
|
+
* However the OdspDocumentDeltaConnection differ in dispose as in there we don't close the socket. There is no
|
|
323
|
+
* multiplexing here, so we need to close the socket here.
|
|
314
324
|
*/
|
|
315
325
|
public dispose() {
|
|
316
|
-
this.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
326
|
+
this.logger.sendTelemetryEvent({
|
|
327
|
+
eventName: "ClientClosingDeltaConnection",
|
|
328
|
+
driverVersion,
|
|
329
|
+
details: JSON.stringify({ disposed: this._disposed, socketConnected: this.socket.connected }),
|
|
330
|
+
});
|
|
331
|
+
this.disconnect(createGenericNetworkError(
|
|
332
|
+
// pre-0.58 error message: clientClosingConnection
|
|
333
|
+
"Client closing delta connection", { canRetry: true }, { driverVersion }),
|
|
334
|
+
);
|
|
321
335
|
}
|
|
322
336
|
|
|
323
|
-
protected
|
|
337
|
+
protected disconnect(err: IAnyDriverError) {
|
|
324
338
|
// Can't check this.disposed here, as we get here on socket closure,
|
|
325
339
|
// so _disposed & socket.connected might be not in sync while processing
|
|
326
340
|
// "dispose" event.
|
|
@@ -335,17 +349,30 @@ export class DocumentDeltaConnection
|
|
|
335
349
|
// to prevent normal messages from being emitted.
|
|
336
350
|
this._disposed = true;
|
|
337
351
|
|
|
352
|
+
// Let user of connection object know about disconnect. This has to happen in between setting _disposed and
|
|
353
|
+
// removing all listeners!
|
|
354
|
+
this.emit("disconnect", err);
|
|
355
|
+
this.logger.sendTelemetryEvent({
|
|
356
|
+
eventName: "AfterDisconnectEvent",
|
|
357
|
+
driverVersion,
|
|
358
|
+
details: JSON.stringify({
|
|
359
|
+
socketConnected: this.socket.connected,
|
|
360
|
+
disconnectListenerCount: this.listenerCount("disconnect"),
|
|
361
|
+
}),
|
|
362
|
+
});
|
|
363
|
+
// user of DeltaConnection should have processed "disconnect" event and removed all listeners. Not clear
|
|
364
|
+
// if we want to enforce that, as some users (like LocalDocumentService) do not unregister any handlers
|
|
365
|
+
// assert(this.listenerCount("disconnect") === 0, "'disconnect` events should be processed synchronously");
|
|
366
|
+
|
|
338
367
|
this.removeTrackedListeners();
|
|
339
|
-
this.
|
|
368
|
+
this.disconnectCore();
|
|
340
369
|
}
|
|
341
370
|
|
|
342
371
|
/**
|
|
343
372
|
* Disconnect from the websocket.
|
|
344
|
-
* @param socketProtocolError - true if error happened on socket / socket.io protocol level
|
|
345
|
-
* (not on Fluid protocol level)
|
|
346
373
|
* @param reason - reason for disconnect
|
|
347
374
|
*/
|
|
348
|
-
protected
|
|
375
|
+
protected disconnectCore() {
|
|
349
376
|
this.socket.disconnect();
|
|
350
377
|
}
|
|
351
378
|
|
|
@@ -364,11 +391,15 @@ export class DocumentDeltaConnection
|
|
|
364
391
|
getMaxInternalSocketReconnectionAttempts() + 1;
|
|
365
392
|
|
|
366
393
|
this._details = await new Promise<IConnected>((resolve, reject) => {
|
|
367
|
-
const
|
|
368
|
-
this.
|
|
394
|
+
const failAndCloseSocket = (err: IAnyDriverError) => {
|
|
395
|
+
this.closeSocket(err);
|
|
369
396
|
reject(err);
|
|
370
397
|
};
|
|
371
398
|
|
|
399
|
+
const failConnection = (err: IAnyDriverError) => {
|
|
400
|
+
this.disconnect(err);
|
|
401
|
+
reject(err);
|
|
402
|
+
};
|
|
372
403
|
// Listen for connection issues
|
|
373
404
|
this.addConnectionListener("connect_error", (error) => {
|
|
374
405
|
internalSocketConnectionFailureCount++;
|
|
@@ -406,12 +437,12 @@ export class DocumentDeltaConnection
|
|
|
406
437
|
return;
|
|
407
438
|
}
|
|
408
439
|
|
|
409
|
-
|
|
440
|
+
failAndCloseSocket(this.createErrorObject("connect_error", error));
|
|
410
441
|
});
|
|
411
442
|
|
|
412
443
|
// Listen for timeouts
|
|
413
444
|
this.addConnectionListener("connect_timeout", () => {
|
|
414
|
-
|
|
445
|
+
failAndCloseSocket(this.createErrorObject("connect_timeout"));
|
|
415
446
|
});
|
|
416
447
|
|
|
417
448
|
this.addConnectionListener("connect_document_success", (response: IConnected) => {
|
|
@@ -430,7 +461,7 @@ export class DocumentDeltaConnection
|
|
|
430
461
|
// The only time we expect a mismatch in requested/actual is if we lack write permissions
|
|
431
462
|
// In this case we will get "read", even if we requested "write"
|
|
432
463
|
if (actualMode !== requestedMode) {
|
|
433
|
-
|
|
464
|
+
failConnection(this.createErrorObject(
|
|
434
465
|
"connect_document_success",
|
|
435
466
|
"Connected in a different mode than was requested",
|
|
436
467
|
false,
|
|
@@ -439,7 +470,7 @@ export class DocumentDeltaConnection
|
|
|
439
470
|
}
|
|
440
471
|
} else {
|
|
441
472
|
if (actualMode === "write") {
|
|
442
|
-
|
|
473
|
+
failConnection(this.createErrorObject(
|
|
443
474
|
"connect_document_success",
|
|
444
475
|
"Connected in write mode without write permissions",
|
|
445
476
|
false,
|
|
@@ -459,17 +490,14 @@ export class DocumentDeltaConnection
|
|
|
459
490
|
// had a chance to register its handlers.
|
|
460
491
|
this.addTrackedListener("disconnect", (reason) => {
|
|
461
492
|
const err = this.createErrorObject("disconnect", reason);
|
|
462
|
-
|
|
463
|
-
fail(true, err);
|
|
493
|
+
failAndCloseSocket(err);
|
|
464
494
|
});
|
|
465
495
|
|
|
466
496
|
this.addTrackedListener("error", ((error) => {
|
|
467
|
-
// First, raise an error event, to give clients a chance to observe error contents
|
|
468
497
|
// This includes "Invalid namespace" error, which we consider critical (reconnecting will not help)
|
|
469
498
|
const err = this.createErrorObject("error", error, error !== "Invalid namespace");
|
|
470
|
-
this.emit("error", err);
|
|
471
499
|
// Disconnect socket - required if happened before initial handshake
|
|
472
|
-
|
|
500
|
+
failAndCloseSocket(err);
|
|
473
501
|
}));
|
|
474
502
|
|
|
475
503
|
this.addConnectionListener("connect_document_error", ((error) => {
|
|
@@ -482,14 +510,14 @@ export class DocumentDeltaConnection
|
|
|
482
510
|
|
|
483
511
|
// This is not an socket.io error - it's Fluid protocol error.
|
|
484
512
|
// In this case fail connection and indicate that we were unable to create connection
|
|
485
|
-
|
|
513
|
+
failConnection(this.createErrorObject("connect_document_error", error));
|
|
486
514
|
}));
|
|
487
515
|
|
|
488
516
|
this.socket.emit("connect_document", connectMessage);
|
|
489
517
|
|
|
490
518
|
// Give extra 2 seconds for handshake on top of socket connection timeout
|
|
491
519
|
this.socketConnectionTimeout = setTimeout(() => {
|
|
492
|
-
|
|
520
|
+
failConnection(this.createErrorObject("orderingServiceHandshakeTimeout"));
|
|
493
521
|
}, timeout + 2000);
|
|
494
522
|
});
|
|
495
523
|
|
package/src/index.ts
CHANGED
package/src/packageVersion.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateDriverBasePrevious.d.ts","sourceRoot":"","sources":["../../../src/test/types/validateDriverBasePrevious.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateDriverBasePrevious.js","sourceRoot":"","sources":["../../../src/test/types/validateDriverBasePrevious.ts"],"names":[],"mappings":"AAwBA,oDAAoD,CAChD,gDAAgD,EAAE,CAAC,CAAC;AAWxD,gDAAgD,CAC5C,oDAAoD,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/*\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * Generated by fluid-type-validator in @fluidframework/build-tools.\n */\nimport * as old from \"@fluidframework/driver-base-previous\";\nimport * as current from \"../../index\";\n\ntype TypeOnly<T> = {\n [P in keyof T]: TypeOnly<T[P]>;\n};\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_DocumentDeltaConnection\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_DocumentDeltaConnection():\n TypeOnly<old.DocumentDeltaConnection>;\ndeclare function use_current_ClassDeclaration_DocumentDeltaConnection(\n use: TypeOnly<current.DocumentDeltaConnection>);\nuse_current_ClassDeclaration_DocumentDeltaConnection(\n get_old_ClassDeclaration_DocumentDeltaConnection());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_DocumentDeltaConnection\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_DocumentDeltaConnection():\n TypeOnly<current.DocumentDeltaConnection>;\ndeclare function use_old_ClassDeclaration_DocumentDeltaConnection(\n use: TypeOnly<old.DocumentDeltaConnection>);\nuse_old_ClassDeclaration_DocumentDeltaConnection(\n get_current_ClassDeclaration_DocumentDeltaConnection());\n"]}
|