@fluidframework/container-loader 2.62.0 → 2.63.0-359286
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/api-report/container-loader.legacy.alpha.api.md +1 -9
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +64 -49
- package/dist/connectionManager.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +3 -5
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +10 -22
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +3 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/contracts.d.ts +5 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createAndLoadContainerUtils.d.ts +1 -33
- package/dist/createAndLoadContainerUtils.d.ts.map +1 -1
- package/dist/createAndLoadContainerUtils.js +1 -1
- package/dist/createAndLoadContainerUtils.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +56 -55
- package/dist/deltaManager.js.map +1 -1
- package/dist/frozenServices.d.ts +2 -0
- package/dist/frozenServices.d.ts.map +1 -1
- package/dist/frozenServices.js +20 -12
- package/dist/frozenServices.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/protocol.d.ts +51 -8
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +11 -12
- package/dist/protocol.js.map +1 -1
- package/dist/serializedStateManager.d.ts +4 -3
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +63 -23
- package/dist/serializedStateManager.js.map +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +18 -3
- package/lib/connectionManager.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +3 -5
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +10 -22
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +3 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/contracts.d.ts +5 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createAndLoadContainerUtils.d.ts +1 -33
- package/lib/createAndLoadContainerUtils.d.ts.map +1 -1
- package/lib/createAndLoadContainerUtils.js +1 -1
- package/lib/createAndLoadContainerUtils.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +2 -1
- package/lib/deltaManager.js.map +1 -1
- package/lib/frozenServices.d.ts +2 -0
- package/lib/frozenServices.d.ts.map +1 -1
- package/lib/frozenServices.js +20 -12
- package/lib/frozenServices.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/protocol.d.ts +51 -8
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +5 -6
- package/lib/protocol.js.map +1 -1
- package/lib/serializedStateManager.d.ts +4 -3
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +63 -23
- package/lib/serializedStateManager.js.map +1 -1
- package/package.json +12 -12
- package/src/connectionManager.ts +31 -14
- package/src/container.ts +9 -13
- package/src/containerContext.ts +34 -34
- package/src/contracts.ts +4 -1
- package/src/createAndLoadContainerUtils.ts +3 -42
- package/src/deltaManager.ts +12 -5
- package/src/frozenServices.ts +24 -12
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +67 -10
- package/src/serializedStateManager.ts +60 -29
|
@@ -101,16 +101,8 @@ export interface ILoadExistingContainerProps extends ICreateAndLoadContainerProp
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// @alpha @legacy
|
|
104
|
-
export interface ILoadFrozenContainerFromPendingStateProps {
|
|
105
|
-
readonly clientDetailsOverride?: IClientDetails | undefined;
|
|
106
|
-
readonly codeLoader: ICodeDetailsLoader_2;
|
|
107
|
-
readonly configProvider?: IConfigProviderBase | undefined;
|
|
108
|
-
readonly logger?: ITelemetryBaseLogger | undefined;
|
|
109
|
-
readonly options?: IContainerPolicies | undefined;
|
|
104
|
+
export interface ILoadFrozenContainerFromPendingStateProps extends ILoadExistingContainerProps {
|
|
110
105
|
readonly pendingLocalState: string;
|
|
111
|
-
readonly request: IRequest;
|
|
112
|
-
readonly scope?: FluidObject | undefined;
|
|
113
|
-
readonly urlResolver: IUrlResolver;
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
// @beta @legacy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,KAAK,wBAAwB,EAAY,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,KAAK,wBAAwB,EAAY,MAAM,iCAAiC,CAAC;AAI1F,OAAO,KAAK,EACX,cAAc,EACd,OAAO,EACP,cAAc,EACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEN,KAAK,gBAAgB,EAGrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAOrB,KAAK,yBAAyB,EAE9B,MAAM,6CAA6C,CAAC;AAYrD,OAAO,EACN,KAAK,mBAAmB,EAOxB,MAAM,0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C,uBAAuB;IAWxB,OAAO,CAAC,MAAM,EAAE,4BAA4B,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI;YAO7E,WAAW;IA8PzB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAyCjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IA0JpC;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;;;;OAMG;YACW,SAAS;IA8DhB,oBAAoB,CAC1B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,GACrD,gBAAgB,GAAG,SAAS;IAuCxB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ5D,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IA+BhD,0BAA0B,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAgD3E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAMxB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAI5B;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAkB1B;IAGF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAIxC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAE3B;CACF"}
|
|
@@ -7,10 +7,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.ConnectionManager = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const core_interfaces_1 = require("@fluidframework/core-interfaces");
|
|
10
|
-
const internal_1 = require("@fluidframework/core-
|
|
11
|
-
const internal_2 = require("@fluidframework/
|
|
12
|
-
const internal_3 = require("@fluidframework/driver-
|
|
13
|
-
const internal_4 = require("@fluidframework/
|
|
10
|
+
const internal_1 = require("@fluidframework/core-interfaces/internal");
|
|
11
|
+
const internal_2 = require("@fluidframework/core-utils/internal");
|
|
12
|
+
const internal_3 = require("@fluidframework/driver-definitions/internal");
|
|
13
|
+
const internal_4 = require("@fluidframework/driver-utils/internal");
|
|
14
|
+
const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
14
15
|
const contracts_js_1 = require("./contracts.js");
|
|
15
16
|
const deltaQueue_js_1 = require("./deltaQueue.js");
|
|
16
17
|
const frozenServices_js_1 = require("./frozenServices.js");
|
|
@@ -24,7 +25,7 @@ function getNackReconnectInfo(nackContent) {
|
|
|
24
25
|
const message = `Nack (${nackContent.type}): ${nackContent.message}`;
|
|
25
26
|
const canRetry = nackContent.code !== 403;
|
|
26
27
|
const retryAfterMs = nackContent.retryAfter === undefined ? undefined : nackContent.retryAfter * 1000;
|
|
27
|
-
return (0,
|
|
28
|
+
return (0, internal_4.createGenericNetworkError)(message, { canRetry, retryAfterMs }, { statusCode: nackContent.code, driverVersion: undefined });
|
|
28
29
|
}
|
|
29
30
|
const waitForOnline = async () => {
|
|
30
31
|
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
@@ -38,6 +39,16 @@ const waitForOnline = async () => {
|
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
};
|
|
42
|
+
function assertExpectedSignals(signals) {
|
|
43
|
+
for (const signal of signals) {
|
|
44
|
+
if ("type" in signal) {
|
|
45
|
+
throw new Error("Unexpected type in ISignalMessage");
|
|
46
|
+
}
|
|
47
|
+
if (typeof signal.content !== "string") {
|
|
48
|
+
throw new TypeError("Non-string content in ISignalMessage");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
41
52
|
/**
|
|
42
53
|
* Implementation of IConnectionManager, used by Container class
|
|
43
54
|
* Implements constant connectivity to relay service, by reconnecting in case of lost connection or error.
|
|
@@ -194,13 +205,14 @@ class ConnectionManager {
|
|
|
194
205
|
};
|
|
195
206
|
this.signalHandler = (signalsArg) => {
|
|
196
207
|
const signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];
|
|
208
|
+
assertExpectedSignals(signals);
|
|
197
209
|
this.props.signalHandler(signals);
|
|
198
210
|
};
|
|
199
211
|
// Always connect in write mode after getting nacked.
|
|
200
212
|
this.nackHandler = (documentId, messages) => {
|
|
201
213
|
const message = messages[0];
|
|
202
214
|
if (this._readonlyPermissions === true) {
|
|
203
|
-
this.props.closeHandler((0,
|
|
215
|
+
this.props.closeHandler((0, internal_4.createWriteError)("writeOnReadOnlyDocument", { driverVersion: undefined }));
|
|
204
216
|
return;
|
|
205
217
|
}
|
|
206
218
|
const reconnectInfo = getNackReconnectInfo(message.content);
|
|
@@ -232,7 +244,7 @@ class ConnectionManager {
|
|
|
232
244
|
this.connection.submit(messages);
|
|
233
245
|
});
|
|
234
246
|
this._outbound.on("error", (error) => {
|
|
235
|
-
this.props.closeHandler((0,
|
|
247
|
+
this.props.closeHandler((0, internal_5.normalizeError)(error));
|
|
236
248
|
});
|
|
237
249
|
}
|
|
238
250
|
dispose(error, switchToReadonly = true) {
|
|
@@ -262,7 +274,7 @@ class ConnectionManager {
|
|
|
262
274
|
* Will throw an error if reconnectMode set to Never.
|
|
263
275
|
*/
|
|
264
276
|
setAutoReconnect(mode, reason) {
|
|
265
|
-
(0,
|
|
277
|
+
(0, internal_2.assert)(mode !== contracts_js_1.ReconnectMode.Never && this._reconnectMode !== contracts_js_1.ReconnectMode.Never, 0x278 /* "API is not supported for non-connecting or closed container" */);
|
|
266
278
|
this._reconnectMode = mode;
|
|
267
279
|
if (mode !== contracts_js_1.ReconnectMode.Enabled) {
|
|
268
280
|
// immediately disconnect - do not rely on service eventually dropping connection.
|
|
@@ -283,7 +295,7 @@ class ConnectionManager {
|
|
|
283
295
|
this._forceReadonly = readonly;
|
|
284
296
|
if (oldValue !== this.readonly) {
|
|
285
297
|
if (this._reconnectMode === contracts_js_1.ReconnectMode.Never) {
|
|
286
|
-
throw new
|
|
298
|
+
throw new internal_5.UsageError("API is not supported for non-connecting or closed container");
|
|
287
299
|
}
|
|
288
300
|
let reconnect = false;
|
|
289
301
|
if (this.readonly === true) {
|
|
@@ -312,12 +324,12 @@ class ConnectionManager {
|
|
|
312
324
|
}
|
|
313
325
|
connect(reason, connectionMode) {
|
|
314
326
|
this.connectCore(reason, connectionMode).catch((error) => {
|
|
315
|
-
const normalizedError = (0,
|
|
327
|
+
const normalizedError = (0, internal_5.normalizeError)(error, { props: fatalConnectErrorProp });
|
|
316
328
|
this.props.closeHandler(normalizedError);
|
|
317
329
|
});
|
|
318
330
|
}
|
|
319
331
|
async connectCore(reason, connectionMode) {
|
|
320
|
-
(0,
|
|
332
|
+
(0, internal_2.assert)(!this._disposed, 0x26a /* "not closed" */);
|
|
321
333
|
let requestedMode = connectionMode ?? this.defaultReconnectionMode;
|
|
322
334
|
// if we have any non-acked ops from last connection, reconnect as "write".
|
|
323
335
|
// without that we would connect in view-only mode, which will result in immediate
|
|
@@ -343,19 +355,19 @@ class ConnectionManager {
|
|
|
343
355
|
connected: this.connection !== undefined,
|
|
344
356
|
mode,
|
|
345
357
|
requestedMode,
|
|
346
|
-
stack: (0,
|
|
358
|
+
stack: (0, internal_5.generateStack)(),
|
|
347
359
|
});
|
|
348
360
|
}
|
|
349
361
|
return;
|
|
350
362
|
}
|
|
351
363
|
const docService = this.serviceProvider();
|
|
352
|
-
(0,
|
|
364
|
+
(0, internal_2.assert)(docService !== undefined, 0x2a7 /* "Container is not attached" */);
|
|
353
365
|
this.props.establishConnectionHandler(reason);
|
|
354
366
|
let connection;
|
|
355
367
|
if (docService.policies?.storageOnly === true) {
|
|
356
368
|
connection = new frozenServices_js_1.FrozenDeltaStream();
|
|
357
369
|
this.setupNewSuccessfulConnection(connection, "read", reason);
|
|
358
|
-
(0,
|
|
370
|
+
(0, internal_2.assert)(this.pendingConnection === undefined, 0x2b3 /* "logic error" */);
|
|
359
371
|
return;
|
|
360
372
|
}
|
|
361
373
|
let delayMs = InitialReconnectDelayInMs;
|
|
@@ -383,7 +395,7 @@ class ConnectionManager {
|
|
|
383
395
|
this.logger.sendTelemetryEvent({
|
|
384
396
|
eventName: "ConnectionAttemptCancelled",
|
|
385
397
|
attempts: connectRepeatCount,
|
|
386
|
-
duration: (0,
|
|
398
|
+
duration: (0, internal_5.formatTick)((0, client_utils_1.performanceNow)() - connectStartTime),
|
|
387
399
|
connectionEstablished: false,
|
|
388
400
|
});
|
|
389
401
|
return;
|
|
@@ -418,8 +430,8 @@ class ConnectionManager {
|
|
|
418
430
|
requestedMode = "read";
|
|
419
431
|
break;
|
|
420
432
|
}
|
|
421
|
-
else if ((0,
|
|
422
|
-
origError.errorType ===
|
|
433
|
+
else if ((0, internal_5.isFluidError)(origError) &&
|
|
434
|
+
origError.errorType === internal_3.DriverErrorTypes.outOfStorageError) {
|
|
423
435
|
// If we get out of storage error from calling joinsession, then use the NoDeltaStream object so
|
|
424
436
|
// that user can at least load the container.
|
|
425
437
|
connection = new frozenServices_js_1.FrozenDeltaStream(undefined, {
|
|
@@ -430,17 +442,17 @@ class ConnectionManager {
|
|
|
430
442
|
break;
|
|
431
443
|
}
|
|
432
444
|
// Socket.io error when we connect to wrong socket, or hit some multiplexing bug
|
|
433
|
-
if (!(0,
|
|
434
|
-
const error = (0,
|
|
445
|
+
if (!(0, internal_4.canRetryOnError)(origError)) {
|
|
446
|
+
const error = (0, internal_5.normalizeError)(origError, { props: fatalConnectErrorProp });
|
|
435
447
|
this.props.closeHandler(error);
|
|
436
448
|
throw error;
|
|
437
449
|
}
|
|
438
450
|
// Since the error is retryable this will not log to the error table
|
|
439
|
-
(0,
|
|
451
|
+
(0, internal_4.logNetworkFailure)(this.logger, {
|
|
440
452
|
attempts: connectRepeatCount,
|
|
441
453
|
delay: delayMs, // milliseconds
|
|
442
454
|
eventName: "DeltaConnectionFailureToConnect",
|
|
443
|
-
duration: (0,
|
|
455
|
+
duration: (0, internal_5.formatTick)((0, client_utils_1.performanceNow)() - connectStartTime),
|
|
444
456
|
}, origError);
|
|
445
457
|
lastError = origError;
|
|
446
458
|
// We will not perform retries if the container disconnected and the ReconnectMode is set to Disabled or Never
|
|
@@ -449,14 +461,14 @@ class ConnectionManager {
|
|
|
449
461
|
return;
|
|
450
462
|
}
|
|
451
463
|
const waitStartTime = (0, client_utils_1.performanceNow)();
|
|
452
|
-
const retryDelayFromError = (0,
|
|
464
|
+
const retryDelayFromError = (0, internal_4.getRetryDelayFromError)(origError);
|
|
453
465
|
// If the error told us to wait or browser signals us that we are offline, then calculate the time we
|
|
454
466
|
// want to wait for before retrying. then we wait for that time. If the error didn't tell us to wait,
|
|
455
467
|
// let's still wait a little bit before retrying. We can skip this delay if we're confident we're offline,
|
|
456
468
|
// because we probably just need to wait to come back online. But we never have strong signal of being
|
|
457
469
|
// offline, so we at least wait for sometime.
|
|
458
470
|
if (retryDelayFromError !== undefined || globalThis.navigator?.onLine !== false) {
|
|
459
|
-
delayMs = (0,
|
|
471
|
+
delayMs = (0, internal_4.calculateMaxWaitTime)(delayMs, origError);
|
|
460
472
|
}
|
|
461
473
|
// Raise event in case the delay was there from the error.
|
|
462
474
|
if (retryDelayFromError !== undefined) {
|
|
@@ -475,13 +487,13 @@ class ConnectionManager {
|
|
|
475
487
|
this.logger.sendTelemetryEvent({
|
|
476
488
|
eventName: "RetryDelayExceedsConnectionTimeout",
|
|
477
489
|
attempts: connectRepeatCount,
|
|
478
|
-
duration: (0,
|
|
490
|
+
duration: (0, internal_5.formatTick)(elapsedTime),
|
|
479
491
|
calculatedDelayMs: delayMs,
|
|
480
492
|
remainingTimeMs: remainingTime,
|
|
481
493
|
timeoutMs: this.retryConnectionTimeoutMs,
|
|
482
494
|
});
|
|
483
495
|
// Throw the error immediately since the estimated time for delay + next connection attempt would exceed our conservative timeout buffer
|
|
484
|
-
throw (0,
|
|
496
|
+
throw (0, internal_5.normalizeError)(origError, { props: fatalConnectErrorProp });
|
|
485
497
|
}
|
|
486
498
|
}
|
|
487
499
|
await new Promise((resolve) => {
|
|
@@ -503,10 +515,10 @@ class ConnectionManager {
|
|
|
503
515
|
}
|
|
504
516
|
// If we retried more than once, log an event about how long it took (this will not log to error table)
|
|
505
517
|
if (connectRepeatCount > 1) {
|
|
506
|
-
(0,
|
|
518
|
+
(0, internal_4.logNetworkFailure)(this.logger, {
|
|
507
519
|
eventName: "MultipleDeltaConnectionFailures",
|
|
508
520
|
attempts: connectRepeatCount,
|
|
509
|
-
duration: (0,
|
|
521
|
+
duration: (0, internal_5.formatTick)((0, client_utils_1.performanceNow)() - connectStartTime),
|
|
510
522
|
}, lastError);
|
|
511
523
|
}
|
|
512
524
|
// Check for abort signal after while loop as well or we've been disposed
|
|
@@ -515,7 +527,7 @@ class ConnectionManager {
|
|
|
515
527
|
this.logger.sendTelemetryEvent({
|
|
516
528
|
eventName: "ConnectionAttemptCancelled",
|
|
517
529
|
attempts: connectRepeatCount,
|
|
518
|
-
duration: (0,
|
|
530
|
+
duration: (0, internal_5.formatTick)((0, client_utils_1.performanceNow)() - connectStartTime),
|
|
519
531
|
connectionEstablished: true,
|
|
520
532
|
});
|
|
521
533
|
return;
|
|
@@ -554,7 +566,7 @@ class ConnectionManager {
|
|
|
554
566
|
}
|
|
555
567
|
return false;
|
|
556
568
|
}
|
|
557
|
-
(0,
|
|
569
|
+
(0, internal_2.assert)(this.pendingConnection === undefined, 0x27b /* "reentrancy may result in incorrect behavior" */);
|
|
558
570
|
const connection = this.connection;
|
|
559
571
|
// Avoid any re-entrancy - clear object reference
|
|
560
572
|
this.connection = undefined;
|
|
@@ -578,7 +590,7 @@ class ConnectionManager {
|
|
|
578
590
|
* Cancel in-progress connection attempt.
|
|
579
591
|
*/
|
|
580
592
|
cancelConnection(reason) {
|
|
581
|
-
(0,
|
|
593
|
+
(0, internal_2.assert)(this.pendingConnection !== undefined, 0x345 /* this.pendingConnection is undefined when trying to cancel */);
|
|
582
594
|
this.pendingConnection.abort();
|
|
583
595
|
this.pendingConnection = undefined;
|
|
584
596
|
this.logger.sendTelemetryEvent({
|
|
@@ -597,15 +609,15 @@ class ConnectionManager {
|
|
|
597
609
|
*/
|
|
598
610
|
setupNewSuccessfulConnection(connection, requestedMode, reason) {
|
|
599
611
|
// Old connection should have been cleaned up before establishing a new one
|
|
600
|
-
(0,
|
|
601
|
-
(0,
|
|
612
|
+
(0, internal_2.assert)(this.connection === undefined, 0x0e6 /* "old connection exists on new connection setup" */);
|
|
613
|
+
(0, internal_2.assert)(!connection.disposed, 0x28a /* "can't be disposed - Callers need to ensure that!" */);
|
|
602
614
|
this.pendingConnection = undefined;
|
|
603
615
|
const oldReadonlyValue = this.readonly;
|
|
604
616
|
this.connection = connection;
|
|
605
617
|
// Does information in scopes & mode matches?
|
|
606
618
|
// If we asked for "write" and got "read", then file is read-only
|
|
607
619
|
// But if we ask read, server can still give us write.
|
|
608
|
-
const readonlyPermission = !connection.claims.scopes.includes(
|
|
620
|
+
const readonlyPermission = !connection.claims.scopes.includes(internal_3.ScopeType.DocWrite);
|
|
609
621
|
if (connection.mode !== requestedMode) {
|
|
610
622
|
this.logger.sendTelemetryEvent({
|
|
611
623
|
eventName: "ConnectionModeMismatch",
|
|
@@ -613,7 +625,7 @@ class ConnectionManager {
|
|
|
613
625
|
mode: connection.mode,
|
|
614
626
|
});
|
|
615
627
|
}
|
|
616
|
-
(0,
|
|
628
|
+
(0, internal_2.assert)(!readonlyPermission || this.connectionMode === "read", 0x0e8 /* "readonly perf with write connection" */);
|
|
617
629
|
this.set_readonlyPermissions(readonlyPermission, oldReadonlyValue, (0, frozenServices_js_1.isFrozenDeltaStreamConnection)(connection)
|
|
618
630
|
? connection.readonlyConnectionReason
|
|
619
631
|
: undefined);
|
|
@@ -673,17 +685,19 @@ class ConnectionManager {
|
|
|
673
685
|
// API uses null
|
|
674
686
|
// eslint-disable-next-line unicorn/no-null
|
|
675
687
|
clientId: null, // system message
|
|
676
|
-
content:
|
|
688
|
+
content: (0, internal_1.JsonStringify)({
|
|
677
689
|
type: protocol_js_1.SignalType.Clear,
|
|
678
690
|
}),
|
|
679
691
|
};
|
|
680
692
|
// list of signals to process due to this new connection
|
|
681
|
-
let signalsToProcess = [
|
|
693
|
+
let signalsToProcess = [
|
|
694
|
+
clearSignal,
|
|
695
|
+
];
|
|
682
696
|
const clientJoinSignals = (connection.initialClients ?? []).map((priorClient) => ({
|
|
683
697
|
// API uses null
|
|
684
698
|
// eslint-disable-next-line unicorn/no-null
|
|
685
699
|
clientId: null, // system signal
|
|
686
|
-
content:
|
|
700
|
+
content: (0, internal_1.JsonStringify)({
|
|
687
701
|
type: protocol_js_1.SignalType.ClientJoin,
|
|
688
702
|
content: priorClient, // ISignalClient
|
|
689
703
|
}),
|
|
@@ -696,6 +710,7 @@ class ConnectionManager {
|
|
|
696
710
|
// for "self" and connection.initialClients does not contain "self", so we have to process them after
|
|
697
711
|
// "clear" signal above.
|
|
698
712
|
if (connection.initialSignals !== undefined && connection.initialSignals.length > 0) {
|
|
713
|
+
assertExpectedSignals(connection.initialSignals);
|
|
699
714
|
signalsToProcess = [...signalsToProcess, ...connection.initialSignals];
|
|
700
715
|
}
|
|
701
716
|
this.props.signalHandler(signalsToProcess);
|
|
@@ -721,7 +736,7 @@ class ConnectionManager {
|
|
|
721
736
|
// We quite often get protocol errors before / after observing nack/disconnect
|
|
722
737
|
// we do not want to run through same sequence twice.
|
|
723
738
|
// If we're already disconnected/disconnecting it's not appropriate to call this again.
|
|
724
|
-
(0,
|
|
739
|
+
(0, internal_2.assert)(this.connection !== undefined, 0x0eb /* "Missing connection for reconnect" */);
|
|
725
740
|
this.disconnectFromDeltaStream(reason);
|
|
726
741
|
// We will always trigger reconnect, even if canRetry is false.
|
|
727
742
|
// Any truly fatal error state will result in container close upon attempted reconnect,
|
|
@@ -743,7 +758,7 @@ class ConnectionManager {
|
|
|
743
758
|
return;
|
|
744
759
|
}
|
|
745
760
|
// If the error tells us to wait before retrying, then do so.
|
|
746
|
-
const delayMs = (0,
|
|
761
|
+
const delayMs = (0, internal_4.getRetryDelayFromError)(reason.error);
|
|
747
762
|
if (reason.error !== undefined && delayMs !== undefined) {
|
|
748
763
|
this.props.reconnectionDelayHandler(delayMs, reason.error);
|
|
749
764
|
await new Promise((resolve) => {
|
|
@@ -763,8 +778,8 @@ class ConnectionManager {
|
|
|
763
778
|
}
|
|
764
779
|
prepareMessageToSend(message) {
|
|
765
780
|
if (this.readonly === true) {
|
|
766
|
-
(0,
|
|
767
|
-
const error = new
|
|
781
|
+
(0, internal_2.assert)(this.readOnlyInfo.readonly === true, 0x1f0 /* "Unexpected mismatch in readonly" */);
|
|
782
|
+
const error = new internal_5.GenericError("deltaManagerReadonlySubmit", undefined /* error */, {
|
|
768
783
|
readonly: this.readOnlyInfo.readonly,
|
|
769
784
|
forcedReadonly: this.readOnlyInfo.forced,
|
|
770
785
|
readonlyPermissions: this.readOnlyInfo.permissions,
|
|
@@ -777,13 +792,13 @@ class ConnectionManager {
|
|
|
777
792
|
// reset clientSequenceNumber if we are using new clientId.
|
|
778
793
|
// we keep info about old connection as long as possible to be able to account for all non-acked ops
|
|
779
794
|
// that we pick up on next connection.
|
|
780
|
-
(0,
|
|
795
|
+
(0, internal_2.assert)(!!this.connection, 0x0e4 /* "Lost old connection!" */);
|
|
781
796
|
if (this.lastSubmittedClientId !== this.connection?.clientId) {
|
|
782
797
|
this.lastSubmittedClientId = this.connection?.clientId;
|
|
783
798
|
this.clientSequenceNumber = 0;
|
|
784
799
|
this.clientSequenceNumberObserved = 0;
|
|
785
800
|
}
|
|
786
|
-
if ((0,
|
|
801
|
+
if ((0, internal_4.isRuntimeMessage)(message)) {
|
|
787
802
|
this.localOpsToIgnore = 0;
|
|
788
803
|
}
|
|
789
804
|
else {
|
|
@@ -803,7 +818,7 @@ class ConnectionManager {
|
|
|
803
818
|
}
|
|
804
819
|
}
|
|
805
820
|
sendMessages(messages) {
|
|
806
|
-
(0,
|
|
821
|
+
(0, internal_2.assert)(this.connected, 0x2b4 /* "not connected on sending ops!" */);
|
|
807
822
|
// If connection is "read" or implicit "read" (got leave op for "write" connection),
|
|
808
823
|
// then op can't make it through - we will get a nack if op is sent.
|
|
809
824
|
// We can short-circuit this process.
|
|
@@ -825,20 +840,20 @@ class ConnectionManager {
|
|
|
825
840
|
}
|
|
826
841
|
return;
|
|
827
842
|
}
|
|
828
|
-
(0,
|
|
843
|
+
(0, internal_2.assert)(!this.pendingReconnect, 0x2b5 /* "logic error" */);
|
|
829
844
|
this._outbound.push(messages);
|
|
830
845
|
}
|
|
831
846
|
beforeProcessingIncomingOp(message) {
|
|
832
847
|
// if we have connection, and message is local, then we better treat is as local!
|
|
833
|
-
(0,
|
|
848
|
+
(0, internal_2.assert)(this.clientId !== message.clientId || this.lastSubmittedClientId === message.clientId, 0x0ee /* "Not accounting local messages correctly" */);
|
|
834
849
|
if (this.lastSubmittedClientId !== undefined &&
|
|
835
850
|
this.lastSubmittedClientId === message.clientId) {
|
|
836
851
|
const clientSequenceNumber = message.clientSequenceNumber;
|
|
837
|
-
(0,
|
|
838
|
-
(0,
|
|
852
|
+
(0, internal_2.assert)(this.clientSequenceNumberObserved < clientSequenceNumber, 0x0ef /* "client seq# not growing" */);
|
|
853
|
+
(0, internal_2.assert)(clientSequenceNumber <= this.clientSequenceNumber, 0x0f0 /* "Incoming local client seq# > generated by this client" */);
|
|
839
854
|
this.clientSequenceNumberObserved = clientSequenceNumber;
|
|
840
855
|
}
|
|
841
|
-
if (message.type ===
|
|
856
|
+
if (message.type === internal_3.MessageType.ClientLeave) {
|
|
842
857
|
const systemLeaveMessage = message;
|
|
843
858
|
const clientId = JSON.parse(systemLeaveMessage.data);
|
|
844
859
|
if (clientId === this.clientId) {
|