@fluidframework/driver-base
Advanced tools
Comparing version 0.29.4 to 0.30.0
@@ -9,2 +9,3 @@ /*! | ||
import { ConnectionMode, IClient, IConnect, IDocumentMessage, ISequencedDocumentMessage, IServiceConfiguration, ISignalClient, ISignalMessage, ITokenClaims } from "@fluidframework/protocol-definitions"; | ||
import { ITelemetryLogger } from "@fluidframework/common-definitions"; | ||
/** | ||
@@ -16,2 +17,3 @@ * Represents a connection to a stream of delta updates | ||
documentId: string; | ||
protected readonly logger: ITelemetryLogger; | ||
static readonly eventsToForward: string[]; | ||
@@ -30,3 +32,3 @@ /** | ||
*/ | ||
static create(tenantId: string, id: string, token: string | null, io: SocketIOClientStatic, client: IClient, url: string, timeoutMs?: number): Promise<IDocumentDeltaConnection>; | ||
static create(tenantId: string, id: string, token: string | null, io: SocketIOClientStatic, client: IClient, url: string, logger: ITelemetryLogger, timeoutMs?: number): Promise<IDocumentDeltaConnection>; | ||
/** | ||
@@ -63,3 +65,3 @@ * Last known sequence number to ordering service at the time of connection | ||
*/ | ||
protected constructor(socket: SocketIOClient.Socket, documentId: string); | ||
protected constructor(socket: SocketIOClient.Socket, documentId: string, logger: ITelemetryLogger); | ||
/** | ||
@@ -90,8 +92,2 @@ * Get the ID of the client who is sending the message | ||
/** | ||
* Get the parent branch for the document | ||
* | ||
* @returns the parent branch | ||
*/ | ||
get parentBranch(): string | null; | ||
/** | ||
* Get the maximum size of a message before chunking is required | ||
@@ -144,2 +140,3 @@ * | ||
close(): void; | ||
protected closeCore(socketProtocolError: boolean, err: DriverError): void; | ||
/** | ||
@@ -146,0 +143,0 @@ * Disconnect from the websocket. |
@@ -35,6 +35,7 @@ "use strict"; | ||
*/ | ||
constructor(socket, documentId) { | ||
constructor(socket, documentId, logger) { | ||
super(); | ||
this.socket = socket; | ||
this.documentId = documentId; | ||
this.logger = logger; | ||
// Listen for ops sent before we receive a response to connect_document | ||
@@ -98,3 +99,3 @@ this.queuedMessages = []; | ||
*/ | ||
static async create(tenantId, id, token, io, client, url, timeoutMs = 20000) { | ||
static async create(tenantId, id, token, io, client, url, logger, timeoutMs = 20000) { | ||
const socket = io(url, { | ||
@@ -117,3 +118,3 @@ query: { | ||
}; | ||
const deltaConnection = new DocumentDeltaConnection(socket, id); | ||
const deltaConnection = new DocumentDeltaConnection(socket, id, logger); | ||
await deltaConnection.initialize(connectMessage, timeoutMs); | ||
@@ -164,10 +165,2 @@ return deltaConnection; | ||
/** | ||
* Get the parent branch for the document | ||
* | ||
* @returns the parent branch | ||
*/ | ||
get parentBranch() { | ||
return this.details.parentBranch; | ||
} | ||
/** | ||
* Get the maximum size of a message before chunking is required | ||
@@ -257,14 +250,26 @@ * | ||
close() { | ||
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting on the socket is allowed, which is important since | ||
// OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that below we may | ||
// still send disconnect_document which is allowed; this is only intended to prevent normal messages from | ||
// being emitted. | ||
this.closeCore(false, // socketProtocolError | ||
driver_utils_1.createGenericNetworkError("client closing connection", true /* canRetry */)); | ||
} | ||
closeCore(socketProtocolError, err) { | ||
if (this.closed) { | ||
// We see cases where socket is closed while we have two "disconect" listeners - one from DeltaManager, | ||
// one - early handler that should have been removed on establishing connection. This causes asserts in | ||
// OdspDocumentDeltaConnection.disconnect() due to not expectting two calls. | ||
this.logger.sendErrorEvent({ | ||
eventName: "DoubleClose", | ||
connectionEvents: this.connectionListeners.length, | ||
trackedEvents: this.trackedListeners.length, | ||
socketProtocolError, | ||
}, err); | ||
return; | ||
} | ||
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is | ||
// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that | ||
// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended | ||
// to prevent normal messages from being emitted. | ||
this.closed = true; | ||
const reason = driver_utils_1.createGenericNetworkError("client closing connection", true); | ||
this.removeTrackedListeners(); | ||
this.disconnect(false, reason); | ||
this.disconnect(socketProtocolError, err); | ||
} | ||
@@ -287,5 +292,6 @@ /** | ||
const fail = (socketProtocolError, err) => { | ||
this.closed = true; | ||
this.removeTrackedListeners(); | ||
this.disconnect(socketProtocolError, err); | ||
// timeout & "error" can happen after successful connection | ||
if (!success) { | ||
this.closeCore(socketProtocolError, err); | ||
} | ||
reject(err); | ||
@@ -343,5 +349,3 @@ }; | ||
this.socketConnectionTimeout = setTimeout(() => { | ||
if (!success) { | ||
fail(false, createErrorObject("Timeout waiting for handshake from ordering service")); | ||
} | ||
fail(false, createErrorObject("Timeout waiting for handshake from ordering service")); | ||
}, timeout + 2000); | ||
@@ -371,3 +375,2 @@ }); | ||
this.removeConnectionListeners(); | ||
clearTimeout(this.socketConnectionTimeout); | ||
this.removeEarlyOpHandler(); | ||
@@ -378,2 +381,3 @@ this.removeEarlySignalHandler(); | ||
removeConnectionListeners() { | ||
clearTimeout(this.socketConnectionTimeout); | ||
for (const { event, listener } of this.connectionListeners) { | ||
@@ -380,0 +384,0 @@ this.socket.off(event, listener); |
@@ -5,4 +5,3 @@ /*! | ||
*/ | ||
export * from "./debug"; | ||
export * from "./documentDeltaConnection"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,4 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./debug")); | ||
__export(require("./documentDeltaConnection")); | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ /*! | ||
export declare const pkgName = "@fluidframework/driver-base"; | ||
export declare const pkgVersion = "0.29.4"; | ||
export declare const pkgVersion = "0.30.0"; | ||
//# sourceMappingURL=packageVersion.d.ts.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
exports.pkgName = "@fluidframework/driver-base"; | ||
exports.pkgVersion = "0.29.4"; | ||
exports.pkgVersion = "0.30.0"; | ||
//# sourceMappingURL=packageVersion.js.map |
@@ -9,2 +9,3 @@ /*! | ||
import { ConnectionMode, IClient, IConnect, IDocumentMessage, ISequencedDocumentMessage, IServiceConfiguration, ISignalClient, ISignalMessage, ITokenClaims } from "@fluidframework/protocol-definitions"; | ||
import { ITelemetryLogger } from "@fluidframework/common-definitions"; | ||
/** | ||
@@ -16,2 +17,3 @@ * Represents a connection to a stream of delta updates | ||
documentId: string; | ||
protected readonly logger: ITelemetryLogger; | ||
static readonly eventsToForward: string[]; | ||
@@ -30,3 +32,3 @@ /** | ||
*/ | ||
static create(tenantId: string, id: string, token: string | null, io: SocketIOClientStatic, client: IClient, url: string, timeoutMs?: number): Promise<IDocumentDeltaConnection>; | ||
static create(tenantId: string, id: string, token: string | null, io: SocketIOClientStatic, client: IClient, url: string, logger: ITelemetryLogger, timeoutMs?: number): Promise<IDocumentDeltaConnection>; | ||
/** | ||
@@ -63,3 +65,3 @@ * Last known sequence number to ordering service at the time of connection | ||
*/ | ||
protected constructor(socket: SocketIOClient.Socket, documentId: string); | ||
protected constructor(socket: SocketIOClient.Socket, documentId: string, logger: ITelemetryLogger); | ||
/** | ||
@@ -90,8 +92,2 @@ * Get the ID of the client who is sending the message | ||
/** | ||
* Get the parent branch for the document | ||
* | ||
* @returns the parent branch | ||
*/ | ||
get parentBranch(): string | null; | ||
/** | ||
* Get the maximum size of a message before chunking is required | ||
@@ -144,2 +140,3 @@ * | ||
close(): void; | ||
protected closeCore(socketProtocolError: boolean, err: DriverError): void; | ||
/** | ||
@@ -146,0 +143,0 @@ * Disconnect from the websocket. |
@@ -33,6 +33,7 @@ /*! | ||
*/ | ||
constructor(socket, documentId) { | ||
constructor(socket, documentId, logger) { | ||
super(); | ||
this.socket = socket; | ||
this.documentId = documentId; | ||
this.logger = logger; | ||
// Listen for ops sent before we receive a response to connect_document | ||
@@ -96,3 +97,3 @@ this.queuedMessages = []; | ||
*/ | ||
static async create(tenantId, id, token, io, client, url, timeoutMs = 20000) { | ||
static async create(tenantId, id, token, io, client, url, logger, timeoutMs = 20000) { | ||
const socket = io(url, { | ||
@@ -115,3 +116,3 @@ query: { | ||
}; | ||
const deltaConnection = new DocumentDeltaConnection(socket, id); | ||
const deltaConnection = new DocumentDeltaConnection(socket, id, logger); | ||
await deltaConnection.initialize(connectMessage, timeoutMs); | ||
@@ -162,10 +163,2 @@ return deltaConnection; | ||
/** | ||
* Get the parent branch for the document | ||
* | ||
* @returns the parent branch | ||
*/ | ||
get parentBranch() { | ||
return this.details.parentBranch; | ||
} | ||
/** | ||
* Get the maximum size of a message before chunking is required | ||
@@ -255,14 +248,26 @@ * | ||
close() { | ||
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting on the socket is allowed, which is important since | ||
// OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that below we may | ||
// still send disconnect_document which is allowed; this is only intended to prevent normal messages from | ||
// being emitted. | ||
this.closeCore(false, // socketProtocolError | ||
createGenericNetworkError("client closing connection", true /* canRetry */)); | ||
} | ||
closeCore(socketProtocolError, err) { | ||
if (this.closed) { | ||
// We see cases where socket is closed while we have two "disconect" listeners - one from DeltaManager, | ||
// one - early handler that should have been removed on establishing connection. This causes asserts in | ||
// OdspDocumentDeltaConnection.disconnect() due to not expectting two calls. | ||
this.logger.sendErrorEvent({ | ||
eventName: "DoubleClose", | ||
connectionEvents: this.connectionListeners.length, | ||
trackedEvents: this.trackedListeners.length, | ||
socketProtocolError, | ||
}, err); | ||
return; | ||
} | ||
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is | ||
// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that | ||
// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended | ||
// to prevent normal messages from being emitted. | ||
this.closed = true; | ||
const reason = createGenericNetworkError("client closing connection", true); | ||
this.removeTrackedListeners(); | ||
this.disconnect(false, reason); | ||
this.disconnect(socketProtocolError, err); | ||
} | ||
@@ -285,5 +290,6 @@ /** | ||
const fail = (socketProtocolError, err) => { | ||
this.closed = true; | ||
this.removeTrackedListeners(); | ||
this.disconnect(socketProtocolError, err); | ||
// timeout & "error" can happen after successful connection | ||
if (!success) { | ||
this.closeCore(socketProtocolError, err); | ||
} | ||
reject(err); | ||
@@ -341,5 +347,3 @@ }; | ||
this.socketConnectionTimeout = setTimeout(() => { | ||
if (!success) { | ||
fail(false, createErrorObject("Timeout waiting for handshake from ordering service")); | ||
} | ||
fail(false, createErrorObject("Timeout waiting for handshake from ordering service")); | ||
}, timeout + 2000); | ||
@@ -369,3 +373,2 @@ }); | ||
this.removeConnectionListeners(); | ||
clearTimeout(this.socketConnectionTimeout); | ||
this.removeEarlyOpHandler(); | ||
@@ -376,2 +379,3 @@ this.removeEarlySignalHandler(); | ||
removeConnectionListeners() { | ||
clearTimeout(this.socketConnectionTimeout); | ||
for (const { event, listener } of this.connectionListeners) { | ||
@@ -378,0 +382,0 @@ this.socket.off(event, listener); |
@@ -5,4 +5,3 @@ /*! | ||
*/ | ||
export * from "./debug"; | ||
export * from "./documentDeltaConnection"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,4 +5,3 @@ /*! | ||
*/ | ||
export * from "./debug"; | ||
export * from "./documentDeltaConnection"; | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ /*! | ||
export declare const pkgName = "@fluidframework/driver-base"; | ||
export declare const pkgVersion = "0.29.4"; | ||
export declare const pkgVersion = "0.30.0"; | ||
//# sourceMappingURL=packageVersion.d.ts.map |
@@ -8,3 +8,3 @@ /*! | ||
export const pkgName = "@fluidframework/driver-base"; | ||
export const pkgVersion = "0.29.4"; | ||
export const pkgVersion = "0.30.0"; | ||
//# sourceMappingURL=packageVersion.js.map |
{ | ||
"name": "@fluidframework/driver-base", | ||
"version": "0.29.4", | ||
"version": "0.30.0", | ||
"description": "Shared driver code for Fluid driver implementations", | ||
@@ -31,5 +31,6 @@ "homepage": "https://fluidframework.com", | ||
"dependencies": { | ||
"@fluidframework/common-definitions": "^0.19.1", | ||
"@fluidframework/common-utils": "^0.25.0", | ||
"@fluidframework/driver-definitions": "^0.29.4", | ||
"@fluidframework/driver-utils": "^0.29.4", | ||
"@fluidframework/driver-definitions": "^0.30.0", | ||
"@fluidframework/driver-utils": "^0.30.0", | ||
"@fluidframework/protocol-definitions": "^0.1015.0", | ||
@@ -36,0 +37,0 @@ "assert": "^2.0.0", |
@@ -7,3 +7,2 @@ /*! | ||
import { assert , BatchManager, TypedEventEmitter } from "@fluidframework/common-utils"; | ||
import { | ||
@@ -27,2 +26,3 @@ IDocumentDeltaConnection, | ||
} from "@fluidframework/protocol-definitions"; | ||
import { ITelemetryLogger } from "@fluidframework/common-definitions"; | ||
import { debug } from "./debug"; | ||
@@ -85,2 +85,3 @@ | ||
url: string, | ||
logger: ITelemetryLogger, | ||
timeoutMs: number = 20000): Promise<IDocumentDeltaConnection> { | ||
@@ -108,3 +109,3 @@ const socket = io( | ||
const deltaConnection = new DocumentDeltaConnection(socket, id); | ||
const deltaConnection = new DocumentDeltaConnection(socket, id, logger); | ||
@@ -168,2 +169,3 @@ await deltaConnection.initialize(connectMessage, timeoutMs); | ||
public documentId: string, | ||
protected readonly logger: ITelemetryLogger, | ||
) { | ||
@@ -235,11 +237,2 @@ super(); | ||
/** | ||
* Get the parent branch for the document | ||
* | ||
* @returns the parent branch | ||
*/ | ||
public get parentBranch(): string | null { | ||
return this.details.parentBranch; | ||
} | ||
/** | ||
* Get the maximum size of a message before chunking is required | ||
@@ -341,18 +334,32 @@ * | ||
public close() { | ||
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting on the socket is allowed, which is important since | ||
// OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that below we may | ||
// still send disconnect_document which is allowed; this is only intended to prevent normal messages from | ||
// being emitted. | ||
this.closeCore( | ||
false, // socketProtocolError | ||
createGenericNetworkError("client closing connection", true /* canRetry */)); | ||
} | ||
protected closeCore(socketProtocolError: boolean, err: DriverError) { | ||
if (this.closed) { | ||
// We see cases where socket is closed while we have two "disconect" listeners - one from DeltaManager, | ||
// one - early handler that should have been removed on establishing connection. This causes asserts in | ||
// OdspDocumentDeltaConnection.disconnect() due to not expectting two calls. | ||
this.logger.sendErrorEvent( | ||
{ | ||
eventName: "DoubleClose", | ||
connectionEvents: this.connectionListeners.length, | ||
trackedEvents: this.trackedListeners.length, | ||
socketProtocolError, | ||
}, | ||
err); | ||
return; | ||
} | ||
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting messages (ops) on the socket is allowed, which is | ||
// important since OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. Note that | ||
// OdspDocumentDeltaConnection may still send disconnect_document which is allowed; this is only intended | ||
// to prevent normal messages from being emitted. | ||
this.closed = true; | ||
const reason = createGenericNetworkError( | ||
"client closing connection", | ||
true, // canRetry | ||
); | ||
this.removeTrackedListeners(); | ||
this.disconnect(false, reason); | ||
this.disconnect(socketProtocolError, err); | ||
} | ||
@@ -379,5 +386,6 @@ | ||
const fail = (socketProtocolError: boolean, err: DriverError) => { | ||
this.closed = true; | ||
this.removeTrackedListeners(); | ||
this.disconnect(socketProtocolError, err); | ||
// timeout & "error" can happen after successful connection | ||
if (!success) { | ||
this.closeCore(socketProtocolError, err); | ||
} | ||
reject(err); | ||
@@ -446,5 +454,3 @@ }; | ||
this.socketConnectionTimeout = setTimeout(() => { | ||
if (!success) { | ||
fail(false, createErrorObject("Timeout waiting for handshake from ordering service")); | ||
} | ||
fail(false, createErrorObject("Timeout waiting for handshake from ordering service")); | ||
}, timeout + 2000); | ||
@@ -490,4 +496,2 @@ }); | ||
clearTimeout(this.socketConnectionTimeout); | ||
this.removeEarlyOpHandler(); | ||
@@ -500,2 +504,4 @@ this.removeEarlySignalHandler(); | ||
private removeConnectionListeners() { | ||
clearTimeout(this.socketConnectionTimeout); | ||
for (const { event, listener } of this.connectionListeners) { | ||
@@ -502,0 +508,0 @@ this.socket.off(event, listener); |
@@ -6,3 +6,2 @@ /*! | ||
export * from "./debug"; | ||
export * from "./documentDeltaConnection"; |
@@ -9,2 +9,2 @@ /*! | ||
export const pkgName = "@fluidframework/driver-base"; | ||
export const pkgVersion = "0.29.4"; | ||
export const pkgVersion = "0.30.0"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136200
1647
7
+ Added@fluidframework/core-interfaces@0.30.4(transitive)
+ Added@fluidframework/driver-definitions@0.30.4(transitive)
+ Added@fluidframework/driver-utils@0.30.4(transitive)
+ Added@fluidframework/telemetry-utils@0.30.4(transitive)
- Removed@fluidframework/core-interfaces@0.29.4(transitive)
- Removed@fluidframework/driver-definitions@0.29.4(transitive)
- Removed@fluidframework/driver-utils@0.29.4(transitive)
- Removed@fluidframework/telemetry-utils@0.29.4(transitive)