@fluidframework/container-loader 0.51.2 → 0.52.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/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +5 -3
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +15 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +31 -19
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +4 -4
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +7 -18
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +5 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js.map +1 -1
- package/dist/loader.d.ts +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/utils.js +6 -5
- package/dist/utils.js.map +1 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +5 -3
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +15 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +32 -20
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +4 -4
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +7 -18
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +5 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js.map +1 -1
- package/lib/loader.d.ts +3 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.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/utils.js +6 -5
- package/lib/utils.js.map +1 -1
- package/package.json +11 -11
- package/src/connectionStateHandler.ts +6 -4
- package/src/container.ts +26 -14
- package/src/containerContext.ts +4 -3
- package/src/deltaManager.ts +15 -22
- package/src/deltaQueue.ts +10 -1
- package/src/loader.ts +4 -5
- package/src/packageVersion.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionStateHandler.d.ts","sourceRoot":"","sources":["../src/connectionStateHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,uBAAuB;IACpC,eAAe,EAAE,MAAM,iBAAiB,GAAG,SAAS,CAAC;IACrD,iCAAiC,EAC7B,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC7F,qBAAqB,EAAE,MAAM,OAAO,CAAC;IACrC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,kBAAkB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAID,qBAAa,sBAAsB;IA0B3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IA1B3B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AAS,CAAC;IAC3C,kBAAkB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAID,qBAAa,sBAAsB;IA0B3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IA1B3B,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAQ;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IAEpC,OAAO,CAAC,SAAS,CAA+B;IAEhD,IAAW,eAAe,IAAI,eAAe,CAE5C;IAED,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,IAAW,QAAQ,IAAI,MAAM,GAAG,SAAS,CAExC;IAED,IAAW,eAAe,IAAI,MAAM,GAAG,SAAS,CAE/C;gBAGoB,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,gBAAgB;IAyB7C,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,eAAe;IAKhB,sBAAsB,CAAC,QAAQ,EAAE,MAAM;IAsB9C,OAAO,CAAC,sBAAsB;IA4BvB,yBAAyB,CAAC,QAAQ,EAAE,MAAM;IAQ1C,uBAAuB,CAAC,MAAM,EAAE,MAAM;IAOtC,oBAAoB,CACvB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,kBAAkB;IA+B/B,OAAO,CAAC,kBAAkB;CAuD7B"}
|
|
@@ -91,6 +91,7 @@ class ConnectionStateHandler {
|
|
|
91
91
|
// Adding this event temporarily so that we can get help debugging if something goes wrong.
|
|
92
92
|
this.logger.sendTelemetryEvent({
|
|
93
93
|
eventName: "connectedStateRejected",
|
|
94
|
+
category: source === "timeout" ? "error" : "generic",
|
|
94
95
|
source,
|
|
95
96
|
pendingClientId: this.pendingClientId,
|
|
96
97
|
clientId: this.clientId,
|
|
@@ -123,7 +124,7 @@ class ConnectionStateHandler {
|
|
|
123
124
|
// join message. after we see the join message for out new connection with our new client id,
|
|
124
125
|
// we know there can no longer be outstanding ops that we sent with the previous client id.
|
|
125
126
|
this._pendingClientId = details.clientId;
|
|
126
|
-
// Report telemetry after we set client id!
|
|
127
|
+
// Report telemetry after we set client id, but before transitioning to Connected state below!
|
|
127
128
|
this.handler.logConnectionStateChangeTelemetry(container_1.ConnectionState.Connecting, oldState);
|
|
128
129
|
const protocolHandler = this.handler.protocolHandler();
|
|
129
130
|
// Check if we already processed our own join op through delta storage!
|
|
@@ -185,9 +186,10 @@ class ConnectionStateHandler {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
|
-
|
|
189
|
-
// Report telemetry after we set client id!
|
|
189
|
+
// Report transition before we propagate event across layers
|
|
190
190
|
this.handler.logConnectionStateChangeTelemetry(this._connectionState, oldState, reason);
|
|
191
|
+
// Propagate event across layers
|
|
192
|
+
this.handler.connectionStateChanged();
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
exports.ConnectionStateHandler = ConnectionStateHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionStateHandler.js","sourceRoot":"","sources":["../src/connectionStateHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,qEAAmE;AACnE,+DAA6D;AAC7D,2CAA8C;AAgB9C,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B,MAAa,sBAAsB;IAyB/B,YACqB,OAAgC,EAChC,MAAwB;;QADxB,YAAO,GAAP,OAAO,CAAyB;QAChC,WAAM,GAAN,MAAM,CAAkB;QA1BrC,qBAAgB,GAAG,2BAAe,CAAC,YAAY,CAAC;QA4BpD,IAAI,CAAC,mBAAmB,GAAG,IAAI,oBAAK;QAChC,gF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AM,IAAI,KAAK,KAAK,2BAAe,CAAC,YAAY,EAAE;YAC/C,4EAA4E;YAC5E,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAClC,oGAAoG;YACpG,sGAAsG;YACtG,mCAAmC;YACnC,uGAAuG;YACvG,qGAAqG;YACrG,sGAAsG;YACtG,IAAI,MAAM,KAAK,SAAS;mBACjB,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;mBACpC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,KAAK,KAAK,EAChD;gBACE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;aACtC;iBAAM;gBACH,2FAA2F;gBAC3F,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;oBAC3B,SAAS,EAAE,sBAAsB;oBACjC,QAAQ,EAAE,MAAM,KAAK,SAAS;oBAC9B,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,QAAQ;oBAC3C,qBAAqB,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;iBAC9D,CAAC,CAAC;aACN;SACJ;QAED,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;QAEtC,2CAA2C;QAC3C,IAAI,CAAC,OAAO,CAAC,iCAAiC,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5F,CAAC;CACJ;AArND,wDAqNC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IConnectionDetails } from \"@fluidframework/container-definitions\";\nimport { ProtocolOpHandler } from \"@fluidframework/protocol-base\";\nimport { ConnectionMode, ISequencedClient } from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert, Timer } from \"@fluidframework/common-utils\";\nimport { ConnectionState } from \"./container\";\n\nexport interface IConnectionStateHandler {\n protocolHandler: () => ProtocolOpHandler | undefined,\n logConnectionStateChangeTelemetry:\n (value: ConnectionState, oldState: ConnectionState, reason?: string | undefined) => void,\n shouldClientJoinWrite: () => boolean,\n maxClientLeaveWaitTime: number | undefined,\n logConnectionIssue: (eventName: string) => void,\n connectionStateChanged: () => void,\n}\n\nexport interface ILocalSequencedClient extends ISequencedClient {\n shouldHaveLeft?: boolean;\n}\n\nconst JoinOpTimer = 45000;\n\nexport class ConnectionStateHandler {\n private _connectionState = ConnectionState.Disconnected;\n private _pendingClientId: string | undefined;\n private _clientId: string | undefined;\n private readonly prevClientLeftTimer: Timer;\n private readonly joinOpTimer: Timer;\n\n private waitEvent: PerformanceEvent | undefined;\n\n public get connectionState(): ConnectionState {\n return this._connectionState;\n }\n\n public get connected(): boolean {\n return this.connectionState === ConnectionState.Connected;\n }\n\n public get clientId(): string | undefined {\n return this._clientId;\n }\n\n public get pendingClientId(): string | undefined {\n return this._pendingClientId;\n }\n\n constructor(\n private readonly handler: IConnectionStateHandler,\n private readonly logger: ITelemetryLogger,\n ) {\n this.prevClientLeftTimer = new Timer(\n // Default is 90 sec for which we are going to wait for its own \"leave\" message.\n this.handler.maxClientLeaveWaitTime ?? 90000,\n () => {\n this.applyForConnectedState(\"timeout\");\n },\n );\n\n // Based on recent data, it looks like majority of cases where we get stuck are due to really slow or\n // timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so\n // if retrying fixes the problem, we should not see these events.\n this.joinOpTimer = new Timer(\n JoinOpTimer,\n () => {\n // I've observed timer firing within couple ms from disconnect event, looks like\n // queued timer callback is not cancelled if timer is cancelled while callback sits in the queue.\n if (this.connectionState === ConnectionState.Connecting) {\n this.handler.logConnectionIssue(\"NoJoinOp\");\n }\n },\n );\n }\n\n private startJoinOpTimer() {\n assert(!this.joinOpTimer.hasTimer, 0x234 /* \"has joinOpTimer\" */);\n this.joinOpTimer.start();\n }\n\n private stopJoinOpTimer() {\n assert(this.joinOpTimer.hasTimer, 0x235 /* \"no joinOpTimer\" */);\n this.joinOpTimer.clear();\n }\n\n public receivedAddMemberEvent(clientId: string) {\n // This is the only one that requires the pending client ID\n if (clientId === this.pendingClientId) {\n if (this.joinOpTimer.hasTimer) {\n this.stopJoinOpTimer();\n } else {\n // timer has already fired, meaning it took too long to get join on.\n // Record how long it actually took to recover.\n this.handler.logConnectionIssue(\"ReceivedJoinOp\");\n }\n // Start the event in case we are waiting for leave or timeout.\n if (this.prevClientLeftTimer.hasTimer) {\n this.waitEvent = PerformanceEvent.start(this.logger, {\n eventName: \"WaitBeforeClientLeave\",\n waitOnClientId: this._clientId,\n hadOutstandingOps: this.handler.shouldClientJoinWrite(),\n });\n }\n this.applyForConnectedState(\"addMemberEvent\");\n }\n }\n\n private applyForConnectedState(source: \"removeMemberEvent\" | \"addMemberEvent\" | \"timeout\") {\n const protocolHandler = this.handler.protocolHandler();\n assert(protocolHandler !== undefined, 0x236 /* \"In all cases it should be already installed\" */);\n // Move to connected state only if we are in Connecting state, we have seen our join op\n // and there is no timer running which means we are not waiting for previous client to leave\n // or timeout has occured while doing so.\n if (this.pendingClientId !== this.clientId\n && this.pendingClientId !== undefined\n && protocolHandler.quorum.getMember(this.pendingClientId) !== undefined\n && !this.prevClientLeftTimer.hasTimer\n ) {\n this.waitEvent?.end({ source });\n this.setConnectionState(ConnectionState.Connected);\n } else {\n // Adding this event temporarily so that we can get help debugging if something goes wrong.\n this.logger.sendTelemetryEvent({\n eventName: \"connectedStateRejected\",\n source,\n pendingClientId: this.pendingClientId,\n clientId: this.clientId,\n hasTimer: this.prevClientLeftTimer.hasTimer,\n inQuorum: protocolHandler !== undefined && this.pendingClientId !== undefined\n && protocolHandler.quorum.getMember(this.pendingClientId) !== undefined,\n });\n }\n }\n\n public receivedRemoveMemberEvent(clientId: string) {\n // If the client which has left was us, then finish the timer.\n if (this.clientId === clientId) {\n this.prevClientLeftTimer.clear();\n this.applyForConnectedState(\"removeMemberEvent\");\n }\n }\n\n public receivedDisconnectEvent(reason: string) {\n if (this.joinOpTimer.hasTimer) {\n this.stopJoinOpTimer();\n }\n this.setConnectionState(ConnectionState.Disconnected, reason);\n }\n\n public receivedConnectEvent(\n connectionMode: ConnectionMode,\n details: IConnectionDetails,\n ) {\n const oldState = this._connectionState;\n this._connectionState = ConnectionState.Connecting;\n\n // Stash the clientID to detect when transitioning from connecting (socket.io channel open) to connected\n // (have received the join message for the client ID)\n // This is especially important in the reconnect case. It's possible there could be outstanding\n // ops sent by this client, so we should keep the old client id until we see our own client's\n // join message. after we see the join message for out new connection with our new client id,\n // we know there can no longer be outstanding ops that we sent with the previous client id.\n this._pendingClientId = details.clientId;\n\n // Report telemetry after we set client id!\n this.handler.logConnectionStateChangeTelemetry(ConnectionState.Connecting, oldState);\n\n const protocolHandler = this.handler.protocolHandler();\n // Check if we already processed our own join op through delta storage!\n // we are fetching ops from storage in parallel to connecting to ordering service\n // Given async processes, it's possible that we have already processed our own join message before\n // connection was fully established.\n // Note that we might be still initializing quorum - connection is established proactively on load!\n if ((protocolHandler !== undefined && protocolHandler.quorum.getMember(details.clientId) !== undefined)\n || connectionMode === \"read\"\n ) {\n this.setConnectionState(ConnectionState.Connected);\n } else if (connectionMode === \"write\") {\n this.startJoinOpTimer();\n }\n }\n\n private setConnectionState(value: ConnectionState.Disconnected, reason: string);\n private setConnectionState(value: ConnectionState.Connected);\n private setConnectionState(value: ConnectionState, reason?: string) {\n if (this.connectionState === value) {\n // Already in the desired state - exit early\n this.logger.sendErrorEvent({ eventName: \"setConnectionStateSame\", value });\n return;\n }\n\n const oldState = this._connectionState;\n this._connectionState = value;\n const quorum = this.handler.protocolHandler()?.quorum;\n let client: ILocalSequencedClient | undefined;\n if (this._clientId !== undefined) {\n client = quorum?.getMember(this._clientId);\n }\n if (value === ConnectionState.Connected) {\n assert(oldState === ConnectionState.Connecting,\n 0x1d8 /* \"Should only transition from Connecting state\" */);\n // Mark our old client should have left in the quorum if it's still there\n if (client !== undefined) {\n client.shouldHaveLeft = true;\n }\n this._clientId = this.pendingClientId;\n } else if (value === ConnectionState.Disconnected) {\n // Important as we process our own joinSession message through delta request\n this._pendingClientId = undefined;\n // Only wait for \"leave\" message if the connected client exists in the quorum because only the write\n // client will exist in the quorum and only for those clients we will receive \"removeMember\" event and\n // the client has some unacked ops.\n // Also server would not accept ops from read client. Also check if the timer is not already running as\n // we could receive \"Disconnected\" event multiple times without getting connected and in that case we\n // don't want to reset the timer as we still want to wait on original client which started this timer.\n if (client !== undefined\n && this.handler.shouldClientJoinWrite()\n && this.prevClientLeftTimer.hasTimer === false\n ) {\n this.prevClientLeftTimer.restart();\n } else {\n // Adding this event temporarily so that we can get help debugging if something goes wrong.\n this.logger.sendTelemetryEvent({\n eventName: \"noWaitOnDisconnected\",\n inQuorum: client !== undefined,\n hasTimer: this.prevClientLeftTimer.hasTimer,\n shouldClientJoinWrite: this.handler.shouldClientJoinWrite(),\n });\n }\n }\n\n this.handler.connectionStateChanged();\n\n // Report telemetry after we set client id!\n this.handler.logConnectionStateChangeTelemetry(this._connectionState, oldState, reason);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connectionStateHandler.js","sourceRoot":"","sources":["../src/connectionStateHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,qEAAmE;AACnE,+DAA6D;AAC7D,2CAA8C;AAgB9C,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B,MAAa,sBAAsB;IAyB/B,YACqB,OAAgC,EAChC,MAAwB;;QADxB,YAAO,GAAP,OAAO,CAAyB;QAChC,WAAM,GAAN,MAAM,CAAkB;QA1BrC,qBAAgB,GAAG,2BAAe,CAAC,YAAY,CAAC;QA4BpD,IAAI,CAAC,mBAAmB,GAAG,IAAI,oBAAK;QAChC,gFAAgF;QAChF,IAAI,CAAC,OAAO,CAAC,sBAAsB,mCAAI,KAAK,EAC5C,GAAG,EAAE;YACD,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC,CACJ,CAAC;QAEF,qGAA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CAAC,gBAAgB,GAAG,SAAS,CAAC;YAClC,oGAAoG;YACpG,sGAAsG;YACtG,mCAAmC;YACnC,uGAAuG;YACvG,qGAAqG;YACrG,sGAAsG;YACtG,IAAI,MAAM,KAAK,SAAS;mBACjB,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;mBACpC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,KAAK,KAAK,EAChD;gBACE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;aACtC;iBAAM;gBACH,2FAA2F;gBAC3F,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;oBAC3B,SAAS,EAAE,sBAAsB;oBACjC,QAAQ,EAAE,MAAM,KAAK,SAAS;oBAC9B,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,QAAQ;oBAC3C,qBAAqB,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;iBAC9D,CAAC,CAAC;aACN;SACJ;QAED,4DAA4D;QAC5D,IAAI,CAAC,OAAO,CAAC,iCAAiC,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAExF,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAC1C,CAAC;CACJ;AAvND,wDAuNC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IConnectionDetails } from \"@fluidframework/container-definitions\";\nimport { ProtocolOpHandler } from \"@fluidframework/protocol-base\";\nimport { ConnectionMode, ISequencedClient } from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert, Timer } from \"@fluidframework/common-utils\";\nimport { ConnectionState } from \"./container\";\n\nexport interface IConnectionStateHandler {\n protocolHandler: () => ProtocolOpHandler | undefined,\n logConnectionStateChangeTelemetry:\n (value: ConnectionState, oldState: ConnectionState, reason?: string | undefined) => void,\n shouldClientJoinWrite: () => boolean,\n maxClientLeaveWaitTime: number | undefined,\n logConnectionIssue: (eventName: string) => void,\n connectionStateChanged: () => void,\n}\n\nexport interface ILocalSequencedClient extends ISequencedClient {\n shouldHaveLeft?: boolean;\n}\n\nconst JoinOpTimer = 45000;\n\nexport class ConnectionStateHandler {\n private _connectionState = ConnectionState.Disconnected;\n private _pendingClientId: string | undefined;\n private _clientId: string | undefined;\n private readonly prevClientLeftTimer: Timer;\n private readonly joinOpTimer: Timer;\n\n private waitEvent: PerformanceEvent | undefined;\n\n public get connectionState(): ConnectionState {\n return this._connectionState;\n }\n\n public get connected(): boolean {\n return this.connectionState === ConnectionState.Connected;\n }\n\n public get clientId(): string | undefined {\n return this._clientId;\n }\n\n public get pendingClientId(): string | undefined {\n return this._pendingClientId;\n }\n\n constructor(\n private readonly handler: IConnectionStateHandler,\n private readonly logger: ITelemetryLogger,\n ) {\n this.prevClientLeftTimer = new Timer(\n // Default is 90 sec for which we are going to wait for its own \"leave\" message.\n this.handler.maxClientLeaveWaitTime ?? 90000,\n () => {\n this.applyForConnectedState(\"timeout\");\n },\n );\n\n // Based on recent data, it looks like majority of cases where we get stuck are due to really slow or\n // timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so\n // if retrying fixes the problem, we should not see these events.\n this.joinOpTimer = new Timer(\n JoinOpTimer,\n () => {\n // I've observed timer firing within couple ms from disconnect event, looks like\n // queued timer callback is not cancelled if timer is cancelled while callback sits in the queue.\n if (this.connectionState === ConnectionState.Connecting) {\n this.handler.logConnectionIssue(\"NoJoinOp\");\n }\n },\n );\n }\n\n private startJoinOpTimer() {\n assert(!this.joinOpTimer.hasTimer, 0x234 /* \"has joinOpTimer\" */);\n this.joinOpTimer.start();\n }\n\n private stopJoinOpTimer() {\n assert(this.joinOpTimer.hasTimer, 0x235 /* \"no joinOpTimer\" */);\n this.joinOpTimer.clear();\n }\n\n public receivedAddMemberEvent(clientId: string) {\n // This is the only one that requires the pending client ID\n if (clientId === this.pendingClientId) {\n if (this.joinOpTimer.hasTimer) {\n this.stopJoinOpTimer();\n } else {\n // timer has already fired, meaning it took too long to get join on.\n // Record how long it actually took to recover.\n this.handler.logConnectionIssue(\"ReceivedJoinOp\");\n }\n // Start the event in case we are waiting for leave or timeout.\n if (this.prevClientLeftTimer.hasTimer) {\n this.waitEvent = PerformanceEvent.start(this.logger, {\n eventName: \"WaitBeforeClientLeave\",\n waitOnClientId: this._clientId,\n hadOutstandingOps: this.handler.shouldClientJoinWrite(),\n });\n }\n this.applyForConnectedState(\"addMemberEvent\");\n }\n }\n\n private applyForConnectedState(source: \"removeMemberEvent\" | \"addMemberEvent\" | \"timeout\") {\n const protocolHandler = this.handler.protocolHandler();\n assert(protocolHandler !== undefined, 0x236 /* \"In all cases it should be already installed\" */);\n // Move to connected state only if we are in Connecting state, we have seen our join op\n // and there is no timer running which means we are not waiting for previous client to leave\n // or timeout has occured while doing so.\n if (this.pendingClientId !== this.clientId\n && this.pendingClientId !== undefined\n && protocolHandler.quorum.getMember(this.pendingClientId) !== undefined\n && !this.prevClientLeftTimer.hasTimer\n ) {\n this.waitEvent?.end({ source });\n this.setConnectionState(ConnectionState.Connected);\n } else {\n // Adding this event temporarily so that we can get help debugging if something goes wrong.\n this.logger.sendTelemetryEvent({\n eventName: \"connectedStateRejected\",\n category: source === \"timeout\" ? \"error\" : \"generic\",\n source,\n pendingClientId: this.pendingClientId,\n clientId: this.clientId,\n hasTimer: this.prevClientLeftTimer.hasTimer,\n inQuorum: protocolHandler !== undefined && this.pendingClientId !== undefined\n && protocolHandler.quorum.getMember(this.pendingClientId) !== undefined,\n });\n }\n }\n\n public receivedRemoveMemberEvent(clientId: string) {\n // If the client which has left was us, then finish the timer.\n if (this.clientId === clientId) {\n this.prevClientLeftTimer.clear();\n this.applyForConnectedState(\"removeMemberEvent\");\n }\n }\n\n public receivedDisconnectEvent(reason: string) {\n if (this.joinOpTimer.hasTimer) {\n this.stopJoinOpTimer();\n }\n this.setConnectionState(ConnectionState.Disconnected, reason);\n }\n\n public receivedConnectEvent(\n connectionMode: ConnectionMode,\n details: IConnectionDetails,\n ) {\n const oldState = this._connectionState;\n this._connectionState = ConnectionState.Connecting;\n\n // Stash the clientID to detect when transitioning from connecting (socket.io channel open) to connected\n // (have received the join message for the client ID)\n // This is especially important in the reconnect case. It's possible there could be outstanding\n // ops sent by this client, so we should keep the old client id until we see our own client's\n // join message. after we see the join message for out new connection with our new client id,\n // we know there can no longer be outstanding ops that we sent with the previous client id.\n this._pendingClientId = details.clientId;\n\n // Report telemetry after we set client id, but before transitioning to Connected state below!\n this.handler.logConnectionStateChangeTelemetry(ConnectionState.Connecting, oldState);\n\n const protocolHandler = this.handler.protocolHandler();\n // Check if we already processed our own join op through delta storage!\n // we are fetching ops from storage in parallel to connecting to ordering service\n // Given async processes, it's possible that we have already processed our own join message before\n // connection was fully established.\n // Note that we might be still initializing quorum - connection is established proactively on load!\n if ((protocolHandler !== undefined && protocolHandler.quorum.getMember(details.clientId) !== undefined)\n || connectionMode === \"read\"\n ) {\n this.setConnectionState(ConnectionState.Connected);\n } else if (connectionMode === \"write\") {\n this.startJoinOpTimer();\n }\n }\n\n private setConnectionState(value: ConnectionState.Disconnected, reason: string);\n private setConnectionState(value: ConnectionState.Connected);\n private setConnectionState(value: ConnectionState, reason?: string) {\n if (this.connectionState === value) {\n // Already in the desired state - exit early\n this.logger.sendErrorEvent({ eventName: \"setConnectionStateSame\", value });\n return;\n }\n\n const oldState = this._connectionState;\n this._connectionState = value;\n const quorum = this.handler.protocolHandler()?.quorum;\n let client: ILocalSequencedClient | undefined;\n if (this._clientId !== undefined) {\n client = quorum?.getMember(this._clientId);\n }\n if (value === ConnectionState.Connected) {\n assert(oldState === ConnectionState.Connecting,\n 0x1d8 /* \"Should only transition from Connecting state\" */);\n // Mark our old client should have left in the quorum if it's still there\n if (client !== undefined) {\n client.shouldHaveLeft = true;\n }\n this._clientId = this.pendingClientId;\n } else if (value === ConnectionState.Disconnected) {\n // Important as we process our own joinSession message through delta request\n this._pendingClientId = undefined;\n // Only wait for \"leave\" message if the connected client exists in the quorum because only the write\n // client will exist in the quorum and only for those clients we will receive \"removeMember\" event and\n // the client has some unacked ops.\n // Also server would not accept ops from read client. Also check if the timer is not already running as\n // we could receive \"Disconnected\" event multiple times without getting connected and in that case we\n // don't want to reset the timer as we still want to wait on original client which started this timer.\n if (client !== undefined\n && this.handler.shouldClientJoinWrite()\n && this.prevClientLeftTimer.hasTimer === false\n ) {\n this.prevClientLeftTimer.restart();\n } else {\n // Adding this event temporarily so that we can get help debugging if something goes wrong.\n this.logger.sendTelemetryEvent({\n eventName: \"noWaitOnDisconnected\",\n inQuorum: client !== undefined,\n hasTimer: this.prevClientLeftTimer.hasTimer,\n shouldClientJoinWrite: this.handler.shouldClientJoinWrite(),\n });\n }\n }\n\n // Report transition before we propagate event across layers\n this.handler.logConnectionStateChangeTelemetry(this._connectionState, oldState, reason);\n\n // Propagate event across layers\n this.handler.connectionStateChanged();\n }\n}\n"]}
|
package/dist/container.d.ts
CHANGED
|
@@ -159,10 +159,23 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
159
159
|
get scopes(): string[] | undefined;
|
|
160
160
|
get clientDetails(): IClientDetails;
|
|
161
161
|
/**
|
|
162
|
-
*
|
|
162
|
+
* The current code details for the container's runtime
|
|
163
|
+
* @deprecated use getSpecifiedCodeDetails for the code details currently specified for this container, or
|
|
164
|
+
* getLoadedCodeDetails for the code details that the container's context was loaded with.
|
|
165
|
+
* To be removed after getSpecifiedCodeDetails and getLoadedCodeDetails become ubiquitous.
|
|
163
166
|
*/
|
|
164
|
-
get chaincodePackage(): IFluidCodeDetails | undefined;
|
|
165
167
|
get codeDetails(): IFluidCodeDetails | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Get the code details that are currently specified for the container.
|
|
170
|
+
* @returns The current code details if any are specified, undefined if none are specified.
|
|
171
|
+
*/
|
|
172
|
+
getSpecifiedCodeDetails(): IFluidCodeDetails | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* Get the code details that were used to load the container.
|
|
175
|
+
* @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
|
|
176
|
+
* loaded.
|
|
177
|
+
*/
|
|
178
|
+
getLoadedCodeDetails(): IFluidCodeDetails | undefined;
|
|
166
179
|
/**
|
|
167
180
|
* Retrieves the audience associated with the document
|
|
168
181
|
*/
|
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACH,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,iBAAiB,EAEpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EAET,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EAGX,YAAY,EACZ,kBAAkB,EACrB,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EAEH,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAc5C,OAAO,EAGH,oBAAoB,EACpB,cAAc,EAGd,gBAAgB,EAEhB,OAAO,EAEP,yBAAyB,EAOzB,QAAQ,EAQX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEH,6BAA6B,EAG7B,eAAe,EAIlB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAelE,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,qBAAqB,CAAC,EAAE,cAAc,CAAC;IACvC,WAAW,EAAE,iBAAiB,CAAC;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,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C;IAS3C,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB5E,gBAAgB,CAAC,SAAS,EAAE,OAAO;IA2CnC,MAAM;IASb,OAAO,CAAC,cAAc;IAetB;;;;OAIG;IACI,qBAAqB,CAAC,OAAO,EAAE,gBAAgB;IASzC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAWhE,kBAAkB,CAAC,WAAW,EAAE,iBAAiB;YAmBhD,mBAAmB;YAgBnB,YAAY;IAwB1B,OAAO,CAAC,YAAY;YAyDN,UAAU;IAKxB,OAAO,CAAC,sBAAsB;YAMhB,oBAAoB;IAWlC;;;;;;OAMG;YACW,IAAI;YA0HJ,cAAc;YAuCd,6BAA6B;YA4B7B,qBAAqB;YAqBrB,qBAAqB;YA2BrB,8BAA8B;YA2B9B,uBAAuB;IAwDrC,OAAO,CAAC,sBAAsB;IAmC9B,OAAO,CAAC,wBAAwB;IAQhC,OAAO,KAAK,MAAM,GAkBjB;IAED;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,kBAAkB;YAkDZ,2BAA2B;IAiBzC,OAAO,CAAC,iCAAiC;IA6DzC,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,sBAAsB;IA4B9B,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,oBAAoB;IAoC5B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAiBrB;;;;OAIG;YACW,iBAAiB;YAkBjB,0BAA0B;YAkB1B,kBAAkB;IA0ChC,OAAO,CAAC,iBAAiB;CAG5B"}
|
package/dist/container.js
CHANGED
|
@@ -65,7 +65,7 @@ async function waitContainerToCatchUp(container) {
|
|
|
65
65
|
if (container.closed) {
|
|
66
66
|
throw new Error("Container is closed");
|
|
67
67
|
}
|
|
68
|
-
return new Promise((
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
69
|
const deltaManager = container.deltaManager;
|
|
70
70
|
container.on("closed", reject);
|
|
71
71
|
const waitForOps = () => {
|
|
@@ -74,12 +74,12 @@ async function waitContainerToCatchUp(container) {
|
|
|
74
74
|
const connectionOpSeqNumber = deltaManager.lastKnownSeqNumber;
|
|
75
75
|
common_utils_1.assert(deltaManager.lastSequenceNumber <= connectionOpSeqNumber, 0x266 /* "lastKnownSeqNumber should never be below last processed sequence number" */);
|
|
76
76
|
if (deltaManager.lastSequenceNumber === connectionOpSeqNumber) {
|
|
77
|
-
|
|
77
|
+
resolve(hasCheckpointSequenceNumber);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
const callbackOps = (message) => {
|
|
81
81
|
if (connectionOpSeqNumber <= message.sequenceNumber) {
|
|
82
|
-
|
|
82
|
+
resolve(hasCheckpointSequenceNumber);
|
|
83
83
|
deltaManager.off("op", callbackOps);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
@@ -229,12 +229,12 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
229
229
|
switch (event) {
|
|
230
230
|
case dirtyContainerEvent:
|
|
231
231
|
if (this._dirtyContainer) {
|
|
232
|
-
listener(
|
|
232
|
+
listener(dirtyContainerEvent);
|
|
233
233
|
}
|
|
234
234
|
break;
|
|
235
235
|
case savedContainerEvent:
|
|
236
236
|
if (!this._dirtyContainer) {
|
|
237
|
-
listener(
|
|
237
|
+
listener(savedContainerEvent);
|
|
238
238
|
}
|
|
239
239
|
break;
|
|
240
240
|
case telemetry_utils_1.connectedEventName:
|
|
@@ -428,15 +428,31 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
428
428
|
return this._deltaManager.clientDetails;
|
|
429
429
|
}
|
|
430
430
|
/**
|
|
431
|
-
*
|
|
431
|
+
* The current code details for the container's runtime
|
|
432
|
+
* @deprecated use getSpecifiedCodeDetails for the code details currently specified for this container, or
|
|
433
|
+
* getLoadedCodeDetails for the code details that the container's context was loaded with.
|
|
434
|
+
* To be removed after getSpecifiedCodeDetails and getLoadedCodeDetails become ubiquitous.
|
|
432
435
|
*/
|
|
433
|
-
get chaincodePackage() {
|
|
434
|
-
return this.codeDetails;
|
|
435
|
-
}
|
|
436
436
|
get codeDetails() {
|
|
437
437
|
var _a, _b;
|
|
438
438
|
return (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails) !== null && _b !== void 0 ? _b : this.getCodeDetailsFromQuorum();
|
|
439
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Get the code details that are currently specified for the container.
|
|
442
|
+
* @returns The current code details if any are specified, undefined if none are specified.
|
|
443
|
+
*/
|
|
444
|
+
getSpecifiedCodeDetails() {
|
|
445
|
+
return this.getCodeDetailsFromQuorum();
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Get the code details that were used to load the container.
|
|
449
|
+
* @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
|
|
450
|
+
* loaded.
|
|
451
|
+
*/
|
|
452
|
+
getLoadedCodeDetails() {
|
|
453
|
+
var _a;
|
|
454
|
+
return (_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails;
|
|
455
|
+
}
|
|
440
456
|
/**
|
|
441
457
|
* Retrieves the audience associated with the document
|
|
442
458
|
*/
|
|
@@ -517,7 +533,7 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
517
533
|
const protocolSummary = this.captureProtocolSummary();
|
|
518
534
|
const combinedSummary = driver_utils_1.combineAppAndProtocolSummary(appSummary, protocolSummary);
|
|
519
535
|
if (this.loader.services.detachedBlobStorage && this.loader.services.detachedBlobStorage.size > 0) {
|
|
520
|
-
combinedSummary.tree[".hasAttachmentBlobs"] = { type:
|
|
536
|
+
combinedSummary.tree[".hasAttachmentBlobs"] = { type: protocol_definitions_1.SummaryType.Blob, content: "true" };
|
|
521
537
|
}
|
|
522
538
|
return JSON.stringify(combinedSummary);
|
|
523
539
|
}
|
|
@@ -603,7 +619,6 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
603
619
|
newError.addTelemetryProperties({ resolvedUrl: resolvedUrl.url });
|
|
604
620
|
}
|
|
605
621
|
this.close(newError);
|
|
606
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
607
622
|
throw newError;
|
|
608
623
|
}
|
|
609
624
|
}
|
|
@@ -922,7 +937,6 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
922
937
|
}
|
|
923
938
|
async createDetached(source) {
|
|
924
939
|
const attributes = {
|
|
925
|
-
branch: "",
|
|
926
940
|
sequenceNumber: detachedContainerRefSeqNumber,
|
|
927
941
|
term: 1,
|
|
928
942
|
minimumSequenceNumber: 0,
|
|
@@ -984,7 +998,6 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
984
998
|
async getDocumentAttributes(storage, tree) {
|
|
985
999
|
if (tree === undefined) {
|
|
986
1000
|
return {
|
|
987
|
-
branch: this.id,
|
|
988
1001
|
minimumSequenceNumber: 0,
|
|
989
1002
|
sequenceNumber: 0,
|
|
990
1003
|
term: 1,
|
|
@@ -1053,7 +1066,6 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
1053
1066
|
const quorumSnapshot = this.protocolHandler.quorum.snapshot();
|
|
1054
1067
|
// Save attributes for the document
|
|
1055
1068
|
const documentAttributes = {
|
|
1056
|
-
branch: this.id,
|
|
1057
1069
|
minimumSequenceNumber: this.protocolHandler.minimumSequenceNumber,
|
|
1058
1070
|
sequenceNumber: this.protocolHandler.sequenceNumber,
|
|
1059
1071
|
term: this.protocolHandler.term,
|
|
@@ -1062,22 +1074,22 @@ class Container extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
1062
1074
|
tree: {
|
|
1063
1075
|
attributes: {
|
|
1064
1076
|
content: JSON.stringify(documentAttributes),
|
|
1065
|
-
type:
|
|
1077
|
+
type: protocol_definitions_1.SummaryType.Blob,
|
|
1066
1078
|
},
|
|
1067
1079
|
quorumMembers: {
|
|
1068
1080
|
content: JSON.stringify(quorumSnapshot.members),
|
|
1069
|
-
type:
|
|
1081
|
+
type: protocol_definitions_1.SummaryType.Blob,
|
|
1070
1082
|
},
|
|
1071
1083
|
quorumProposals: {
|
|
1072
1084
|
content: JSON.stringify(quorumSnapshot.proposals),
|
|
1073
|
-
type:
|
|
1085
|
+
type: protocol_definitions_1.SummaryType.Blob,
|
|
1074
1086
|
},
|
|
1075
1087
|
quorumValues: {
|
|
1076
1088
|
content: JSON.stringify(quorumSnapshot.values),
|
|
1077
|
-
type:
|
|
1089
|
+
type: protocol_definitions_1.SummaryType.Blob,
|
|
1078
1090
|
},
|
|
1079
1091
|
},
|
|
1080
|
-
type:
|
|
1092
|
+
type: protocol_definitions_1.SummaryType.Tree,
|
|
1081
1093
|
};
|
|
1082
1094
|
return summary;
|
|
1083
1095
|
}
|