@fluidframework/container-loader 2.0.0-rc.2.0.1 → 2.0.0-rc.3.0.0
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/CHANGELOG.md +33 -0
- package/api-report/container-loader.api.md +13 -13
- package/dist/attachment.d.ts +6 -9
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js +5 -5
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts +1 -1
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +4 -4
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js +2 -2
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +4 -4
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +48 -43
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +3 -3
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +27 -27
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +9 -46
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +105 -116
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +19 -7
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +7 -2
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +3 -3
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +6 -6
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +4 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +2 -2
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.d.ts +2 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js +4 -4
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +11 -7
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +53 -50
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +5 -5
- package/dist/deltaQueue.js.map +1 -1
- package/dist/error.d.ts +3 -2
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +5 -5
- package/dist/error.js.map +1 -1
- package/dist/legacy.d.ts +29 -0
- package/dist/loader.d.ts +4 -4
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +23 -23
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -2
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +2 -2
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/dist/noopHeuristic.d.ts +1 -1
- package/dist/noopHeuristic.d.ts.map +1 -1
- package/dist/noopHeuristic.js +6 -6
- package/dist/noopHeuristic.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/protocol.d.ts +1 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +2 -2
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +4 -4
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/public.d.ts +14 -0
- package/dist/quorum.d.ts +1 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js +4 -0
- package/dist/quorum.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +7 -7
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +86 -16
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +182 -82
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +24 -9
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +82 -25
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/attachment.d.ts +6 -9
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js +1 -1
- package/lib/attachment.js.map +1 -1
- package/lib/audience.d.ts +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +4 -4
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +11 -6
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +3 -3
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +2 -2
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +9 -46
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +37 -48
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +19 -7
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +7 -2
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +3 -3
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +2 -2
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +4 -3
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.d.ts +2 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +11 -7
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +13 -10
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +2 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/error.d.ts +3 -2
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +2 -2
- package/lib/error.js.map +1 -1
- package/lib/legacy.d.ts +29 -0
- package/lib/loader.d.ts +4 -4
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +4 -4
- package/lib/loader.js.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -2
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +2 -2
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/lib/noopHeuristic.d.ts +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -1
- package/lib/noopHeuristic.js +2 -2
- package/lib/noopHeuristic.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/protocol.d.ts +1 -1
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +1 -1
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +4 -4
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/public.d.ts +14 -0
- package/lib/quorum.d.ts +1 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js +4 -0
- package/lib/quorum.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +2 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +3 -3
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts +86 -16
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +174 -77
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts +24 -9
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +69 -15
- package/lib/utils.js.map +1 -1
- package/package.json +37 -58
- package/src/attachment.ts +10 -8
- package/src/audience.ts +3 -2
- package/src/catchUpMonitor.ts +2 -2
- package/src/connectionManager.ts +27 -20
- package/src/connectionStateHandler.ts +7 -7
- package/src/container.ts +90 -143
- package/src/containerContext.ts +22 -12
- package/src/containerStorageAdapter.ts +7 -6
- package/src/contracts.ts +4 -5
- package/src/debugLogger.ts +3 -4
- package/src/deltaManager.ts +40 -30
- package/src/deltaQueue.ts +2 -2
- package/src/error.ts +5 -4
- package/src/loader.ts +25 -23
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +4 -4
- package/src/noopHeuristic.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +2 -2
- package/src/protocolTreeDocumentStorageService.ts +4 -1
- package/src/quorum.ts +2 -1
- package/src/retriableDocumentStorageService.ts +6 -5
- package/src/serializedStateManager.ts +299 -111
- package/src/utils.ts +103 -24
- package/api-extractor-cjs.json +0 -8
- package/dist/container-loader-alpha.d.ts +0 -275
- package/dist/container-loader-beta.d.ts +0 -101
- package/dist/container-loader-public.d.ts +0 -101
- package/dist/container-loader-untrimmed.d.ts +0 -331
- package/lib/container-loader-alpha.d.ts +0 -275
- package/lib/container-loader-beta.d.ts +0 -101
- package/lib/container-loader-public.d.ts +0 -101
- package/lib/container-loader-untrimmed.d.ts +0 -331
- package/lib/test/attachment.spec.js +0 -380
- package/lib/test/attachment.spec.js.map +0 -1
- package/lib/test/catchUpMonitor.spec.js +0 -88
- package/lib/test/catchUpMonitor.spec.js.map +0 -1
- package/lib/test/connectionManager.spec.js +0 -201
- package/lib/test/connectionManager.spec.js.map +0 -1
- package/lib/test/connectionStateHandler.spec.js +0 -555
- package/lib/test/connectionStateHandler.spec.js.map +0 -1
- package/lib/test/container.spec.js +0 -64
- package/lib/test/container.spec.js.map +0 -1
- package/lib/test/deltaManager.spec.js +0 -405
- package/lib/test/deltaManager.spec.js.map +0 -1
- package/lib/test/loader.spec.js +0 -212
- package/lib/test/loader.spec.js.map +0 -1
- package/lib/test/locationRedirectionTests.spec.js +0 -44
- package/lib/test/locationRedirectionTests.spec.js.map +0 -1
- package/lib/test/serializedStateManager.spec.js +0 -148
- package/lib/test/serializedStateManager.spec.js.map +0 -1
- package/lib/test/snapshotConversionTest.spec.js +0 -79
- package/lib/test/snapshotConversionTest.spec.js.map +0 -1
- package/lib/test/types/validateContainerLoaderPrevious.generated.js +0 -38
- package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +0 -1
- package/lib/test/utils.spec.js +0 -31
- package/lib/test/utils.spec.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ConnectionManager = void 0;
|
|
8
|
-
const core_interfaces_1 = require("@fluidframework/core-interfaces");
|
|
9
|
-
const core_utils_1 = require("@fluidframework/core-utils");
|
|
10
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
|
+
const core_interfaces_1 = require("@fluidframework/core-interfaces");
|
|
10
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
11
11
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
12
|
-
const
|
|
12
|
+
const internal_2 = require("@fluidframework/driver-utils/internal");
|
|
13
13
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
14
|
-
const
|
|
14
|
+
const internal_3 = require("@fluidframework/telemetry-utils/internal");
|
|
15
15
|
const contracts_js_1 = require("./contracts.js");
|
|
16
16
|
const deltaQueue_js_1 = require("./deltaQueue.js");
|
|
17
17
|
const protocol_js_1 = require("./protocol.js");
|
|
@@ -24,7 +24,7 @@ function getNackReconnectInfo(nackContent) {
|
|
|
24
24
|
const message = `Nack (${nackContent.type}): ${nackContent.message}`;
|
|
25
25
|
const canRetry = nackContent.code !== 403;
|
|
26
26
|
const retryAfterMs = nackContent.retryAfter !== undefined ? nackContent.retryAfter * 1000 : undefined;
|
|
27
|
-
return (0,
|
|
27
|
+
return (0, internal_2.createGenericNetworkError)(message, { canRetry, retryAfterMs }, { statusCode: nackContent.code, driverVersion: undefined });
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Implementation of IDocumentDeltaConnection that does not support submitting
|
|
@@ -253,7 +253,7 @@ class ConnectionManager {
|
|
|
253
253
|
this.nackHandler = (documentId, messages) => {
|
|
254
254
|
const message = messages[0];
|
|
255
255
|
if (this._readonlyPermissions === true) {
|
|
256
|
-
this.props.closeHandler((0,
|
|
256
|
+
this.props.closeHandler((0, internal_2.createWriteError)("writeOnReadOnlyDocument", { driverVersion: undefined }));
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
const reconnectInfo = getNackReconnectInfo(message.content);
|
|
@@ -285,7 +285,7 @@ class ConnectionManager {
|
|
|
285
285
|
this.connection.submit(messages);
|
|
286
286
|
});
|
|
287
287
|
this._outbound.on("error", (error) => {
|
|
288
|
-
this.props.closeHandler((0,
|
|
288
|
+
this.props.closeHandler((0, internal_3.normalizeError)(error));
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
dispose(error, switchToReadonly = true) {
|
|
@@ -315,7 +315,7 @@ class ConnectionManager {
|
|
|
315
315
|
* Will throw an error if reconnectMode set to Never.
|
|
316
316
|
*/
|
|
317
317
|
setAutoReconnect(mode, reason) {
|
|
318
|
-
(0,
|
|
318
|
+
(0, internal_1.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" */);
|
|
319
319
|
this._reconnectMode = mode;
|
|
320
320
|
if (mode !== contracts_js_1.ReconnectMode.Enabled) {
|
|
321
321
|
// immediately disconnect - do not rely on service eventually dropping connection.
|
|
@@ -336,7 +336,7 @@ class ConnectionManager {
|
|
|
336
336
|
this._forceReadonly = readonly;
|
|
337
337
|
if (oldValue !== this.readonly) {
|
|
338
338
|
if (this._reconnectMode === contracts_js_1.ReconnectMode.Never) {
|
|
339
|
-
throw new
|
|
339
|
+
throw new internal_3.UsageError("API is not supported for non-connecting or closed container");
|
|
340
340
|
}
|
|
341
341
|
let reconnect = false;
|
|
342
342
|
if (this.readonly === true) {
|
|
@@ -365,12 +365,12 @@ class ConnectionManager {
|
|
|
365
365
|
}
|
|
366
366
|
connect(reason, connectionMode) {
|
|
367
367
|
this.connectCore(reason, connectionMode).catch((e) => {
|
|
368
|
-
const normalizedError = (0,
|
|
368
|
+
const normalizedError = (0, internal_3.normalizeError)(e, { props: fatalConnectErrorProp });
|
|
369
369
|
this.props.closeHandler(normalizedError);
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
async connectCore(reason, connectionMode) {
|
|
373
|
-
(0,
|
|
373
|
+
(0, internal_1.assert)(!this._disposed, 0x26a /* "not closed" */);
|
|
374
374
|
if (this.connection !== undefined) {
|
|
375
375
|
return; // Connection attempt already completed successfully
|
|
376
376
|
}
|
|
@@ -378,7 +378,7 @@ class ConnectionManager {
|
|
|
378
378
|
if (this.pendingConnection !== undefined) {
|
|
379
379
|
pendingConnectionMode = this.pendingConnection.connectionMode;
|
|
380
380
|
this.cancelConnection(reason); // Throw out in-progress connection attempt in favor of new attempt
|
|
381
|
-
(0,
|
|
381
|
+
(0, internal_1.assert)(this.pendingConnection === undefined, 0x344 /* this.pendingConnection should be undefined */);
|
|
382
382
|
}
|
|
383
383
|
// If there is no specified ConnectionMode, try the previous mode, if there is no previous mode use default
|
|
384
384
|
let requestedMode = connectionMode ?? pendingConnectionMode ?? this.defaultReconnectionMode;
|
|
@@ -391,12 +391,13 @@ class ConnectionManager {
|
|
|
391
391
|
requestedMode = "write";
|
|
392
392
|
}
|
|
393
393
|
const docService = this.serviceProvider();
|
|
394
|
-
(0,
|
|
394
|
+
(0, internal_1.assert)(docService !== undefined, 0x2a7 /* "Container is not attached" */);
|
|
395
|
+
this.props.establishConnectionHandler(reason);
|
|
395
396
|
let connection;
|
|
396
397
|
if (docService.policies?.storageOnly === true) {
|
|
397
398
|
connection = new NoDeltaStream();
|
|
398
399
|
this.setupNewSuccessfulConnection(connection, "read", reason);
|
|
399
|
-
(0,
|
|
400
|
+
(0, internal_1.assert)(this.pendingConnection === undefined, 0x2b3 /* "logic error" */);
|
|
400
401
|
return;
|
|
401
402
|
}
|
|
402
403
|
let delayMs = InitialReconnectDelayInMs;
|
|
@@ -411,7 +412,6 @@ class ConnectionManager {
|
|
|
411
412
|
},
|
|
412
413
|
connectionMode: requestedMode,
|
|
413
414
|
};
|
|
414
|
-
this.props.establishConnectionHandler(reason);
|
|
415
415
|
// This loop will keep trying to connect until successful, with a delay between each iteration.
|
|
416
416
|
while (connection === undefined) {
|
|
417
417
|
if (this._disposed) {
|
|
@@ -421,7 +421,7 @@ class ConnectionManager {
|
|
|
421
421
|
this.logger.sendTelemetryEvent({
|
|
422
422
|
eventName: "ConnectionAttemptCancelled",
|
|
423
423
|
attempts: connectRepeatCount,
|
|
424
|
-
duration: (0,
|
|
424
|
+
duration: (0, internal_3.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
425
425
|
connectionEstablished: false,
|
|
426
426
|
});
|
|
427
427
|
return;
|
|
@@ -456,7 +456,7 @@ class ConnectionManager {
|
|
|
456
456
|
requestedMode = "read";
|
|
457
457
|
break;
|
|
458
458
|
}
|
|
459
|
-
else if ((0,
|
|
459
|
+
else if ((0, internal_3.isFluidError)(origError) &&
|
|
460
460
|
origError.errorType === driver_definitions_1.DriverErrorTypes.outOfStorageError) {
|
|
461
461
|
// If we get out of storage error from calling joinsession, then use the NoDeltaStream object so
|
|
462
462
|
// that user can at least load the container.
|
|
@@ -468,28 +468,33 @@ class ConnectionManager {
|
|
|
468
468
|
break;
|
|
469
469
|
}
|
|
470
470
|
// Socket.io error when we connect to wrong socket, or hit some multiplexing bug
|
|
471
|
-
if (!(0,
|
|
472
|
-
const error = (0,
|
|
471
|
+
if (!(0, internal_2.canRetryOnError)(origError)) {
|
|
472
|
+
const error = (0, internal_3.normalizeError)(origError, { props: fatalConnectErrorProp });
|
|
473
473
|
this.props.closeHandler(error);
|
|
474
474
|
throw error;
|
|
475
475
|
}
|
|
476
476
|
// Since the error is retryable this will not log to the error table
|
|
477
|
-
(0,
|
|
477
|
+
(0, internal_2.logNetworkFailure)(this.logger, {
|
|
478
478
|
attempts: connectRepeatCount,
|
|
479
479
|
delay: delayMs,
|
|
480
480
|
eventName: "DeltaConnectionFailureToConnect",
|
|
481
|
-
duration: (0,
|
|
481
|
+
duration: (0, internal_3.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
482
482
|
}, origError);
|
|
483
483
|
lastError = origError;
|
|
484
|
+
// We will not perform retries if the container disconnected and the ReconnectMode is set to Disabled or Never
|
|
485
|
+
// so break out of the re-connecting while-loop after first attempt
|
|
486
|
+
if (this.reconnectMode !== contracts_js_1.ReconnectMode.Enabled) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
484
489
|
const waitStartTime = client_utils_1.performance.now();
|
|
485
|
-
const retryDelayFromError = (0,
|
|
490
|
+
const retryDelayFromError = (0, internal_2.getRetryDelayFromError)(origError);
|
|
486
491
|
// If the error told us to wait or browser signals us that we are offline, then calculate the time we
|
|
487
492
|
// want to wait for before retrying. then we wait for that time. If the error didn't tell us to wait,
|
|
488
493
|
// let's still wait a little bit before retrying. We can skip this delay if we're confident we're offline,
|
|
489
494
|
// because we probably just need to wait to come back online. But we never have strong signal of being
|
|
490
495
|
// offline, so we at least wait for sometime.
|
|
491
496
|
if (retryDelayFromError !== undefined || globalThis.navigator?.onLine !== false) {
|
|
492
|
-
delayMs = (0,
|
|
497
|
+
delayMs = (0, internal_2.calculateMaxWaitTime)(delayMs, origError);
|
|
493
498
|
}
|
|
494
499
|
// Raise event in case the delay was there from the error.
|
|
495
500
|
if (retryDelayFromError !== undefined) {
|
|
@@ -514,10 +519,10 @@ class ConnectionManager {
|
|
|
514
519
|
}
|
|
515
520
|
// If we retried more than once, log an event about how long it took (this will not log to error table)
|
|
516
521
|
if (connectRepeatCount > 1) {
|
|
517
|
-
(0,
|
|
522
|
+
(0, internal_2.logNetworkFailure)(this.logger, {
|
|
518
523
|
eventName: "MultipleDeltaConnectionFailures",
|
|
519
524
|
attempts: connectRepeatCount,
|
|
520
|
-
duration: (0,
|
|
525
|
+
duration: (0, internal_3.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
521
526
|
}, lastError);
|
|
522
527
|
}
|
|
523
528
|
// Check for abort signal after while loop as well or we've been disposed
|
|
@@ -526,7 +531,7 @@ class ConnectionManager {
|
|
|
526
531
|
this.logger.sendTelemetryEvent({
|
|
527
532
|
eventName: "ConnectionAttemptCancelled",
|
|
528
533
|
attempts: connectRepeatCount,
|
|
529
|
-
duration: (0,
|
|
534
|
+
duration: (0, internal_3.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
530
535
|
connectionEstablished: true,
|
|
531
536
|
});
|
|
532
537
|
return;
|
|
@@ -565,7 +570,7 @@ class ConnectionManager {
|
|
|
565
570
|
}
|
|
566
571
|
return false;
|
|
567
572
|
}
|
|
568
|
-
(0,
|
|
573
|
+
(0, internal_1.assert)(this.pendingConnection === undefined, 0x27b /* "reentrancy may result in incorrect behavior" */);
|
|
569
574
|
const connection = this.connection;
|
|
570
575
|
// Avoid any re-entrancy - clear object reference
|
|
571
576
|
this.connection = undefined;
|
|
@@ -588,7 +593,7 @@ class ConnectionManager {
|
|
|
588
593
|
* Cancel in-progress connection attempt.
|
|
589
594
|
*/
|
|
590
595
|
cancelConnection(reason) {
|
|
591
|
-
(0,
|
|
596
|
+
(0, internal_1.assert)(this.pendingConnection !== undefined, 0x345 /* this.pendingConnection is undefined when trying to cancel */);
|
|
592
597
|
this.pendingConnection.abort();
|
|
593
598
|
this.pendingConnection = undefined;
|
|
594
599
|
this.logger.sendTelemetryEvent({ eventName: "ConnectionCancelReceived" });
|
|
@@ -604,8 +609,8 @@ class ConnectionManager {
|
|
|
604
609
|
*/
|
|
605
610
|
setupNewSuccessfulConnection(connection, requestedMode, reason) {
|
|
606
611
|
// Old connection should have been cleaned up before establishing a new one
|
|
607
|
-
(0,
|
|
608
|
-
(0,
|
|
612
|
+
(0, internal_1.assert)(this.connection === undefined, 0x0e6 /* "old connection exists on new connection setup" */);
|
|
613
|
+
(0, internal_1.assert)(!connection.disposed, 0x28a /* "can't be disposed - Callers need to ensure that!" */);
|
|
609
614
|
this.pendingConnection = undefined;
|
|
610
615
|
const oldReadonlyValue = this.readonly;
|
|
611
616
|
this.connection = connection;
|
|
@@ -622,8 +627,8 @@ class ConnectionManager {
|
|
|
622
627
|
}
|
|
623
628
|
// This connection mode validation logic is moving to the driver layer in 0.44. These two asserts can be
|
|
624
629
|
// removed after those packages have released and become ubiquitous.
|
|
625
|
-
(0,
|
|
626
|
-
(0,
|
|
630
|
+
(0, internal_1.assert)(requestedMode === "read" || readonly === (this.connectionMode === "read"), 0x0e7 /* "claims/connectionMode mismatch" */);
|
|
631
|
+
(0, internal_1.assert)(!readonly || this.connectionMode === "read", 0x0e8 /* "readonly perf with write connection" */);
|
|
627
632
|
this.set_readonlyPermissions(readonly, oldReadonlyValue, isNoDeltaStreamConnection(connection) ? connection.readonlyConnectionReason : undefined);
|
|
628
633
|
if (this._disposed) {
|
|
629
634
|
// Raise proper events, Log telemetry event and close connection.
|
|
@@ -725,7 +730,7 @@ class ConnectionManager {
|
|
|
725
730
|
// We quite often get protocol errors before / after observing nack/disconnect
|
|
726
731
|
// we do not want to run through same sequence twice.
|
|
727
732
|
// If we're already disconnected/disconnecting it's not appropriate to call this again.
|
|
728
|
-
(0,
|
|
733
|
+
(0, internal_1.assert)(this.connection !== undefined, 0x0eb /* "Missing connection for reconnect" */);
|
|
729
734
|
this.disconnectFromDeltaStream(reason);
|
|
730
735
|
// We will always trigger reconnect, even if canRetry is false.
|
|
731
736
|
// Any truly fatal error state will result in container close upon attempted reconnect,
|
|
@@ -747,7 +752,7 @@ class ConnectionManager {
|
|
|
747
752
|
return;
|
|
748
753
|
}
|
|
749
754
|
// If the error tells us to wait before retrying, then do so.
|
|
750
|
-
const delayMs = (0,
|
|
755
|
+
const delayMs = (0, internal_2.getRetryDelayFromError)(reason.error);
|
|
751
756
|
if (reason.error !== undefined && delayMs !== undefined) {
|
|
752
757
|
this.props.reconnectionDelayHandler(delayMs, reason.error);
|
|
753
758
|
await new Promise((resolve) => {
|
|
@@ -767,8 +772,8 @@ class ConnectionManager {
|
|
|
767
772
|
}
|
|
768
773
|
prepareMessageToSend(message) {
|
|
769
774
|
if (this.readonly === true) {
|
|
770
|
-
(0,
|
|
771
|
-
const error = new
|
|
775
|
+
(0, internal_1.assert)(this.readOnlyInfo.readonly === true, 0x1f0 /* "Unexpected mismatch in readonly" */);
|
|
776
|
+
const error = new internal_3.GenericError("deltaManagerReadonlySubmit", undefined /* error */, {
|
|
772
777
|
readonly: this.readOnlyInfo.readonly,
|
|
773
778
|
forcedReadonly: this.readOnlyInfo.forced,
|
|
774
779
|
readonlyPermissions: this.readOnlyInfo.permissions,
|
|
@@ -781,13 +786,13 @@ class ConnectionManager {
|
|
|
781
786
|
// reset clientSequenceNumber if we are using new clientId.
|
|
782
787
|
// we keep info about old connection as long as possible to be able to account for all non-acked ops
|
|
783
788
|
// that we pick up on next connection.
|
|
784
|
-
(0,
|
|
789
|
+
(0, internal_1.assert)(!!this.connection, 0x0e4 /* "Lost old connection!" */);
|
|
785
790
|
if (this.lastSubmittedClientId !== this.connection?.clientId) {
|
|
786
791
|
this.lastSubmittedClientId = this.connection?.clientId;
|
|
787
792
|
this.clientSequenceNumber = 0;
|
|
788
793
|
this.clientSequenceNumberObserved = 0;
|
|
789
794
|
}
|
|
790
|
-
if (!(0,
|
|
795
|
+
if (!(0, internal_2.isRuntimeMessage)(message)) {
|
|
791
796
|
this.localOpsToIgnore++;
|
|
792
797
|
}
|
|
793
798
|
else {
|
|
@@ -807,7 +812,7 @@ class ConnectionManager {
|
|
|
807
812
|
}
|
|
808
813
|
}
|
|
809
814
|
sendMessages(messages) {
|
|
810
|
-
(0,
|
|
815
|
+
(0, internal_1.assert)(this.connected, 0x2b4 /* "not connected on sending ops!" */);
|
|
811
816
|
// If connection is "read" or implicit "read" (got leave op for "write" connection),
|
|
812
817
|
// then op can't make it through - we will get a nack if op is sent.
|
|
813
818
|
// We can short-circuit this process.
|
|
@@ -829,17 +834,17 @@ class ConnectionManager {
|
|
|
829
834
|
}
|
|
830
835
|
return;
|
|
831
836
|
}
|
|
832
|
-
(0,
|
|
837
|
+
(0, internal_1.assert)(!this.pendingReconnect, 0x2b5 /* "logic error" */);
|
|
833
838
|
this._outbound.push(messages);
|
|
834
839
|
}
|
|
835
840
|
beforeProcessingIncomingOp(message) {
|
|
836
841
|
// if we have connection, and message is local, then we better treat is as local!
|
|
837
|
-
(0,
|
|
842
|
+
(0, internal_1.assert)(this.clientId !== message.clientId || this.lastSubmittedClientId === message.clientId, 0x0ee /* "Not accounting local messages correctly" */);
|
|
838
843
|
if (this.lastSubmittedClientId !== undefined &&
|
|
839
844
|
this.lastSubmittedClientId === message.clientId) {
|
|
840
845
|
const clientSequenceNumber = message.clientSequenceNumber;
|
|
841
|
-
(0,
|
|
842
|
-
(0,
|
|
846
|
+
(0, internal_1.assert)(this.clientSequenceNumberObserved < clientSequenceNumber, 0x0ef /* "client seq# not growing" */);
|
|
847
|
+
(0, internal_1.assert)(clientSequenceNumber <= this.clientSequenceNumber, 0x0f0 /* "Incoming local client seq# > generated by this client" */);
|
|
843
848
|
this.clientSequenceNumberObserved = clientSequenceNumber;
|
|
844
849
|
}
|
|
845
850
|
if (message.type === protocol_definitions_1.MessageType.ClientLeave) {
|