@fluidframework/container-loader 0.59.4001 → 1.1.0-75972
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 +1 -1
- package/README.md +1 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +3 -1
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +15 -3
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +15 -3
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +47 -11
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +108 -38
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +20 -28
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +97 -153
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +6 -4
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +8 -7
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +4 -5
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +4 -7
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.js +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +9 -1
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts +0 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaManagerProxy.js +0 -3
- package/dist/deltaManagerProxy.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +8 -3
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -13
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +2 -3
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +2 -3
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +0 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +3 -4
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +4 -7
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -2
- package/dist/utils.js.map +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +4 -2
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts +15 -3
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js +15 -3
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +47 -11
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +108 -38
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +20 -28
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +98 -154
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +6 -4
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +8 -7
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +4 -5
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +4 -7
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +1 -1
- package/lib/contracts.js +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +9 -1
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts +0 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaManagerProxy.js +0 -3
- package/lib/deltaManagerProxy.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +8 -3
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +1 -13
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +2 -3
- package/lib/loader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +2 -3
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js +0 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +3 -4
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +4 -7
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +3 -2
- package/lib/utils.js.map +1 -1
- package/package.json +14 -27
- package/src/connectionManager.ts +4 -6
- package/src/connectionState.ts +20 -6
- package/src/connectionStateHandler.ts +136 -56
- package/src/container.ts +139 -185
- package/src/containerContext.ts +10 -10
- package/src/containerStorageAdapter.ts +5 -10
- package/src/contracts.ts +1 -1
- package/src/deltaManager.ts +8 -2
- package/src/deltaManagerProxy.ts +0 -4
- package/src/deltaQueue.ts +7 -3
- package/src/index.ts +1 -0
- package/src/loader.ts +4 -21
- package/src/packageVersion.ts +1 -1
- package/src/protocolTreeDocumentStorageService.ts +0 -1
- package/src/retriableDocumentStorageService.ts +4 -12
- package/src/utils.ts +3 -2
|
@@ -5,15 +5,38 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ConnectionStateHandler = void 0;
|
|
8
|
-
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
9
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
10
10
|
const connectionState_1 = require("./connectionState");
|
|
11
|
-
const
|
|
11
|
+
const JoinOpTimeoutMs = 45000;
|
|
12
|
+
/**
|
|
13
|
+
* In the lifetime of a container, the connection will likely disconnect and reconnect periodically.
|
|
14
|
+
* This class ensures that any ops sent by this container instance on previous connection are either
|
|
15
|
+
* sequenced or blocked by the server before emitting the new "connected" event and allowing runtime to resubmit ops.
|
|
16
|
+
*
|
|
17
|
+
* Each connection is assigned a clientId by the service, and the connection is book-ended by a Join and a Leave op
|
|
18
|
+
* generated by the service. Due to the distributed nature of the ordering service, in the case of reconnect we cannot
|
|
19
|
+
* make any assumptions about ordering of operations between the old and new connections - i.e. new Join op could
|
|
20
|
+
* be sequenced before old Leave op (and some acks from pending ops that were in flight when we disconnected).
|
|
21
|
+
*
|
|
22
|
+
* The job of this class is to encapsulate the transition period during reconnect, which is identified by
|
|
23
|
+
* ConnectionState.CatchingUp. Specifically, before moving to Connected state with the new clientId, it ensures that:
|
|
24
|
+
* (A) We process the Leave op for the previous clientId. This allows us to properly handle any acks from in-flight ops
|
|
25
|
+
* that got sequenced with the old clientId (we'll recognize them as local ops). After the Leave op, any other
|
|
26
|
+
* pending ops can safely be submitted with the new clientId without fear of duplication in the sequenced op stream.
|
|
27
|
+
* (B) We process the Join op for the new clientId (identified when the underlying connection was first established),
|
|
28
|
+
* indicating the service is ready to sequence ops sent with the new clientId.
|
|
29
|
+
*
|
|
30
|
+
* For (A) we give up waiting after some time (same timeout as server uses), and go ahead and transition to Connected.
|
|
31
|
+
* For (B) we log telemetry if it takes too long, but still only transition to Connected when the Join op is processed
|
|
32
|
+
* and we are added to the Quorum.
|
|
33
|
+
*/
|
|
12
34
|
class ConnectionStateHandler {
|
|
13
|
-
constructor(handler, logger) {
|
|
35
|
+
constructor(handler, logger, _clientId) {
|
|
14
36
|
var _a;
|
|
15
37
|
this.handler = handler;
|
|
16
38
|
this.logger = logger;
|
|
39
|
+
this._clientId = _clientId;
|
|
17
40
|
this._connectionState = connectionState_1.ConnectionState.Disconnected;
|
|
18
41
|
this.prevClientLeftTimer = new common_utils_1.Timer(
|
|
19
42
|
// Default is 5 min for which we are going to wait for its own "leave" message. This is same as
|
|
@@ -25,12 +48,21 @@ class ConnectionStateHandler {
|
|
|
25
48
|
// Based on recent data, it looks like majority of cases where we get stuck are due to really slow or
|
|
26
49
|
// timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so
|
|
27
50
|
// if retrying fixes the problem, we should not see these events.
|
|
28
|
-
this.joinOpTimer = new common_utils_1.Timer(
|
|
51
|
+
this.joinOpTimer = new common_utils_1.Timer(JoinOpTimeoutMs, () => {
|
|
52
|
+
var _a;
|
|
29
53
|
// I've observed timer firing within couple ms from disconnect event, looks like
|
|
30
54
|
// queued timer callback is not cancelled if timer is cancelled while callback sits in the queue.
|
|
31
|
-
if (this.connectionState
|
|
32
|
-
|
|
55
|
+
if (this.connectionState !== connectionState_1.ConnectionState.CatchingUp) {
|
|
56
|
+
return;
|
|
33
57
|
}
|
|
58
|
+
const quorumClients = this.handler.quorumClients();
|
|
59
|
+
const details = {
|
|
60
|
+
quorumInitialized: quorumClients !== undefined,
|
|
61
|
+
hasPendingClientId: this.pendingClientId !== undefined,
|
|
62
|
+
inQuorum: (quorumClients === null || quorumClients === void 0 ? void 0 : quorumClients.getMember((_a = this.pendingClientId) !== null && _a !== void 0 ? _a : "")) !== undefined,
|
|
63
|
+
waitingForLeaveOp: this.waitingForLeaveOp,
|
|
64
|
+
};
|
|
65
|
+
this.handler.logConnectionIssue("NoJoinOp", details);
|
|
34
66
|
});
|
|
35
67
|
}
|
|
36
68
|
get connectionState() {
|
|
@@ -53,6 +85,9 @@ class ConnectionStateHandler {
|
|
|
53
85
|
(0, common_utils_1.assert)(this.joinOpTimer.hasTimer, 0x235 /* "no joinOpTimer" */);
|
|
54
86
|
this.joinOpTimer.clear();
|
|
55
87
|
}
|
|
88
|
+
get waitingForLeaveOp() {
|
|
89
|
+
return this.prevClientLeftTimer.hasTimer;
|
|
90
|
+
}
|
|
56
91
|
dispose() {
|
|
57
92
|
(0, common_utils_1.assert)(!this.joinOpTimer.hasTimer, 0x2a5 /* "join timer" */);
|
|
58
93
|
this.prevClientLeftTimer.clear();
|
|
@@ -60,7 +95,7 @@ class ConnectionStateHandler {
|
|
|
60
95
|
containerSaved() {
|
|
61
96
|
// If we were waiting for moving to Connected state, then only apply for state change. Since the container
|
|
62
97
|
// is now saved and we don't have any ops to roundtrip, we can clear the timer and apply for connected state.
|
|
63
|
-
if (this.
|
|
98
|
+
if (this.waitingForLeaveOp) {
|
|
64
99
|
this.prevClientLeftTimer.clear();
|
|
65
100
|
this.applyForConnectedState("containerSaved");
|
|
66
101
|
}
|
|
@@ -77,27 +112,31 @@ class ConnectionStateHandler {
|
|
|
77
112
|
this.handler.logConnectionIssue("ReceivedJoinOp");
|
|
78
113
|
}
|
|
79
114
|
// Start the event in case we are waiting for leave or timeout.
|
|
80
|
-
if (this.
|
|
115
|
+
if (this.waitingForLeaveOp) {
|
|
81
116
|
this.waitEvent = telemetry_utils_1.PerformanceEvent.start(this.logger, {
|
|
82
117
|
eventName: "WaitBeforeClientLeave",
|
|
83
|
-
|
|
84
|
-
|
|
118
|
+
details: JSON.stringify({
|
|
119
|
+
waitOnClientId: this._clientId,
|
|
120
|
+
hadOutstandingOps: this.handler.shouldClientJoinWrite(),
|
|
121
|
+
}),
|
|
85
122
|
});
|
|
86
123
|
}
|
|
87
124
|
this.applyForConnectedState("addMemberEvent");
|
|
88
125
|
}
|
|
89
126
|
}
|
|
90
127
|
applyForConnectedState(source) {
|
|
91
|
-
var _a;
|
|
128
|
+
var _a, _b;
|
|
92
129
|
const quorumClients = this.handler.quorumClients();
|
|
93
130
|
(0, common_utils_1.assert)(quorumClients !== undefined, 0x236 /* "In all cases it should be already installed" */);
|
|
131
|
+
(0, common_utils_1.assert)(this.waitingForLeaveOp === false ||
|
|
132
|
+
(this.clientId !== undefined && quorumClients.getMember(this.clientId) !== undefined), 0x2e2 /* "Must only wait for leave message when clientId in quorum" */);
|
|
94
133
|
// Move to connected state only if we are in Connecting state, we have seen our join op
|
|
95
134
|
// and there is no timer running which means we are not waiting for previous client to leave
|
|
96
|
-
// or timeout has
|
|
135
|
+
// or timeout has occurred while doing so.
|
|
97
136
|
if (this.pendingClientId !== this.clientId
|
|
98
137
|
&& this.pendingClientId !== undefined
|
|
99
138
|
&& quorumClients.getMember(this.pendingClientId) !== undefined
|
|
100
|
-
&& !this.
|
|
139
|
+
&& !this.waitingForLeaveOp) {
|
|
101
140
|
(_a = this.waitEvent) === null || _a === void 0 ? void 0 : _a.end({ source });
|
|
102
141
|
this.setConnectionState(connectionState_1.ConnectionState.Connected);
|
|
103
142
|
}
|
|
@@ -106,12 +145,13 @@ class ConnectionStateHandler {
|
|
|
106
145
|
this.logger.sendTelemetryEvent({
|
|
107
146
|
eventName: "connectedStateRejected",
|
|
108
147
|
category: source === "timeout" ? "error" : "generic",
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
148
|
+
details: JSON.stringify({
|
|
149
|
+
source,
|
|
150
|
+
pendingClientId: this.pendingClientId,
|
|
151
|
+
clientId: this.clientId,
|
|
152
|
+
waitingForLeaveOp: this.waitingForLeaveOp,
|
|
153
|
+
inQuorum: (quorumClients === null || quorumClients === void 0 ? void 0 : quorumClients.getMember((_b = this.pendingClientId) !== null && _b !== void 0 ? _b : "")) !== undefined,
|
|
154
|
+
}),
|
|
115
155
|
});
|
|
116
156
|
}
|
|
117
157
|
}
|
|
@@ -128,32 +168,48 @@ class ConnectionStateHandler {
|
|
|
128
168
|
}
|
|
129
169
|
this.setConnectionState(connectionState_1.ConnectionState.Disconnected, reason);
|
|
130
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* The "connect" event indicates the connection to the Relay Service is live.
|
|
173
|
+
* However, some additional conditions must be met before we can fully transition to
|
|
174
|
+
* "Connected" state. This function handles that interim period, known as "Connecting" state.
|
|
175
|
+
* @param connectionMode - Read or Write connection
|
|
176
|
+
* @param details - Connection details returned from the ordering service
|
|
177
|
+
*/
|
|
131
178
|
receivedConnectEvent(connectionMode, details) {
|
|
132
179
|
const oldState = this._connectionState;
|
|
133
|
-
this._connectionState = connectionState_1.ConnectionState.
|
|
180
|
+
this._connectionState = connectionState_1.ConnectionState.CatchingUp;
|
|
181
|
+
const writeConnection = connectionMode === "write";
|
|
182
|
+
(0, common_utils_1.assert)(writeConnection || !this.handler.shouldClientJoinWrite(), 0x30a /* shouldClientJoinWrite should imply this is a writeConnection */);
|
|
183
|
+
(0, common_utils_1.assert)(writeConnection || !this.waitingForLeaveOp, 0x2a6 /* "waitingForLeaveOp should imply writeConnection (we need to be ready to flush pending ops)" */);
|
|
184
|
+
// Note that this may be undefined since the connection is established proactively on load
|
|
185
|
+
// and the quorum may still be under initialization.
|
|
186
|
+
const quorumClients = this.handler.quorumClients();
|
|
134
187
|
// Stash the clientID to detect when transitioning from connecting (socket.io channel open) to connected
|
|
135
188
|
// (have received the join message for the client ID)
|
|
136
189
|
// This is especially important in the reconnect case. It's possible there could be outstanding
|
|
137
190
|
// ops sent by this client, so we should keep the old client id until we see our own client's
|
|
138
|
-
// join message. after we see the join message for
|
|
191
|
+
// join message. after we see the join message for our new connection with our new client id,
|
|
139
192
|
// we know there can no longer be outstanding ops that we sent with the previous client id.
|
|
140
193
|
this._pendingClientId = details.clientId;
|
|
141
|
-
// Report telemetry after we set
|
|
142
|
-
this.handler.logConnectionStateChangeTelemetry(connectionState_1.ConnectionState.
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
// Given async processes, it's possible that we have already processed our own join message before
|
|
194
|
+
// IMPORTANT: Report telemetry after we set _pendingClientId, but before transitioning to Connected state
|
|
195
|
+
this.handler.logConnectionStateChangeTelemetry(connectionState_1.ConnectionState.CatchingUp, oldState);
|
|
196
|
+
// For write connections, this pending clientId could be in the quorum already (i.e. join op already processed).
|
|
197
|
+
// We are fetching ops from storage in parallel to connecting to Relay Service,
|
|
198
|
+
// and given async processes, it's possible that we have already processed our own join message before
|
|
147
199
|
// connection was fully established.
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
else if (connectionMode === "write") {
|
|
200
|
+
// If quorumClients itself is undefined, we expect it will process the join op after it's initialized.
|
|
201
|
+
const waitingForJoinOp = writeConnection && (quorumClients === null || quorumClients === void 0 ? void 0 : quorumClients.getMember(this._pendingClientId)) === undefined;
|
|
202
|
+
if (waitingForJoinOp) {
|
|
203
|
+
// Previous client left, and we are waiting for our own join op. When it is processed we'll join the quorum
|
|
204
|
+
// and attempt to transition to Connected state via receivedAddMemberEvent.
|
|
155
205
|
this.startJoinOpTimer();
|
|
156
206
|
}
|
|
207
|
+
else if (!this.waitingForLeaveOp) {
|
|
208
|
+
// We're not waiting for Join or Leave op (if read-only connection those don't even apply),
|
|
209
|
+
// go ahead and declare the state to be Connected!
|
|
210
|
+
// If we are waiting for Leave op still, do nothing for now, we will transition to Connected later.
|
|
211
|
+
this.setConnectionState(connectionState_1.ConnectionState.Connected);
|
|
212
|
+
}
|
|
157
213
|
}
|
|
158
214
|
setConnectionState(value, reason) {
|
|
159
215
|
if (this.connectionState === value) {
|
|
@@ -169,7 +225,7 @@ class ConnectionStateHandler {
|
|
|
169
225
|
client = quorumClients === null || quorumClients === void 0 ? void 0 : quorumClients.getMember(this._clientId);
|
|
170
226
|
}
|
|
171
227
|
if (value === connectionState_1.ConnectionState.Connected) {
|
|
172
|
-
(0, common_utils_1.assert)(oldState === connectionState_1.ConnectionState.
|
|
228
|
+
(0, common_utils_1.assert)(oldState === connectionState_1.ConnectionState.CatchingUp, 0x1d8 /* "Should only transition from Connecting state" */);
|
|
173
229
|
// Mark our old client should have left in the quorum if it's still there
|
|
174
230
|
if (client !== undefined) {
|
|
175
231
|
client.shouldHaveLeft = true;
|
|
@@ -194,9 +250,11 @@ class ConnectionStateHandler {
|
|
|
194
250
|
// Adding this event temporarily so that we can get help debugging if something goes wrong.
|
|
195
251
|
this.logger.sendTelemetryEvent({
|
|
196
252
|
eventName: "noWaitOnDisconnected",
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
253
|
+
details: JSON.stringify({
|
|
254
|
+
inQuorum: client !== undefined,
|
|
255
|
+
waitingForLeaveOp: this.waitingForLeaveOp,
|
|
256
|
+
hadOutstandingOps: this.handler.shouldClientJoinWrite(),
|
|
257
|
+
}),
|
|
200
258
|
});
|
|
201
259
|
}
|
|
202
260
|
}
|
|
@@ -205,6 +263,18 @@ class ConnectionStateHandler {
|
|
|
205
263
|
// Propagate event across layers
|
|
206
264
|
this.handler.connectionStateChanged();
|
|
207
265
|
}
|
|
266
|
+
initProtocol(protocol) {
|
|
267
|
+
protocol.quorum.on("addMember", (clientId, _details) => {
|
|
268
|
+
this.receivedAddMemberEvent(clientId);
|
|
269
|
+
});
|
|
270
|
+
protocol.quorum.on("removeMember", (clientId) => {
|
|
271
|
+
this.receivedRemoveMemberEvent(clientId);
|
|
272
|
+
});
|
|
273
|
+
// if we have a clientId from a previous container we need to wait for its leave message
|
|
274
|
+
if (this.clientId !== undefined && protocol.quorum.getMember(this.clientId) !== undefined) {
|
|
275
|
+
this.prevClientLeftTimer.restart();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
208
278
|
}
|
|
209
279
|
exports.ConnectionStateHandler = ConnectionStateHandler;
|
|
210
280
|
//# sourceMappingURL=connectionStateHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionStateHandler.js","sourceRoot":"","sources":["../src/conn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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;AAzOD,wDAyOC","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 { ConnectionMode, IQuorumClients, ISequencedClient } from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert, Timer } from \"@fluidframework/common-utils\";\nimport { ConnectionState } from \"./connectionState\";\n\nexport interface IConnectionStateHandler {\n quorumClients: () => IQuorumClients | undefined;\n logConnectionStateChangeTelemetry: (\n value: ConnectionState,\n oldState: ConnectionState,\n reason?: string | undefined\n ) => 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 5 min for which we are going to wait for its own \"leave\" message. This is same as\n // the max time on server after which leave op is sent.\n this.handler.maxClientLeaveWaitTime ?? 300000,\n () => {\n assert(!this.connected,\n 0x2ac /* \"Connected when timeout waiting for leave from previous session fired!\" */);\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 dispose() {\n assert(!this.joinOpTimer.hasTimer, 0x2a5 /* \"join timer\" */);\n this.prevClientLeftTimer.clear();\n }\n\n public containerSaved() {\n // If we were waiting for moving to Connected state, then only apply for state change. Since the container\n // is now saved and we don't have any ops to roundtrip, we can clear the timer and apply for connected state.\n if (this.prevClientLeftTimer.hasTimer) {\n this.prevClientLeftTimer.clear();\n this.applyForConnectedState(\"containerSaved\");\n }\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\" | \"containerSaved\") {\n const quorumClients = this.handler.quorumClients();\n assert(quorumClients !== 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 && quorumClients.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: quorumClients !== undefined && this.pendingClientId !== undefined\n && quorumClients.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 quorumClients = this.handler.quorumClients();\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 (quorumClients?.getMember(details.clientId) !== undefined\n || connectionMode === \"read\"\n ) {\n assert(!this.prevClientLeftTimer.hasTimer, 0x2a6 /* \"there should be no timer for 'read' connections\" */);\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 quorumClients = this.handler.quorumClients();\n let client: ILocalSequencedClient | undefined;\n if (this._clientId !== undefined) {\n client = quorumClients?.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"]}
|
|
1
|
+
{"version":3,"file":"connectionStateHandler.js","sourceRoot":"","sources":["../src/connectionStateHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA6D;AAI7D,qEAAmE;AACnE,uDAAoD;AAmBpD,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,sBAAsB;IAwB/B,YACqB,OAAsC,EACtC,MAAwB,EACjC,SAAkB;;QAFT,YAAO,GAAP,OAAO,CAA+B;QACtC,WAAM,GAAN,MAAM,CAAkB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,IAAI,CAAC,iBAAiB;wBACzC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;qBAC1D,CAAC;iBACL,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;IAEM,YAAY,CAAC,QAA0B;QAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACnD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC5C,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,wFAAwF;QACxF,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;YACvF,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;SACtC;IACL,CAAC;CACJ;AAlSD,wDAkSC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert, Timer } from \"@fluidframework/common-utils\";\nimport { IConnectionDetails } from \"@fluidframework/container-definitions\";\nimport { ILocalSequencedClient, IProtocolHandler } from \"@fluidframework/protocol-base\";\nimport { ConnectionMode, IQuorumClients } from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ConnectionState } from \"./connectionState\";\n\n/** Constructor parameter type for passing in dependencies needed by the ConnectionStateHandler */\nexport interface IConnectionStateHandlerInputs {\n /** Provides access to the clients currently in the quorum */\n quorumClients: () => IQuorumClients | undefined;\n /** Log to telemetry any change in state, included to Connecting */\n logConnectionStateChangeTelemetry:\n (value: ConnectionState, oldState: ConnectionState, reason?: string | undefined) => void;\n /** Whether to expect the client to join in write mode on next connection */\n shouldClientJoinWrite: () => boolean;\n /** (Optional) How long should we wait on our previous client's Leave op before transitioning to Connected again */\n maxClientLeaveWaitTime: number | undefined;\n /** Log an issue encountered while in the Connecting state. details will be logged as a JSON string */\n logConnectionIssue: (eventName: string, details?: ITelemetryProperties) => void;\n /** Callback whenever the ConnectionState changes between Disconnected and Connected */\n connectionStateChanged: () => void;\n}\n\nconst JoinOpTimeoutMs = 45000;\n\n/**\n * In the lifetime of a container, the connection will likely disconnect and reconnect periodically.\n * This class ensures that any ops sent by this container instance on previous connection are either\n * sequenced or blocked by the server before emitting the new \"connected\" event and allowing runtime to resubmit ops.\n *\n * Each connection is assigned a clientId by the service, and the connection is book-ended by a Join and a Leave op\n * generated by the service. Due to the distributed nature of the ordering service, in the case of reconnect we cannot\n * make any assumptions about ordering of operations between the old and new connections - i.e. new Join op could\n * be sequenced before old Leave op (and some acks from pending ops that were in flight when we disconnected).\n *\n * The job of this class is to encapsulate the transition period during reconnect, which is identified by\n * ConnectionState.CatchingUp. Specifically, before moving to Connected state with the new clientId, it ensures that:\n * (A) We process the Leave op for the previous clientId. This allows us to properly handle any acks from in-flight ops\n * that got sequenced with the old clientId (we'll recognize them as local ops). After the Leave op, any other\n * pending ops can safely be submitted with the new clientId without fear of duplication in the sequenced op stream.\n * (B) We process the Join op for the new clientId (identified when the underlying connection was first established),\n * indicating the service is ready to sequence ops sent with the new clientId.\n *\n * For (A) we give up waiting after some time (same timeout as server uses), and go ahead and transition to Connected.\n * For (B) we log telemetry if it takes too long, but still only transition to Connected when the Join op is processed\n * and we are added to the Quorum.\n */\nexport class ConnectionStateHandler {\n private _connectionState = ConnectionState.Disconnected;\n private _pendingClientId: 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: IConnectionStateHandlerInputs,\n private readonly logger: ITelemetryLogger,\n private _clientId?: string,\n ) {\n this.prevClientLeftTimer = new Timer(\n // Default is 5 min for which we are going to wait for its own \"leave\" message. This is same as\n // the max time on server after which leave op is sent.\n this.handler.maxClientLeaveWaitTime ?? 300000,\n () => {\n assert(!this.connected,\n 0x2ac /* \"Connected when timeout waiting for leave from previous session fired!\" */);\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 JoinOpTimeoutMs,\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.CatchingUp) {\n return;\n }\n const quorumClients = this.handler.quorumClients();\n const details = {\n quorumInitialized: quorumClients !== undefined,\n hasPendingClientId: this.pendingClientId !== undefined,\n inQuorum: quorumClients?.getMember(this.pendingClientId ?? \"\") !== undefined,\n waitingForLeaveOp: this.waitingForLeaveOp,\n };\n this.handler.logConnectionIssue(\"NoJoinOp\", details);\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 private get waitingForLeaveOp() {\n return this.prevClientLeftTimer.hasTimer;\n }\n\n public dispose() {\n assert(!this.joinOpTimer.hasTimer, 0x2a5 /* \"join timer\" */);\n this.prevClientLeftTimer.clear();\n }\n\n public containerSaved() {\n // If we were waiting for moving to Connected state, then only apply for state change. Since the container\n // is now saved and we don't have any ops to roundtrip, we can clear the timer and apply for connected state.\n if (this.waitingForLeaveOp) {\n this.prevClientLeftTimer.clear();\n this.applyForConnectedState(\"containerSaved\");\n }\n }\n\n private 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.waitingForLeaveOp) {\n this.waitEvent = PerformanceEvent.start(this.logger, {\n eventName: \"WaitBeforeClientLeave\",\n details: JSON.stringify({\n waitOnClientId: this._clientId,\n hadOutstandingOps: this.handler.shouldClientJoinWrite(),\n }),\n });\n }\n this.applyForConnectedState(\"addMemberEvent\");\n }\n }\n\n private applyForConnectedState(source: \"removeMemberEvent\" | \"addMemberEvent\" | \"timeout\" | \"containerSaved\") {\n const quorumClients = this.handler.quorumClients();\n assert(quorumClients !== undefined, 0x236 /* \"In all cases it should be already installed\" */);\n\n assert(this.waitingForLeaveOp === false ||\n (this.clientId !== undefined && quorumClients.getMember(this.clientId) !== undefined),\n 0x2e2 /* \"Must only wait for leave message when clientId in quorum\" */);\n\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 occurred while doing so.\n if (this.pendingClientId !== this.clientId\n && this.pendingClientId !== undefined\n && quorumClients.getMember(this.pendingClientId) !== undefined\n && !this.waitingForLeaveOp\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 details: JSON.stringify({\n source,\n pendingClientId: this.pendingClientId,\n clientId: this.clientId,\n waitingForLeaveOp: this.waitingForLeaveOp,\n inQuorum: quorumClients?.getMember(this.pendingClientId ?? \"\") !== undefined,\n }),\n });\n }\n }\n\n private 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 /**\n * The \"connect\" event indicates the connection to the Relay Service is live.\n * However, some additional conditions must be met before we can fully transition to\n * \"Connected\" state. This function handles that interim period, known as \"Connecting\" state.\n * @param connectionMode - Read or Write connection\n * @param details - Connection details returned from the ordering service\n */\n public receivedConnectEvent(\n connectionMode: ConnectionMode,\n details: IConnectionDetails,\n ) {\n const oldState = this._connectionState;\n this._connectionState = ConnectionState.CatchingUp;\n\n const writeConnection = connectionMode === \"write\";\n assert(writeConnection || !this.handler.shouldClientJoinWrite(),\n 0x30a /* shouldClientJoinWrite should imply this is a writeConnection */);\n assert(writeConnection || !this.waitingForLeaveOp,\n 0x2a6 /* \"waitingForLeaveOp should imply writeConnection (we need to be ready to flush pending ops)\" */);\n\n // Note that this may be undefined since the connection is established proactively on load\n // and the quorum may still be under initialization.\n const quorumClients: IQuorumClients | undefined = this.handler.quorumClients();\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 our 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 // IMPORTANT: Report telemetry after we set _pendingClientId, but before transitioning to Connected state\n this.handler.logConnectionStateChangeTelemetry(ConnectionState.CatchingUp, oldState);\n\n // For write connections, this pending clientId could be in the quorum already (i.e. join op already processed).\n // We are fetching ops from storage in parallel to connecting to Relay Service,\n // and given async processes, it's possible that we have already processed our own join message before\n // connection was fully established.\n // If quorumClients itself is undefined, we expect it will process the join op after it's initialized.\n const waitingForJoinOp = writeConnection && quorumClients?.getMember(this._pendingClientId) === undefined;\n\n if (waitingForJoinOp) {\n // Previous client left, and we are waiting for our own join op. When it is processed we'll join the quorum\n // and attempt to transition to Connected state via receivedAddMemberEvent.\n this.startJoinOpTimer();\n } else if (!this.waitingForLeaveOp) {\n // We're not waiting for Join or Leave op (if read-only connection those don't even apply),\n // go ahead and declare the state to be Connected!\n // If we are waiting for Leave op still, do nothing for now, we will transition to Connected later.\n this.setConnectionState(ConnectionState.Connected);\n }\n }\n\n private setConnectionState(value: ConnectionState.Disconnected, reason: string): void;\n private setConnectionState(value: ConnectionState.Connected): void;\n private setConnectionState(value: ConnectionState, reason?: string): void {\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 quorumClients = this.handler.quorumClients();\n let client: ILocalSequencedClient | undefined;\n if (this._clientId !== undefined) {\n client = quorumClients?.getMember(this._clientId);\n }\n if (value === ConnectionState.Connected) {\n assert(oldState === ConnectionState.CatchingUp,\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 details: JSON.stringify({\n inQuorum: client !== undefined,\n waitingForLeaveOp: this.waitingForLeaveOp,\n hadOutstandingOps: this.handler.shouldClientJoinWrite(),\n }),\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 public initProtocol(protocol: IProtocolHandler) {\n protocol.quorum.on(\"addMember\", (clientId, _details) => {\n this.receivedAddMemberEvent(clientId);\n });\n\n protocol.quorum.on(\"removeMember\", (clientId) => {\n this.receivedRemoveMemberEvent(clientId);\n });\n\n // if we have a clientId from a previous container we need to wait for its leave message\n if (this.clientId !== undefined && protocol.quorum.getMember(this.clientId) !== undefined) {\n this.prevClientLeftTimer.restart();\n }\n }\n}\n"]}
|
package/dist/container.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { IRequest, IResponse, IFluidRouter } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IAudience, IContainer, IContainerEvents, IDeltaManager, ICriticalContainerError, AttachState, ReadOnlyInfo, IContainerLoadMode, IFluidCodeDetails } from "@fluidframework/container-definitions";
|
|
7
7
|
import { IDocumentStorageService, IFluidResolvedUrl, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
8
|
-
import { IClientConfiguration, IClientDetails, IDocumentMessage, IQuorumClients, ISequencedDocumentMessage, IVersion } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { IClientConfiguration, IClientDetails, IDocumentMessage, IProtocolState, IQuorumClients, ISequencedDocumentMessage, IVersion } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { EventEmitterWithErrorHandling, TelemetryLogger } from "@fluidframework/telemetry-utils";
|
|
10
10
|
import { ILoaderOptions, Loader } from "./loader";
|
|
11
11
|
import { ConnectionState } from "./connectionState";
|
|
@@ -35,26 +35,41 @@ export interface IContainerConfig {
|
|
|
35
35
|
* Client details provided in the override will be merged over the default client.
|
|
36
36
|
*/
|
|
37
37
|
clientDetailsOverride?: IClientDetails;
|
|
38
|
+
/**
|
|
39
|
+
* Serialized state from a previous instance of this container
|
|
40
|
+
*/
|
|
41
|
+
serializedContainerState?: IPendingContainerState;
|
|
38
42
|
}
|
|
39
43
|
/**
|
|
40
44
|
* Waits until container connects to delta storage and gets up-to-date
|
|
41
45
|
* Useful when resolving URIs and hitting 404, due to container being loaded from (stale) snapshot and not being
|
|
42
46
|
* up to date. Host may chose to wait in such case and retry resolving URI.
|
|
43
47
|
* Warning: Will wait infinitely for connection to establish if there is no connection.
|
|
44
|
-
* May result in deadlock if Container.
|
|
48
|
+
* May result in deadlock if Container.disconnect() is called and never followed by a call to Container.connect().
|
|
45
49
|
* @returns true: container is up to date, it processed all the ops that were know at the time of first connection
|
|
46
50
|
* false: storage does not provide indication of how far the client is. Container processed
|
|
47
51
|
* all the ops known to it, but it maybe still behind.
|
|
48
52
|
* @throws an error beginning with `"Container closed"` if the container is closed before it catches up.
|
|
49
53
|
*/
|
|
50
54
|
export declare function waitContainerToCatchUp(container: IContainer): Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* State saved by a container at close time, to be used to load a new instance
|
|
57
|
+
* of the container to the same state
|
|
58
|
+
*/
|
|
59
|
+
export interface IPendingContainerState {
|
|
60
|
+
pendingRuntimeState: unknown;
|
|
61
|
+
url: string;
|
|
62
|
+
protocol: IProtocolState;
|
|
63
|
+
term: number;
|
|
64
|
+
clientId?: string;
|
|
65
|
+
}
|
|
51
66
|
export declare class Container extends EventEmitterWithErrorHandling<IContainerEvents> implements IContainer {
|
|
52
67
|
private readonly loader;
|
|
53
68
|
static version: string;
|
|
54
69
|
/**
|
|
55
70
|
* Load an existing container.
|
|
56
71
|
*/
|
|
57
|
-
static load(loader: Loader, loadOptions: IContainerLoadOptions, pendingLocalState?:
|
|
72
|
+
static load(loader: Loader, loadOptions: IContainerLoadOptions, pendingLocalState?: IPendingContainerState): Promise<Container>;
|
|
58
73
|
/**
|
|
59
74
|
* Create a new container in a detached state.
|
|
60
75
|
*/
|
|
@@ -68,8 +83,7 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
68
83
|
private readonly _canReconnect;
|
|
69
84
|
private readonly mc;
|
|
70
85
|
private _lifecycleState;
|
|
71
|
-
private
|
|
72
|
-
private set loaded(value);
|
|
86
|
+
private setLoaded;
|
|
73
87
|
get closed(): boolean;
|
|
74
88
|
private _attachState;
|
|
75
89
|
private readonly _storage;
|
|
@@ -158,32 +172,17 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
158
172
|
*/
|
|
159
173
|
getQuorum(): IQuorumClients;
|
|
160
174
|
close(error?: ICriticalContainerError): void;
|
|
175
|
+
private closeCore;
|
|
161
176
|
closeAndGetPendingLocalState(): string;
|
|
162
177
|
get attachState(): AttachState;
|
|
163
178
|
serialize(): string;
|
|
164
179
|
attach(request: IRequest): Promise<void>;
|
|
165
180
|
request(path: IRequest): Promise<IResponse>;
|
|
166
|
-
/**
|
|
167
|
-
* Dictates whether or not the current container will automatically attempt to reconnect to the delta stream
|
|
168
|
-
* after receiving a disconnect event
|
|
169
|
-
* @param reconnect - Boolean indicating if reconnect should automatically occur
|
|
170
|
-
* @deprecated - 0.58, This API will be removed in 1.0
|
|
171
|
-
* Use `connect()` and `disconnect()` instead of `setAutoReconnect(true)` and `setAutoReconnect(false)` respectively
|
|
172
|
-
* See https://github.com/microsoft/FluidFramework/issues/9167 for context
|
|
173
|
-
*/
|
|
174
|
-
setAutoReconnect(reconnect: boolean): void;
|
|
175
181
|
private setAutoReconnectInternal;
|
|
176
182
|
connect(): void;
|
|
177
183
|
private connectInternal;
|
|
178
184
|
disconnect(): void;
|
|
179
185
|
private disconnectInternal;
|
|
180
|
-
/**
|
|
181
|
-
* Have the container attempt to resume processing ops
|
|
182
|
-
* @deprecated - 0.58, This API will be removed in 1.0
|
|
183
|
-
* Use `connect()` instead
|
|
184
|
-
* See https://github.com/microsoft/FluidFramework/issues/9167 for context
|
|
185
|
-
*/
|
|
186
|
-
resume(): void;
|
|
187
186
|
private resumeInternal;
|
|
188
187
|
getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
|
|
189
188
|
proposeCodeDetails(codeDetails: IFluidCodeDetails): Promise<boolean>;
|
|
@@ -222,13 +221,6 @@ export declare class Container extends EventEmitterWithErrorHandling<IContainerE
|
|
|
222
221
|
private submitContainerMessage;
|
|
223
222
|
private submitMessage;
|
|
224
223
|
private processRemoteMessage;
|
|
225
|
-
/**
|
|
226
|
-
* #260 (ADO)
|
|
227
|
-
* back-compat: noopTimeFrequency & noopCountFrequency properties were added to
|
|
228
|
-
* IClientConfiguration in 0.59.3000. During the integration, we must read the
|
|
229
|
-
* available configuration from the loader options.
|
|
230
|
-
*/
|
|
231
|
-
private getNoopConfig;
|
|
232
224
|
private submitSignal;
|
|
233
225
|
private processSignal;
|
|
234
226
|
/**
|
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;AASH,OAAO,EACH,QAAQ,EACR,SAAS,EACT,YAAY,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EAET,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EAEvB,WAAW,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container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