@fluidframework/container-loader 0.57.0-51086 → 0.58.0-55561
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connectionManager.d.ts +2 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +8 -12
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +2 -3
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +9 -10
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +10 -9
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -6
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +9 -8
- package/dist/containerContext.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +13 -23
- package/dist/deltaManager.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/retriableDocumentStorageService.js +1 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +8 -12
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +2 -3
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +9 -10
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +10 -9
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -6
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +9 -8
- package/lib/containerContext.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +14 -24
- package/lib/deltaManager.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/retriableDocumentStorageService.js +1 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/package.json +7 -7
- package/src/connectionManager.ts +8 -15
- package/src/connectionStateHandler.ts +11 -12
- package/src/container.ts +10 -9
- package/src/containerContext.ts +10 -9
- package/src/deltaManager.ts +14 -26
- package/src/packageVersion.ts +1 -1
- package/src/retriableDocumentStorageService.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,iBAAiB,EAGjB,WAAW,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,OAAO,EAEP,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EACX,cAAc,EAEd,WAAW,EAEd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACH,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACd,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,iBAAiB,EAGjB,WAAW,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,iBAAiB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AC,EAAE,MAAM;IAQxD,OAAO,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;IAIxE,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO;IAI/C,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAI3C,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAItE,oBAAoB,IAAI,OAAO;IAItC;;;OAGG;IACU,SAAS,CAAC,qBAAqB,EAAE,iBAAiB;IAoCxD,eAAe;YAMR,iBAAiB;YAWjB,kBAAkB;IAKhC,OAAO,CAAC,cAAc;YAMR,cAAc;CAkB/B"}
|
package/lib/containerContext.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { AttachState, } from "@fluidframework/container-definitions";
|
|
6
6
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { assert, LazyPromise } from "@fluidframework/common-utils";
|
|
8
|
+
import { isFluidResolvedUrl } from "@fluidframework/driver-utils";
|
|
8
9
|
const PackageNotFactoryError = "Code package does not implement IRuntimeFactory";
|
|
9
10
|
export class ContainerContext {
|
|
10
11
|
constructor(container, scope, codeLoader, _codeDetails, _baseSnapshot, deltaManager, quorum, loader, raiseContainerWarning, submitFn, submitSignalFn, closeFn, version, updateDirtyContainerState, existing, pendingLocalState) {
|
|
@@ -34,17 +35,17 @@ export class ContainerContext {
|
|
|
34
35
|
await context.instantiateRuntime(existing);
|
|
35
36
|
return context;
|
|
36
37
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Subtlety: returns this.taggedLogger since vanilla this.logger is now deprecated. See IContainerContext for more
|
|
39
|
-
* details.
|
|
40
|
-
*/
|
|
41
|
-
/** @deprecated See IContainerContext for more details. */
|
|
42
|
-
get logger() {
|
|
43
|
-
return this.taggedLogger;
|
|
44
|
-
}
|
|
45
38
|
get clientId() {
|
|
46
39
|
return this.container.clientId;
|
|
47
40
|
}
|
|
41
|
+
/** @deprecated Added back to unblock 0.56 integration */
|
|
42
|
+
get id() {
|
|
43
|
+
const resolvedUrl = this.container.resolvedUrl;
|
|
44
|
+
if (isFluidResolvedUrl(resolvedUrl)) {
|
|
45
|
+
return resolvedUrl.id;
|
|
46
|
+
}
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
48
49
|
get clientDetails() {
|
|
49
50
|
return this.container.clientDetails;
|
|
50
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAQH,WAAW,GAKd,MAAM,uCAAuC,CAAC;AAe/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAInE,MAAM,sBAAsB,GAAG,iDAAiD,CAAC;AAEjF,MAAM,OAAO,gBAAgB;IA4GzB,YACqB,SAAoB,EACrB,KAAiC,EAChC,UAA4C,EAC5C,YAA+B,EAC/B,aAAwC,EACzC,YAAwE,EACxF,MAAe,EACC,MAAe,EACf,qBAA0D,EAC1D,QAAoF,EACpF,cAAuC,EACvC,OAAkD,EAClD,OAAe,EACf,yBAAmD,EACnD,QAAiB,EACjB,iBAA2B;QAf1B,cAAS,GAAT,SAAS,CAAW;QACrB,UAAK,GAAL,KAAK,CAA4B;QAChC,eAAU,GAAV,UAAU,CAAkC;QAC5C,iBAAY,GAAZ,YAAY,CAAmB;QAC/B,kBAAa,GAAb,aAAa,CAA2B;QACzC,iBAAY,GAAZ,YAAY,CAA4D;QAExE,WAAM,GAAN,MAAM,CAAS;QACf,0BAAqB,GAArB,qBAAqB,CAAqC;QAC1D,aAAQ,GAAR,QAAQ,CAA4E;QACpF,mBAAc,GAAd,cAAc,CAAyB;QACvC,YA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reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IFluidObject,\n IRequest,\n IResponse,\n IFluidCodeDetails,\n IFluidCodeDetailsComparer,\n IProvideFluidCodeDetailsComparer,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IAudience,\n IContainerContext,\n IDeltaManager,\n ILoader,\n IRuntime,\n ICriticalContainerError,\n ContainerWarning,\n AttachState,\n ILoaderOptions,\n IRuntimeFactory,\n ICodeLoader,\n IProvideRuntimeFactory,\n} from \"@fluidframework/container-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n IClientConfiguration,\n IClientDetails,\n IDocumentMessage,\n IQuorum,\n IQuorumClients,\n ISequencedDocumentMessage,\n ISignalMessage,\n ISnapshotTree,\n ISummaryTree,\n IVersion,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport { Container } from \"./container\";\nimport { ICodeDetailsLoader, IFluidModuleWithDetails } from \"./loader\";\n\nconst PackageNotFactoryError = \"Code package does not implement IRuntimeFactory\";\n\nexport class ContainerContext implements IContainerContext {\n public static async createOrLoad(\n container: Container,\n scope: FluidObject,\n codeLoader: ICodeDetailsLoader | ICodeLoader,\n codeDetails: IFluidCodeDetails,\n baseSnapshot: ISnapshotTree | undefined,\n deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n loader: ILoader,\n raiseContainerWarning: (warning: ContainerWarning) => void,\n submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n submitSignalFn: (contents: any) => void,\n closeFn: (error?: ICriticalContainerError) => void,\n version: string,\n updateDirtyContainerState: (dirty: boolean) => void,\n existing: boolean,\n pendingLocalState?: unknown,\n ): Promise<ContainerContext> {\n const context = new ContainerContext(\n container,\n scope,\n codeLoader,\n codeDetails,\n baseSnapshot,\n deltaManager,\n quorum,\n loader,\n raiseContainerWarning,\n submitFn,\n submitSignalFn,\n closeFn,\n version,\n updateDirtyContainerState,\n existing,\n pendingLocalState);\n await context.instantiateRuntime(existing);\n return context;\n }\n\n public readonly taggedLogger: ITelemetryLogger;\n\n /**\n * Subtlety: returns this.taggedLogger since vanilla this.logger is now deprecated. See IContainerContext for more\n * details.\n */\n /** @deprecated See IContainerContext for more details. */\n public get logger(): ITelemetryLogger {\n return this.taggedLogger;\n }\n\n public get clientId(): string | undefined {\n return this.container.clientId;\n }\n\n public get clientDetails(): IClientDetails {\n return this.container.clientDetails;\n }\n\n public get connected(): boolean {\n return this.container.connected;\n }\n\n public get canSummarize(): boolean {\n return \"summarize\" in this.runtime;\n }\n\n public get serviceConfiguration(): IClientConfiguration | undefined {\n return this.container.serviceConfiguration;\n }\n\n public get audience(): IAudience {\n return this.container.audience;\n }\n\n public get options(): ILoaderOptions {\n return this.container.options;\n }\n\n public get baseSnapshot() {\n return this._baseSnapshot;\n }\n\n public get storage(): IDocumentStorageService {\n return this.container.storage;\n }\n\n private _runtime: IRuntime | undefined;\n private get runtime() {\n if (this._runtime === undefined) {\n throw new Error(\"Attempted to access runtime before it was defined\");\n }\n return this._runtime;\n }\n\n private _disposed = false;\n\n public get disposed() {\n return this._disposed;\n }\n\n public get codeDetails() { return this._codeDetails; }\n\n private readonly _quorum: IQuorum;\n public get quorum(): IQuorumClients { return this._quorum; }\n\n private readonly _fluidModuleP: Promise<IFluidModuleWithDetails>;\n\n constructor(\n private readonly container: Container,\n public readonly scope: IFluidObject & FluidObject,\n private readonly codeLoader: ICodeDetailsLoader | ICodeLoader,\n private readonly _codeDetails: IFluidCodeDetails,\n private readonly _baseSnapshot: ISnapshotTree | undefined,\n public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n public readonly loader: ILoader,\n public readonly raiseContainerWarning: (warning: ContainerWarning) => void,\n public readonly submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n public readonly submitSignalFn: (contents: any) => void,\n public readonly closeFn: (error?: ICriticalContainerError) => void,\n public readonly version: string,\n public readonly updateDirtyContainerState: (dirty: boolean) => void,\n public readonly existing: boolean,\n public readonly pendingLocalState?: unknown,\n\n ) {\n this._quorum = quorum;\n this.taggedLogger = container.subLogger;\n this._fluidModuleP = new LazyPromise<IFluidModuleWithDetails>(\n async () => this.loadCodeModule(_codeDetails),\n );\n this.attachListener();\n }\n\n /**\n * @deprecated - Temporary migratory API, to be removed when customers no longer need it. When removed,\n * ContainerContext should only take an IQuorumClients rather than an IQuorum. See IContainerContext for more\n * details.\n */\n public getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n return (this._quorum.get(\"code\") ?? this._quorum.get(\"code2\")) as IFluidCodeDetails | undefined;\n }\n\n public dispose(error?: Error): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.runtime.dispose(error);\n this._quorum.dispose();\n this.deltaManager.dispose();\n }\n\n public getLoadedFromVersion(): IVersion | undefined {\n return this.container.loadedFromVersion;\n }\n\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * Create a summary. Used when attaching or serializing a detached container.\n *\n * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n * new storage IDs so requests can be redirected.\n */\n public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n return this.runtime.createSummary(blobRedirectTable);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n const runtime = this.runtime;\n\n assert(connected === this.connected, 0x0de /* \"Mismatch in connection state while setting\" */);\n\n runtime.setConnectionState(connected, clientId);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, context: any) {\n this.runtime.process(message, local, context);\n }\n\n public processSignal(message: ISignalMessage, local: boolean) {\n this.runtime.processSignal(message, local);\n }\n\n public async request(path: IRequest): Promise<IResponse> {\n return this.runtime.request(path);\n }\n\n public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n return this.container.getAbsoluteUrl(relativeUrl);\n }\n\n public getPendingLocalState(): unknown {\n return this.runtime.getPendingLocalState();\n }\n\n /**\n * Determines if the current code details of the context\n * satisfy the incoming constraint code details\n */\n public async satisfies(constraintCodeDetails: IFluidCodeDetails) {\n const comparers: IFluidCodeDetailsComparer[] = [];\n\n const maybeCompareCodeLoader = this.codeLoader;\n if (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);\n }\n\n const moduleWithDetails = await this._fluidModuleP;\n const maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =\n moduleWithDetails.module?.fluidExport;\n if (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);\n }\n\n // if there are not comparers it is not possible to know\n // if the current satisfy the incoming, so return false,\n // as assuming they do not satisfy is safer .e.g we will\n // reload, rather than potentially running with\n // incompatible code\n if (comparers.length === 0) {\n return false;\n }\n\n for (const comparer of comparers) {\n const satisfies = await comparer.satisfies(\n moduleWithDetails.details,\n constraintCodeDetails,\n );\n if (satisfies === false) {\n return false;\n }\n }\n return true;\n }\n\n public notifyAttaching() {\n this.runtime.setAttachState(AttachState.Attaching);\n }\n\n // #region private\n\n private async getRuntimeFactory(): Promise<IRuntimeFactory> {\n const fluidExport: FluidObject<IProvideRuntimeFactory> | undefined =\n (await this._fluidModuleP).module?.fluidExport;\n const runtimeFactory = fluidExport?.IRuntimeFactory;\n if (runtimeFactory === undefined) {\n throw new Error(PackageNotFactoryError);\n }\n\n return runtimeFactory;\n }\n\n private async instantiateRuntime(existing: boolean) {\n const runtimeFactory = await this.getRuntimeFactory();\n this._runtime = await runtimeFactory.instantiateRuntime(this, existing);\n }\n\n private attachListener() {\n this.container.once(\"attached\", () => {\n this.runtime.setAttachState(AttachState.Attached);\n });\n }\n\n private async loadCodeModule(codeDetails: IFluidCodeDetails) {\n const loadCodeResult = await PerformanceEvent.timedExecAsync(\n this.taggedLogger,\n { eventName: \"CodeLoad\" },\n async () => this.codeLoader.load(codeDetails),\n );\n\n if (\"module\" in loadCodeResult) {\n const { module, details } = loadCodeResult;\n return {\n module,\n details: details ?? codeDetails,\n };\n } else {\n return { module: loadCodeResult, details: codeDetails };\n }\n }\n // #endregion\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAQH,WAAW,GAKd,MAAM,uCAAuC,CAAC;AAe/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGlE,MAAM,sBAAsB,GAAG,iDAAiD,CAAC;AAEjF,MAAM,OAAO,gBAAgB;IA4GzB,YACqB,SAAoB,EACrB,KAAiC,EAChC,UAA4C,EAC5C,YAA+B,EAC/B,aAAwC,EACzC,YAAwE,EACxF,MAAe,EACC,MAAe,EACf,qBAA0D,EAC1D,QAAoF,EACpF,cAAuC,EACvC,OAAkD,EAClD,OAAe,EACf,yBAAmD,EACnD,QAAiB,EACjB,iBAA2B;QAf1B,cAAS,GAAT,SAAS,CAAW;QACrB,UAAK,GAAL,KAAK,CAA4B;QAChC,eAAU,GAAV,UAAU,CAAkC;QAC5C,iBAAY,GAAZ,YAAY,CAAmB;QAC/B,kBAAa,GAAb,aAAa,CAA2B;QACzC,iBAAY,GAAZ,YAAY,CAA4D;QAExE,WAAM,GAAN,MAAM,CAAS;QACf,0BAAqB,GAArB,qBAAqB,CAAqC;QAC1D,aAAQ,GAAR,QAAQ,CAA4E;QACpF,mBAAc,GAAd,cAAc,CAAyB;QACvC,YAAO,GAAP,OAAO,CAA2C;QAClD,YA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AW,EAAE,CAAC;SAC3D;IACL,CAAC;CAEJ","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 {\n IFluidObject,\n IRequest,\n IResponse,\n IFluidCodeDetails,\n IFluidCodeDetailsComparer,\n IProvideFluidCodeDetailsComparer,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IAudience,\n IContainerContext,\n IDeltaManager,\n ILoader,\n IRuntime,\n ICriticalContainerError,\n ContainerWarning,\n AttachState,\n ILoaderOptions,\n IRuntimeFactory,\n ICodeLoader,\n IProvideRuntimeFactory,\n} from \"@fluidframework/container-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n IClientConfiguration,\n IClientDetails,\n IDocumentMessage,\n IQuorum,\n IQuorumClients,\n ISequencedDocumentMessage,\n ISignalMessage,\n ISnapshotTree,\n ISummaryTree,\n IVersion,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport { Container } from \"./container\";\nimport { isFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport { ICodeDetailsLoader, IFluidModuleWithDetails } from \"./loader\";\n\nconst PackageNotFactoryError = \"Code package does not implement IRuntimeFactory\";\n\nexport class ContainerContext implements IContainerContext {\n public static async createOrLoad(\n container: Container,\n scope: FluidObject,\n codeLoader: ICodeDetailsLoader | ICodeLoader,\n codeDetails: IFluidCodeDetails,\n baseSnapshot: ISnapshotTree | undefined,\n deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n loader: ILoader,\n raiseContainerWarning: (warning: ContainerWarning) => void,\n submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n submitSignalFn: (contents: any) => void,\n closeFn: (error?: ICriticalContainerError) => void,\n version: string,\n updateDirtyContainerState: (dirty: boolean) => void,\n existing: boolean,\n pendingLocalState?: unknown,\n ): Promise<ContainerContext> {\n const context = new ContainerContext(\n container,\n scope,\n codeLoader,\n codeDetails,\n baseSnapshot,\n deltaManager,\n quorum,\n loader,\n raiseContainerWarning,\n submitFn,\n submitSignalFn,\n closeFn,\n version,\n updateDirtyContainerState,\n existing,\n pendingLocalState);\n await context.instantiateRuntime(existing);\n return context;\n }\n\n public readonly taggedLogger: ITelemetryLogger;\n\n public get clientId(): string | undefined {\n return this.container.clientId;\n }\n\n /** @deprecated Added back to unblock 0.56 integration */\n public get id(): string {\n const resolvedUrl = this.container.resolvedUrl;\n if (isFluidResolvedUrl(resolvedUrl)) {\n return resolvedUrl.id;\n }\n return \"\";\n }\n\n public get clientDetails(): IClientDetails {\n return this.container.clientDetails;\n }\n\n public get connected(): boolean {\n return this.container.connected;\n }\n\n public get canSummarize(): boolean {\n return \"summarize\" in this.runtime;\n }\n\n public get serviceConfiguration(): IClientConfiguration | undefined {\n return this.container.serviceConfiguration;\n }\n\n public get audience(): IAudience {\n return this.container.audience;\n }\n\n public get options(): ILoaderOptions {\n return this.container.options;\n }\n\n public get baseSnapshot() {\n return this._baseSnapshot;\n }\n\n public get storage(): IDocumentStorageService {\n return this.container.storage;\n }\n\n private _runtime: IRuntime | undefined;\n private get runtime() {\n if (this._runtime === undefined) {\n throw new Error(\"Attempted to access runtime before it was defined\");\n }\n return this._runtime;\n }\n\n private _disposed = false;\n\n public get disposed() {\n return this._disposed;\n }\n\n public get codeDetails() { return this._codeDetails; }\n\n private readonly _quorum: IQuorum;\n public get quorum(): IQuorumClients { return this._quorum; }\n\n private readonly _fluidModuleP: Promise<IFluidModuleWithDetails>;\n\n constructor(\n private readonly container: Container,\n public readonly scope: IFluidObject & FluidObject,\n private readonly codeLoader: ICodeDetailsLoader | ICodeLoader,\n private readonly _codeDetails: IFluidCodeDetails,\n private readonly _baseSnapshot: ISnapshotTree | undefined,\n public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n public readonly loader: ILoader,\n public readonly raiseContainerWarning: (warning: ContainerWarning) => void,\n public readonly submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n public readonly submitSignalFn: (contents: any) => void,\n public readonly closeFn: (error?: ICriticalContainerError) => void,\n public readonly version: string,\n public readonly updateDirtyContainerState: (dirty: boolean) => void,\n public readonly existing: boolean,\n public readonly pendingLocalState?: unknown,\n\n ) {\n this._quorum = quorum;\n this.taggedLogger = container.subLogger;\n this._fluidModuleP = new LazyPromise<IFluidModuleWithDetails>(\n async () => this.loadCodeModule(_codeDetails),\n );\n this.attachListener();\n }\n\n /**\n * @deprecated - Temporary migratory API, to be removed when customers no longer need it. When removed,\n * ContainerContext should only take an IQuorumClients rather than an IQuorum. See IContainerContext for more\n * details.\n */\n public getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n return (this._quorum.get(\"code\") ?? this._quorum.get(\"code2\")) as IFluidCodeDetails | undefined;\n }\n\n public dispose(error?: Error): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.runtime.dispose(error);\n this._quorum.dispose();\n this.deltaManager.dispose();\n }\n\n public getLoadedFromVersion(): IVersion | undefined {\n return this.container.loadedFromVersion;\n }\n\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * Create a summary. Used when attaching or serializing a detached container.\n *\n * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n * new storage IDs so requests can be redirected.\n */\n public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n return this.runtime.createSummary(blobRedirectTable);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n const runtime = this.runtime;\n\n assert(connected === this.connected, 0x0de /* \"Mismatch in connection state while setting\" */);\n\n runtime.setConnectionState(connected, clientId);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, context: any) {\n this.runtime.process(message, local, context);\n }\n\n public processSignal(message: ISignalMessage, local: boolean) {\n this.runtime.processSignal(message, local);\n }\n\n public async request(path: IRequest): Promise<IResponse> {\n return this.runtime.request(path);\n }\n\n public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n return this.container.getAbsoluteUrl(relativeUrl);\n }\n\n public getPendingLocalState(): unknown {\n return this.runtime.getPendingLocalState();\n }\n\n /**\n * Determines if the current code details of the context\n * satisfy the incoming constraint code details\n */\n public async satisfies(constraintCodeDetails: IFluidCodeDetails) {\n const comparers: IFluidCodeDetailsComparer[] = [];\n\n const maybeCompareCodeLoader = this.codeLoader;\n if (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);\n }\n\n const moduleWithDetails = await this._fluidModuleP;\n const maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =\n moduleWithDetails.module?.fluidExport;\n if (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);\n }\n\n // if there are not comparers it is not possible to know\n // if the current satisfy the incoming, so return false,\n // as assuming they do not satisfy is safer .e.g we will\n // reload, rather than potentially running with\n // incompatible code\n if (comparers.length === 0) {\n return false;\n }\n\n for (const comparer of comparers) {\n const satisfies = await comparer.satisfies(\n moduleWithDetails.details,\n constraintCodeDetails,\n );\n if (satisfies === false) {\n return false;\n }\n }\n return true;\n }\n\n public notifyAttaching() {\n this.runtime.setAttachState(AttachState.Attaching);\n }\n\n // #region private\n\n private async getRuntimeFactory(): Promise<IRuntimeFactory> {\n const fluidExport: FluidObject<IProvideRuntimeFactory> | undefined =\n (await this._fluidModuleP).module?.fluidExport;\n const runtimeFactory = fluidExport?.IRuntimeFactory;\n if (runtimeFactory === undefined) {\n throw new Error(PackageNotFactoryError);\n }\n\n return runtimeFactory;\n }\n\n private async instantiateRuntime(existing: boolean) {\n const runtimeFactory = await this.getRuntimeFactory();\n this._runtime = await runtimeFactory.instantiateRuntime(this, existing);\n }\n\n private attachListener() {\n this.container.once(\"attached\", () => {\n this.runtime.setAttachState(AttachState.Attached);\n });\n }\n\n private async loadCodeModule(codeDetails: IFluidCodeDetails) {\n const loadCodeResult = await PerformanceEvent.timedExecAsync(\n this.taggedLogger,\n { eventName: \"CodeLoad\" },\n async () => this.codeLoader.load(codeDetails),\n );\n\n if (\"module\" in loadCodeResult) {\n const { module, details } = loadCodeResult;\n return {\n module,\n details: details ?? codeDetails,\n };\n } else {\n return { module: loadCodeResult, details: codeDetails };\n }\n }\n // #endregion\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaManager.d.ts","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,kBAAkB,EAErB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMzE,OAAO,EAEH,gBAAgB,EAEnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"deltaManager.d.ts","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,kBAAkB,EAErB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAU,iBAAiB,EAAE,MAA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{ isSystemMessage } from "@fluidframework/protocol-base";
|
|
11
11
|
import { MessageType, } from "@fluidframework/protocol-definitions";
|
|
12
12
|
import { NonRetryableError, } from "@fluidframework/driver-utils";
|
|
13
|
-
import { ThrottlingWarning,
|
|
13
|
+
import { ThrottlingWarning, DataCorruptionError, extractSafePropertiesFromMessage, DataProcessingError, } from "@fluidframework/container-utils";
|
|
14
14
|
import { DeltaQueue } from "./deltaQueue";
|
|
15
|
+
import { TelemetryDataTag } from "@fluidframework/telemetry-utils";
|
|
15
16
|
/**
|
|
16
17
|
* Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta
|
|
17
18
|
* messages in order regardless of possible network conditions or timings causing out of order delivery.
|
|
@@ -60,7 +61,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
60
61
|
this.processInboundMessage(op);
|
|
61
62
|
});
|
|
62
63
|
this._inbound.on("error", (error) => {
|
|
63
|
-
this.close(
|
|
64
|
+
this.close(DataProcessingError.wrapIfUnrecognized(error, "deltaManagerInboundErrorHandler", this.lastMessage));
|
|
64
65
|
});
|
|
65
66
|
// Inbound signal queue
|
|
66
67
|
this._inboundSignal = new DeltaQueue((message) => {
|
|
@@ -123,19 +124,10 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
123
124
|
get readOnlyInfo() { return this.connectionManager.readOnlyInfo; }
|
|
124
125
|
get clientDetails() { return this.connectionManager.clientDetails; }
|
|
125
126
|
submit(type, contents, batch = false, metadata) {
|
|
126
|
-
// Start adding trace for the op.
|
|
127
|
-
const traces = [
|
|
128
|
-
{
|
|
129
|
-
action: "start",
|
|
130
|
-
service: "client",
|
|
131
|
-
timestamp: Date.now(),
|
|
132
|
-
}
|
|
133
|
-
];
|
|
134
127
|
const messagePartial = {
|
|
135
128
|
contents: JSON.stringify(contents),
|
|
136
129
|
metadata,
|
|
137
130
|
referenceSequenceNumber: this.lastProcessedSequenceNumber,
|
|
138
|
-
traces,
|
|
139
131
|
type,
|
|
140
132
|
};
|
|
141
133
|
if (!batch) {
|
|
@@ -388,9 +380,13 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
388
380
|
// DeltaManager overall policy - drop all ops on disconnection and rely on
|
|
389
381
|
// container runtime to deal with resubmitting any ops that did not make it through.
|
|
390
382
|
// So drop them, but also raise error event to look into details.
|
|
391
|
-
this.logger.
|
|
383
|
+
this.logger.sendTelemetryEvent({
|
|
392
384
|
eventName: "OpenBatchOnDisconnect",
|
|
393
385
|
length: this.messageBuffer.length,
|
|
386
|
+
reason: {
|
|
387
|
+
value: reason,
|
|
388
|
+
tag: TelemetryDataTag.PackageData,
|
|
389
|
+
}
|
|
394
390
|
});
|
|
395
391
|
this.messageBuffer.length = 0;
|
|
396
392
|
}
|
|
@@ -407,7 +403,7 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
407
403
|
this.throttlingIdSet.add(id);
|
|
408
404
|
if (delayMs > 0 && (timeNow + delayMs > this.timeTillThrottling)) {
|
|
409
405
|
this.timeTillThrottling = timeNow + delayMs;
|
|
410
|
-
const throttlingWarning = ThrottlingWarning.wrap(error,
|
|
406
|
+
const throttlingWarning = ThrottlingWarning.wrap(error, delayMs / 1000 /* retryAfterSeconds */, this.logger);
|
|
411
407
|
this.emit("throttled", throttlingWarning);
|
|
412
408
|
}
|
|
413
409
|
}
|
|
@@ -497,7 +493,9 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
497
493
|
const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);
|
|
498
494
|
const message2 = this.comparableMessagePayload(message);
|
|
499
495
|
if (message1 !== message2) {
|
|
500
|
-
|
|
496
|
+
// This looks like a data corruption but the culprit has been found instead
|
|
497
|
+
// to be the file being overwritten in storage. See PR #5882.
|
|
498
|
+
const error = new NonRetryableError("Found two messages with the same sequenceNumber but different payloads", DriverErrorType.fileOverwrittenInStorage, {
|
|
501
499
|
clientId: this.connectionManager.clientId,
|
|
502
500
|
sequenceNumber: message.sequenceNumber,
|
|
503
501
|
message1,
|
|
@@ -537,21 +535,13 @@ export class DeltaManager extends TypedEventEmitter {
|
|
|
537
535
|
message.contents = JSON.parse(message.contents);
|
|
538
536
|
}
|
|
539
537
|
this.connectionManager.beforeProcessingIncomingOp(message);
|
|
540
|
-
// Add final ack trace.
|
|
541
|
-
if (message.traces !== undefined && message.traces.length > 0) {
|
|
542
|
-
message.traces.push({
|
|
543
|
-
action: "end",
|
|
544
|
-
service: "client",
|
|
545
|
-
timestamp: Date.now(),
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
538
|
// Watch the minimum sequence number and be ready to update as needed
|
|
549
539
|
if (this.minSequenceNumber > message.minimumSequenceNumber) {
|
|
550
|
-
throw new DataCorruptionError("
|
|
540
|
+
throw new DataCorruptionError("Found a lower minimumSequenceNumber (msn) than previously recorded", Object.assign(Object.assign({}, extractSafePropertiesFromMessage(message)), { clientId: this.connectionManager.clientId }));
|
|
551
541
|
}
|
|
552
542
|
this.minSequenceNumber = message.minimumSequenceNumber;
|
|
553
543
|
if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {
|
|
554
|
-
throw new DataCorruptionError("
|
|
544
|
+
throw new DataCorruptionError("Found a non-Sequential sequenceNumber", Object.assign(Object.assign({}, extractSafePropertiesFromMessage(message)), { clientId: this.connectionManager.clientId }));
|
|
555
545
|
}
|
|
556
546
|
this.lastProcessedSequenceNumber = message.sequenceNumber;
|
|
557
547
|
// a bunch of code assumes that this is true
|
package/lib/deltaManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaManager.js","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAgBlC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACH,cAAc,EAC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,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QACvF,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,+EAA+E;QAC/E,2CAA2C;QAC3C,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,GAAG,MAAM,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAE/E,wFAAwF;QACxF,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;YAChC,mCAAmC;YACnC,yFAAyF;YACzF,2EAA2E;YAC3E,gGAAgG;YAChG,iGAAiG;YACjG,qGAAqG;YACrG,wFAAwF;YACxF,uGAAuG;YACvG,kGAAkG;YAClG,iGAAiG;YACjG,YAAY;YACZ,IAAI,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE;gBAC5D,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;aACxC;SACJ;IACL,CAAC;IAEO,4BAA4B,CAAC,GAAW;QAC5C,IAAI,IAAI,CAAC,qBAAqB,GAAG,GAAG,EAAE;YAClC,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC;SACpC;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n ITelemetryLogger,\n IEventProvider,\n ITelemetryProperties,\n ITelemetryErrorEvent,\n} from \"@fluidframework/common-definitions\";\nimport {\n IDeltaHandlerStrategy,\n IDeltaManager,\n IDeltaManagerEvents,\n IDeltaQueue,\n ICriticalContainerError,\n IThrottlingWarning,\n IConnectionDetails,\n} from \"@fluidframework/container-definitions\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n normalizeError,\n logIfFalse,\n safeRaiseEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { isSystemMessage } from \"@fluidframework/protocol-base\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISignalMessage,\n MessageType,\n ITrace,\n ConnectionMode,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n NonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport {\n ThrottlingWarning,\n CreateProcessingError,\n DataCorruptionError,\n extractSafePropertiesFromMessage,\n} from \"@fluidframework/container-utils\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport {\n IConnectionManagerFactoryArgs,\n IConnectionManager,\n } from \"./contracts\";\n\nexport interface IConnectionArgs {\n mode?: ConnectionMode;\n fetchOpsFromStorage?: boolean;\n reason: string;\n}\n\n/**\n * Includes events emitted by the concrete implementation DeltaManager\n * but not exposed on the public interface IDeltaManager\n */\nexport interface IDeltaManagerInternalEvents extends IDeltaManagerEvents {\n (event: \"throttled\", listener: (error: IThrottlingWarning) => void);\n (event: \"closed\", listener: (error?: ICriticalContainerError) => void);\n}\n\n/**\n * Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta\n * messages in order regardless of possible network conditions or timings causing out of order delivery.\n */\nexport class DeltaManager<TConnectionManager extends IConnectionManager>\n extends TypedEventEmitter<IDeltaManagerInternalEvents>\n implements\n IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n IEventProvider<IDeltaManagerInternalEvents>\n{\n public readonly connectionManager: TConnectionManager;\n\n public get active(): boolean { return this._active(); }\n\n public get disposed() { return this.closed; }\n\n public get IDeltaSender() { return this; }\n\n private pending: ISequencedDocumentMessage[] = [];\n private fetchReason: string | undefined;\n\n // The minimum sequence number and last sequence number received from the server\n private minSequenceNumber: number = 0;\n\n // There are three numbers we track\n // * lastQueuedSequenceNumber is the last queued sequence number. If there are gaps in seq numbers, then this number\n // is not updated until we cover that gap, so it increases each time by 1.\n // * lastObservedSeqNumber is an estimation of last known sequence number for container in storage. It's initially\n // populated at web socket connection time (if storage provides that info) and is updated once ops shows up.\n // It's never less than lastQueuedSequenceNumber\n // * lastProcessedSequenceNumber - last processed sequence number\n private lastQueuedSequenceNumber: number = 0;\n private lastObservedSeqNumber: number = 0;\n private lastProcessedSequenceNumber: number = 0;\n private lastProcessedMessage: ISequencedDocumentMessage | undefined;\n private baseTerm: number = 0;\n\n private prevEnqueueMessagesReason: string | undefined;\n private previouslyProcessedMessage: ISequencedDocumentMessage | undefined;\n\n // The sequence number we initially loaded from\n private initSequenceNumber: number = 0;\n\n private readonly _inbound: DeltaQueue<ISequencedDocumentMessage>;\n private readonly _inboundSignal: DeltaQueue<ISignalMessage>;\n\n private closed = false;\n\n private handler: IDeltaHandlerStrategy | undefined;\n private deltaStorage: IDocumentDeltaStorageService | undefined;\n\n private readonly throttlingIdSet = new Set<string>();\n private timeTillThrottling: number = 0;\n\n private readonly closeAbortController = new AbortController();\n\n private readonly deltaStorageDelayId = uuid();\n private readonly deltaStreamDelayId = uuid();\n\n private messageBuffer: IDocumentMessage[] = [];\n\n private _checkpointSequenceNumber: number | undefined;\n\n public get inbound(): IDeltaQueue<ISequencedDocumentMessage> {\n return this._inbound;\n }\n\n public get inboundSignal(): IDeltaQueue<ISignalMessage> {\n return this._inboundSignal;\n }\n\n public get initialSequenceNumber(): number {\n return this.initSequenceNumber;\n }\n\n public get lastSequenceNumber(): number {\n return this.lastProcessedSequenceNumber;\n }\n\n public get lastMessage() {\n return this.lastProcessedMessage;\n }\n\n public get lastKnownSeqNumber() {\n return this.lastObservedSeqNumber;\n }\n\n public get referenceTerm(): number {\n return this.baseTerm;\n }\n\n public get minimumSequenceNumber(): number {\n return this.minSequenceNumber;\n }\n\n /**\n * Tells if current connection has checkpoint information.\n * I.e. we know how far behind the client was at the time of establishing connection\n */\n public get hasCheckpointSequenceNumber() {\n // Valid to be called only if we have active connection.\n assert(this.connectionManager.connected, 0x0df /* \"Missing active connection\" */);\n return this._checkpointSequenceNumber !== undefined;\n }\n\n // Forwarding connection manager properties / IDeltaManager implementation\n public get maxMessageSize(): number { return this.connectionManager.maxMessageSize; }\n public get version() { return this.connectionManager.version; }\n public get serviceConfiguration() { return this.connectionManager.serviceConfiguration; }\n public get outbound() { return this.connectionManager.outbound; }\n public get readOnlyInfo() { return this.connectionManager.readOnlyInfo; }\n public get clientDetails() { return this.connectionManager.clientDetails; }\n\n public submit(type: MessageType, contents: any, batch = false, metadata?: any) {\n // Start adding trace for the op.\n const traces: ITrace[] = [\n {\n action: \"start\",\n service: \"client\",\n timestamp: Date.now(),\n }];\n\n const messagePartial: Omit<IDocumentMessage, \"clientSequenceNumber\"> = {\n contents: JSON.stringify(contents),\n metadata,\n referenceSequenceNumber: this.lastProcessedSequenceNumber,\n traces,\n type,\n };\n\n if (!batch) {\n this.flush();\n }\n\n const message = this.connectionManager.prepareMessageToSend(messagePartial);\n if (message === undefined) {\n return -1;\n }\n\n this.messageBuffer.push(message);\n\n if (!batch) {\n this.flush();\n }\n\n this.emit(\"submitOp\", message);\n return message.clientSequenceNumber;\n }\n\n public submitSignal(content: any) { return this.connectionManager.submitSignal(content); }\n\n public flush() {\n if (this.messageBuffer.length === 0) {\n return;\n }\n\n // The prepareFlush event allows listeners to append metadata to the batch prior to submission.\n this.emit(\"prepareSend\", this.messageBuffer);\n\n this.connectionManager.sendMessages(this.messageBuffer);\n this.messageBuffer = [];\n }\n\n public get connectionProps(): ITelemetryProperties {\n return {\n sequenceNumber: this.lastSequenceNumber,\n ...this.connectionManager.connectionProps,\n };\n }\n\n /**\n * Log error event with a bunch of internal to DeltaManager information about state of op processing\n * Used to diagnose connectivity issues related to op processing (i.e. cases where for some reason\n * we stop processing ops that results in no processing join op and thus moving to connected state)\n * @param event - Event to log.\n */\n public logConnectionIssue(event: ITelemetryErrorEvent) {\n assert(this.connectionManager.connected, 0x238 /* \"called only in connected state\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.logger.sendErrorEvent({\n ...event,\n // This directly tells us if fetching ops is in flight, and thus likely the reason of\n // stalled op processing\n fetchReason: this.fetchReason,\n // A bunch of useful sequence numbers to understand if we are holding some ops from processing\n lastQueuedSequenceNumber: this.lastQueuedSequenceNumber, // last sequential op\n lastProcessedSequenceNumber: this.lastProcessedSequenceNumber, // same as above, but after processing\n lastObserved: this.lastObservedSeqNumber, // last sequence we ever saw; may have gaps with above.\n // connection info\n ...this.connectionManager.connectionVerboseProps,\n pendingOps: this.pending.length, // Do we have any pending ops?\n pendingFirst: pendingSorted[0]?.sequenceNumber, // is the first pending op the one that we are missing?\n haveHandler: this.handler !== undefined, // do we have handler installed?\n inboundLength: this.inbound.length,\n inboundPaused: this.inbound.paused,\n });\n }\n\n constructor(\n private readonly serviceProvider: () => IDocumentService | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly _active: () => boolean,\n createConnectionManager: (props: IConnectionManagerFactoryArgs) => TConnectionManager,\n ) {\n super();\n const props: IConnectionManagerFactoryArgs = {\n incomingOpHandler:(messages: ISequencedDocumentMessage[], reason: string) =>\n this.enqueueMessages(messages, reason),\n signalHandler: (message: ISignalMessage) => this._inboundSignal.push(message),\n reconnectionDelayHandler: (delayMs: number, error: unknown) =>\n this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),\n closeHandler: (error: any) => this.close(error),\n disconnectHandler: (reason: string) => this.disconnectHandler(reason),\n connectHandler: (connection: IConnectionDetails) => this.connectHandler(connection),\n pongHandler: (latency: number) => this.emit(\"pong\", latency),\n readonlyChangeHandler: (readonly?: boolean) => safeRaiseEvent(this, this.logger, \"readonly\", readonly),\n };\n\n this.connectionManager = createConnectionManager(props);\n\n this._inbound = new DeltaQueue<ISequencedDocumentMessage>(\n (op) => {\n this.processInboundMessage(op);\n });\n\n this._inbound.on(\"error\", (error) => {\n this.close(CreateProcessingError(error, \"deltaManagerInboundErrorHandler\", this.lastMessage));\n });\n\n // Inbound signal queue\n this._inboundSignal = new DeltaQueue<ISignalMessage>((message) => {\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound signal without a handler attached\");\n }\n this.handler.processSignal({\n clientId: message.clientId,\n content: JSON.parse(message.content as string),\n });\n });\n\n this._inboundSignal.on(\"error\", (error) => {\n this.close(normalizeError(error));\n });\n\n // Initially, all queues are created paused.\n // - outbound is flipped back and forth in setupNewSuccessfulConnection / disconnectFromDeltaStream\n // - inbound & inboundSignal are resumed in attachOpHandler() when we have handler setup\n }\n\n private connectHandler(connection: IConnectionDetails) {\n this.refreshDelayInfo(this.deltaStreamDelayId);\n\n const props = this.connectionManager.connectionVerboseProps;\n props.connectionLastQueuedSequenceNumber = this.lastQueuedSequenceNumber;\n props.connectionLastObservedSeqNumber = this.lastObservedSeqNumber;\n\n const checkpointSequenceNumber = connection.checkpointSequenceNumber;\n this._checkpointSequenceNumber = checkpointSequenceNumber;\n if (checkpointSequenceNumber !== undefined) {\n this.updateLatestKnownOpSeqNumber(checkpointSequenceNumber);\n }\n\n // We cancel all ops on lost of connectivity, and rely on DDSes to resubmit them.\n // Semantics are not well defined for batches (and they are broken right now on disconnects anyway),\n // but it's safe to assume (until better design is put into place) that batches should not exist\n // across multiple connections. Right now we assume runtime will not submit any ops in disconnected\n // state. As requirements change, so should these checks.\n assert(this.messageBuffer.length === 0, 0x0e9 /* \"messageBuffer is not empty on new connection\" */);\n\n this.emit(\n \"connect\",\n connection,\n checkpointSequenceNumber !== undefined ?\n this.lastObservedSeqNumber - this.lastSequenceNumber : undefined);\n\n // If we got some initial ops, then we know the gap and call above fetched ops to fill it.\n // Same is true for \"write\" mode even if we have no ops - we will get \"join\" own op very very soon.\n // However if we are connecting as view-only, then there is no good signal to realize if client is behind.\n // Thus we have to hit storage to see if any ops are there.\n if (checkpointSequenceNumber !== undefined) {\n // We know how far we are behind (roughly). If it's non-zero gap, fetch ops right away.\n if (checkpointSequenceNumber > this.lastQueuedSequenceNumber) {\n this.fetchMissingDeltas(\"AfterConnection\");\n }\n // we do not know the gap, and we will not learn about it if socket is quite - have to ask.\n } else if (connection.mode === \"read\") {\n this.fetchMissingDeltas(\"AfterReadConnection\");\n }\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Sets the sequence number from which inbound messages should be returned\n */\n public async attachOpHandler(\n minSequenceNumber: number,\n sequenceNumber: number,\n term: number,\n handler: IDeltaHandlerStrategy,\n prefetchType: \"cached\" | \"all\" | \"none\" = \"none\",\n ) {\n this.initSequenceNumber = sequenceNumber;\n this.lastProcessedSequenceNumber = sequenceNumber;\n this.baseTerm = term;\n this.minSequenceNumber = minSequenceNumber;\n this.lastQueuedSequenceNumber = sequenceNumber;\n this.lastObservedSeqNumber = sequenceNumber;\n\n // We will use same check in other places to make sure all the seq number above are set properly.\n assert(this.handler === undefined, 0x0e2 /* \"DeltaManager already has attached op handler!\" */);\n this.handler = handler;\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n assert(!!(this.handler as any), 0x0e3 /* \"Newly set op handler is null/undefined!\" */);\n\n // There should be no pending fetch!\n // This API is called right after attachOpHandler by Container.load().\n // We might have connection already and it might have called fetchMissingDeltas() from\n // setupNewSuccessfulConnection. But it should do nothing, because there is no way to fetch ops before\n // we know snapshot sequence number that is set in attachOpHandler. So all such calls should be noop.\n assert(this.fetchReason === undefined, 0x268 /* \"There can't be pending fetch that early in boot sequence!\" */);\n\n if (this.closed) {\n return;\n }\n\n this._inbound.resume();\n this._inboundSignal.resume();\n\n if (prefetchType !== \"none\") {\n const cacheOnly = prefetchType === \"cached\";\n await this.fetchMissingDeltasCore(\"DocumentOpen\", cacheOnly, this.lastQueuedSequenceNumber);\n\n // Keep going with fetching ops from storage once we have all cached ops in.\n // But do not block load and make this request async / not blocking this api.\n // Ops processing will start once cached ops are in and and will stop when queue is empty\n // (which in most cases will happen when we are done processing cached ops)\n if (cacheOnly) {\n // fire and forget\n this.fetchMissingDeltas(\"DocumentOpen\");\n }\n }\n\n // Ensure there is no need to call this.processPendingOps() at the end of boot sequence\n assert(this.fetchReason !== undefined || this.pending.length === 0, 0x269 /* \"pending ops are not dropped\" */);\n }\n\n public connect(args: IConnectionArgs) {\n const fetchOpsFromStorage = args.fetchOpsFromStorage ?? true;\n logIfFalse(\n this.handler !== undefined || !fetchOpsFromStorage,\n this.logger,\n \"CantFetchWithoutBaseline\"); // can't fetch if no baseline\n\n // Note: There is race condition here.\n // We want to issue request to storage as soon as possible, to\n // reduce latency of becoming current, thus this code here.\n // But there is no ordering between fetching OPs and connection to delta stream\n // As result, we might be behind by the time we connect to delta stream\n // In case of r/w connection, that's not an issue, because we will hear our\n // own \"join\" message and realize any gap client has in ops.\n // But for view-only connection, we have no such signal, and with no traffic\n // on the wire, we might be always behind.\n // See comment at the end of \"connect\" handler\n if (fetchOpsFromStorage) {\n this.fetchMissingDeltas(args.reason);\n }\n\n this.connectionManager.connect(args.mode);\n }\n\n private async getDeltas(\n from: number, // inclusive\n to: number | undefined, // exclusive\n callback: (messages: ISequencedDocumentMessage[]) => void,\n cacheOnly: boolean)\n {\n const docService = this.serviceProvider();\n if (docService === undefined) {\n throw new Error(\"Delta manager is not attached\");\n }\n\n if (this.deltaStorage === undefined) {\n this.deltaStorage = await docService.connectToDeltaStorage();\n }\n\n let cancelFetch: (op: ISequencedDocumentMessage) => boolean;\n\n if (to !== undefined) {\n const lastExpectedOp = to - 1; // make it inclusive!\n\n // It is possible that due to asynchrony (including await above), required ops were already\n // received through delta stream. Validate that before moving forward.\n if (this.lastQueuedSequenceNumber >= lastExpectedOp) {\n this.logger.sendPerformanceEvent({\n reason: this.fetchReason,\n eventName: \"ExtraStorageCall\",\n early: true,\n from,\n to,\n ...this.connectionManager.connectionVerboseProps,\n });\n return;\n }\n\n // Be prepared for the case where webSocket would receive the ops that we are trying to fill through\n // storage. Ideally it should never happen (i.e. ops on socket are always ordered, and thus once we\n // detected gap, this gap can't be filled in later on through websocket).\n // And in practice that does look like the case. The place where this code gets hit is if we lost\n // connection and reconnected (likely to another box), and new socket's initial ops contains these ops.\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= lastExpectedOp;\n } else {\n // Unbound requests are made to proactively fetch ops, but also get up to date in cases where socket\n // is silent (and connection is \"read\", thus we might not have any data on how far client is behind).\n // Once we have any op coming in from socket, we can cancel it as it's not needed any more.\n // That said, if we have socket connection, make sure we got ops up to checkpointSequenceNumber!\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= this.lastObservedSeqNumber;\n }\n\n const controller = new AbortController();\n let opsFromFetch = false;\n\n const opListener = (op: ISequencedDocumentMessage) => {\n assert(op.sequenceNumber === this.lastQueuedSequenceNumber, 0x23a /* \"seq#'s\" */);\n // Ops that are coming from this request should not cancel itself.\n // This is useless for known ranges (to is defined) as it means request is over either way.\n // And it will cancel unbound request too early, not allowing us to learn where the end of the file is.\n if (!opsFromFetch && cancelFetch(op)) {\n controller.abort();\n this._inbound.off(\"push\", opListener);\n }\n };\n\n try {\n this._inbound.on(\"push\", opListener);\n assert(this.closeAbortController.signal.onabort === null, 0x1e8 /* \"reentrancy\" */);\n this.closeAbortController.signal.onabort = () => controller.abort();\n\n const stream = this.deltaStorage.fetchMessages(\n from, // inclusive\n to, // exclusive\n controller.signal,\n cacheOnly,\n this.fetchReason);\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await stream.read();\n if (result.done) {\n break;\n }\n try {\n opsFromFetch = true;\n callback(result.value);\n } finally {\n opsFromFetch = false;\n }\n }\n } finally {\n this.closeAbortController.signal.onabort = null;\n this._inbound.off(\"push\", opListener);\n assert(!opsFromFetch, 0x289 /* \"logic error\" */);\n }\n }\n\n /**\n * Closes the connection and clears inbound & outbound queues.\n */\n public close(error?: ICriticalContainerError): void {\n if (this.closed) {\n return;\n }\n this.closed = true;\n\n this.connectionManager.dispose(error);\n\n this.closeAbortController.abort();\n\n this._inbound.clear();\n this._inboundSignal.clear();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inbound.pause();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inboundSignal.pause();\n\n // Drop pending messages - this will ensure catchUp() does not go into infinite loop\n this.pending = [];\n\n // This needs to be the last thing we do (before removing listeners), as it causes\n // Container to dispose context and break ability of data stores / runtime to \"hear\"\n // from delta manager, including notification (above) about readonly state.\n this.emit(\"closed\", error);\n\n this.removeAllListeners();\n }\n\n public refreshDelayInfo(id: string) {\n this.throttlingIdSet.delete(id);\n if (this.throttlingIdSet.size === 0) {\n this.timeTillThrottling = 0;\n }\n }\n\n private disconnectHandler(reason: string) {\n if (this.messageBuffer.length > 0) {\n // Behavior is not well defined here RE batches across connections / disconnect.\n // DeltaManager overall policy - drop all ops on disconnection and rely on\n // container runtime to deal with resubmitting any ops that did not make it through.\n // So drop them, but also raise error event to look into details.\n this.logger.sendErrorEvent({\n eventName: \"OpenBatchOnDisconnect\",\n length: this.messageBuffer.length,\n });\n this.messageBuffer.length = 0;\n }\n this.emit(\"disconnect\", reason);\n }\n\n /**\n * Emit info about a delay in service communication on account of throttling.\n * @param id - Id of the connection that is delayed\n * @param delayMs - Duration of the delay\n * @param error - error object indicating the throttling\n */\n public emitDelayInfo(id: string, delayMs: number, error: unknown) {\n const timeNow = Date.now();\n this.throttlingIdSet.add(id);\n if (delayMs > 0 && (timeNow + delayMs > this.timeTillThrottling)) {\n this.timeTillThrottling = timeNow + delayMs;\n\n const throttlingWarning: IThrottlingWarning = ThrottlingWarning.wrap(\n error,\n \"deltaManagerEmitDelayInfo\",\n delayMs / 1000 /* retryAfterSeconds */,\n this.logger,\n );\n this.emit(\"throttled\", throttlingWarning);\n }\n }\n\n // returns parts of message (in string format) that should never change for a given message.\n // Used for message comparison. It attempts to avoid comparing fields that potentially may differ.\n // for example, it's not clear if serverMetadata or timestamp property is a property of message or server state.\n // We only extract the most obvious fields that are sufficient (with high probability) to detect sequence number\n // reuse.\n // Also payload goes to telemetry, so no PII, including content!!\n // Note: It's possible for a duplicate op to be broadcasted and have everything the same except the timestamp.\n private comparableMessagePayload(m: ISequencedDocumentMessage) {\n return `${m.clientId}-${m.type}-${m.minimumSequenceNumber}-${m.referenceSequenceNumber}-${m.timestamp}`;\n }\n\n private enqueueMessages(\n messages: ISequencedDocumentMessage[],\n reason: string,\n allowGaps = false,\n ): void {\n if (this.handler === undefined) {\n // We did not setup handler yet.\n // This happens when we connect to web socket faster than we get attributes for container\n // and thus faster than attachOpHandler() is called\n // this.lastProcessedSequenceNumber is still zero, so we can't rely on this.fetchMissingDeltas()\n // to do the right thing.\n this.pending = this.pending.concat(messages);\n return;\n }\n\n // Pending ops should never just hang around for nothing.\n // This invariant will stay true through this function execution,\n // so there is no need to process pending ops here.\n // It's responsibility of\n // - attachOpHandler()\n // - fetchMissingDeltas() after it's done with querying storage\n assert(this.pending.length === 0 || this.fetchReason !== undefined, 0x1e9 /* \"Pending ops\" */);\n\n if (messages.length === 0) {\n return;\n }\n\n const from = messages[0].sequenceNumber;\n const last = messages[messages.length - 1].sequenceNumber;\n\n // Report stats about missing and duplicate ops\n // This helps better understand why we fetch ops from storage, and thus may delay\n // getting current / sending ops\n // It's possible that this batch is already too late - do not bother\n if (last > this.lastQueuedSequenceNumber) {\n let prev = from - 1;\n const initialGap = prev - this.lastQueuedSequenceNumber;\n let firstMissing: number | undefined;\n let duplicate = 0;\n let gap = 0;\n\n // Count all gaps and duplicates\n for (const message of messages) {\n if (message.sequenceNumber === prev) {\n duplicate++;\n } else if (message.sequenceNumber !== prev + 1) {\n gap++;\n if (firstMissing === undefined) {\n firstMissing = prev + 1;\n }\n }\n prev = message.sequenceNumber;\n }\n\n let eventName: string | undefined;\n\n // Report if we found some issues\n if (duplicate !== 0 || gap !== 0 && !allowGaps || initialGap > 0 && this.fetchReason === undefined) {\n eventName = \"enqueueMessages\";\n // Also report if we are fetching ops, and same range comes in, thus making this fetch obsolete.\n } else if (this.fetchReason !== undefined && this.fetchReason !== reason &&\n (from <= this.lastQueuedSequenceNumber + 1 && last > this.lastQueuedSequenceNumber)) {\n eventName = \"enqueueMessagesExtraFetch\";\n }\n\n // Report if there is something to report\n // Do not report when pending fetch is in progress, as such reporting will not\n // correctly take into account pending ops.\n if (eventName !== undefined) {\n this.logger.sendPerformanceEvent({\n eventName,\n reason,\n previousReason: this.prevEnqueueMessagesReason,\n from,\n to: last + 1, // exclusive, being consistent with the other telemetry / APIs\n length: messages.length,\n fetchReason: this.fetchReason,\n duplicate: duplicate > 0 ? duplicate : undefined,\n initialGap: initialGap !== 0 ? initialGap : undefined,\n gap: gap > 0 ? gap : undefined,\n firstMissing,\n dmInitialSeqNumber: this.initialSequenceNumber,\n ...this.connectionManager.connectionVerboseProps,\n });\n }\n }\n\n this.updateLatestKnownOpSeqNumber(messages[messages.length - 1].sequenceNumber);\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n assert(n === undefined || n === this.lastQueuedSequenceNumber,\n 0x0ec /* \"Unexpected value for previously processed message's sequence number\" */);\n\n for (const message of messages) {\n // Check that the messages are arriving in the expected order\n if (message.sequenceNumber <= this.lastQueuedSequenceNumber) {\n // Validate that we do not have data loss, i.e. sequencing is reset and started again\n // with numbers that this client already observed before.\n if (this.previouslyProcessedMessage?.sequenceNumber === message.sequenceNumber) {\n const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);\n const message2 = this.comparableMessagePayload(message);\n if (message1 !== message2) {\n const error = new NonRetryableError(\n \"twoMessagesWithSameSeqNumAndDifferentPayload\",\n undefined,\n DriverErrorType.fileOverwrittenInStorage,\n {\n clientId: this.connectionManager.clientId,\n sequenceNumber: message.sequenceNumber,\n message1,\n message2,\n driverVersion: undefined,\n },\n );\n this.close(error);\n }\n }\n } else if (message.sequenceNumber !== this.lastQueuedSequenceNumber + 1) {\n this.pending.push(message);\n this.fetchMissingDeltas(reason, message.sequenceNumber);\n } else {\n this.lastQueuedSequenceNumber = message.sequenceNumber;\n this.previouslyProcessedMessage = message;\n this._inbound.push(message);\n }\n }\n\n // When / if we report a gap in ops in the future, we want telemetry to correctly reflect source\n // of prior ops. But if we have some out of order ops (this.pending), then reporting current reason\n // becomes not accurate, as the gap existed before current batch, so we should just report \"unknown\".\n this.prevEnqueueMessagesReason = this.pending.length > 0 ? \"unknown\" : reason;\n }\n\n private processInboundMessage(message: ISequencedDocumentMessage): void {\n const startTime = Date.now();\n this.lastProcessedMessage = message;\n\n // All non-system messages are coming from some client, and should have clientId\n // System messages may have no clientId (but some do, like propose, noop, summarize)\n assert(\n message.clientId !== undefined\n || isSystemMessage(message),\n 0x0ed /* \"non-system message have to have clientId\" */,\n );\n\n // TODO Remove after SPO picks up the latest build.\n if (\n typeof message.contents === \"string\"\n && message.contents !== \"\"\n && message.type !== MessageType.ClientLeave\n ) {\n message.contents = JSON.parse(message.contents);\n }\n\n this.connectionManager.beforeProcessingIncomingOp(message);\n\n // Add final ack trace.\n if (message.traces !== undefined && message.traces.length > 0) {\n message.traces.push({\n action: \"end\",\n service: \"client\",\n timestamp: Date.now(),\n });\n }\n\n // Watch the minimum sequence number and be ready to update as needed\n if (this.minSequenceNumber > message.minimumSequenceNumber) {\n throw new DataCorruptionError(\"msnMovesBackwards\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.minSequenceNumber = message.minimumSequenceNumber;\n\n if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {\n throw new DataCorruptionError(\"nonSequentialSequenceNumber\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.lastProcessedSequenceNumber = message.sequenceNumber;\n\n // a bunch of code assumes that this is true\n assert(this.lastProcessedSequenceNumber <= this.lastObservedSeqNumber,\n 0x267 /* \"lastObservedSeqNumber should be updated first\" */);\n\n // Back-compat for older server with no term\n if (message.term === undefined) {\n message.term = 1;\n }\n this.baseTerm = message.term;\n\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound message without a handler attached\");\n }\n this.handler.process(message);\n\n const endTime = Date.now();\n\n // Should be last, after changing this.lastProcessedSequenceNumber above, as many callers\n // test this.lastProcessedSequenceNumber instead of using op.sequenceNumber itself.\n this.emit(\"op\", message, endTime - startTime);\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private fetchMissingDeltas(reasonArg: string, to?: number) {\n this.fetchMissingDeltasCore(reasonArg, false /* cacheOnly */, to).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"fetchMissingDeltasException\" }, error);\n });\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private async fetchMissingDeltasCore(\n reason: string,\n cacheOnly: boolean,\n to?: number)\n {\n // Exit out early if we're already fetching deltas\n if (this.fetchReason !== undefined) {\n return;\n }\n\n if (this.closed) {\n this.logger.sendTelemetryEvent({ eventName: \"fetchMissingDeltasClosedConnection\", reason });\n return;\n }\n\n if (this.handler === undefined) {\n // We do not poses yet any information\n assert(this.lastQueuedSequenceNumber === 0, 0x26b /* \"initial state\" */);\n return;\n }\n\n try {\n let from = this.lastQueuedSequenceNumber + 1;\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n if (n !== undefined) {\n // If we already processed at least one op, then we have this.previouslyProcessedMessage populated\n // and can use it to validate that we are operating on same file, i.e. it was not overwritten.\n // Knowing about this mechanism, we could ask for op we already observed to increase validation.\n // This is especially useful when coming out of offline mode or loading from\n // very old cached (by client / driver) snapshot.\n assert(n === this.lastQueuedSequenceNumber, 0x0f2 /* \"previouslyProcessedMessage\" */);\n assert(from > 1, 0x0f3 /* \"not positive\" */);\n from--;\n }\n\n const fetchReason = `${reason}_fetch`;\n this.fetchReason = fetchReason;\n\n await this.getDeltas(\n from,\n to,\n (messages) => {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.enqueueMessages(messages, fetchReason);\n },\n cacheOnly);\n } catch (error) {\n this.logger.sendErrorEvent({eventName: \"GetDeltas_Exception\"}, error);\n this.close(normalizeError(error));\n } finally {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.fetchReason = undefined;\n this.processPendingOps(reason);\n }\n }\n\n /**\n * Sorts pending ops and attempts to apply them\n */\n private processPendingOps(reason?: string): void {\n if (this.closed) {\n return;\n }\n\n assert(this.handler !== undefined, 0x26c /* \"handler should be installed\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.pending = [];\n // Given that we do not track where these ops came from any more, it's not very\n // actionably to report gaps in this range.\n this.enqueueMessages(pendingSorted, `${reason}_pending`, true /* allowGaps */);\n\n // Re-entrancy is ignored by fetchMissingDeltas, execution will come here when it's over\n if (this.fetchReason === undefined) {\n // See issue #7312 for more details\n // We observe cases where client gets into situation where it is not aware of missing ops\n // (i.e. client being behind), and as such, does not attempt to fetch them.\n // In some cases client may not have enough signal (example - \"read\" connection that is silent -\n // there is no easy way for client to realize it's behind, see a bit of commentary / logic at the\n // end of setupNewSuccessfulConnection). In other cases it should be able to learn that info (\"write\"\n // connection, learn by receiving its own join op), but data suggest it does not happen.\n // In 50% of these cases we do know we are behind through checkpointSequenceNumber on connection object\n // and thus can leverage that to trigger recovery. But this is not going to solve all the problems\n // (the other 50%), and thus these errors below should be looked at even if code below results in\n // recovery.\n if (this.lastQueuedSequenceNumber < this.lastObservedSeqNumber) {\n this.fetchMissingDeltas(\"OpsBehind\");\n }\n }\n }\n\n private updateLatestKnownOpSeqNumber(seq: number) {\n if (this.lastObservedSeqNumber < seq) {\n this.lastObservedSeqNumber = seq;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"deltaManager.js","sourceRoot":"","sources":["../src/deltaManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAgBlC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACH,cAAc,EACd,UAAU,EACV,cAAc,GACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAGH,eAAe,GAClB,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AyF;YACzF,2EAA2E;YAC3E,gGAAgG;YAChG,iGAAiG;YACjG,qGAAqG;YACrG,wFAAwF;YACxF,uGAAuG;YACvG,kGAAkG;YAClG,iGAAiG;YACjG,YAAY;YACZ,IAAI,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE;gBAC5D,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;aACxC;SACJ;IACL,CAAC;IAEO,4BAA4B,CAAC,GAAW;QAC5C,IAAI,IAAI,CAAC,qBAAqB,GAAG,GAAG,EAAE;YAClC,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC;SACpC;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n ITelemetryLogger,\n IEventProvider,\n ITelemetryProperties,\n ITelemetryErrorEvent,\n} from \"@fluidframework/common-definitions\";\nimport {\n IDeltaHandlerStrategy,\n IDeltaManager,\n IDeltaManagerEvents,\n IDeltaQueue,\n ICriticalContainerError,\n IThrottlingWarning,\n IConnectionDetails,\n} from \"@fluidframework/container-definitions\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n normalizeError,\n logIfFalse,\n safeRaiseEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { isSystemMessage } from \"@fluidframework/protocol-base\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISignalMessage,\n MessageType,\n ConnectionMode,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n NonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport {\n ThrottlingWarning,\n DataCorruptionError,\n extractSafePropertiesFromMessage,\n DataProcessingError,\n} from \"@fluidframework/container-utils\";\nimport { DeltaQueue } from \"./deltaQueue\";\nimport {\n IConnectionManagerFactoryArgs,\n IConnectionManager,\n } from \"./contracts\";\nimport { TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\n\nexport interface IConnectionArgs {\n mode?: ConnectionMode;\n fetchOpsFromStorage?: boolean;\n reason: string;\n}\n\n/**\n * Includes events emitted by the concrete implementation DeltaManager\n * but not exposed on the public interface IDeltaManager\n */\nexport interface IDeltaManagerInternalEvents extends IDeltaManagerEvents {\n (event: \"throttled\", listener: (error: IThrottlingWarning) => void);\n (event: \"closed\", listener: (error?: ICriticalContainerError) => void);\n}\n\n/**\n * Manages the flow of both inbound and outbound messages. This class ensures that shared objects receive delta\n * messages in order regardless of possible network conditions or timings causing out of order delivery.\n */\nexport class DeltaManager<TConnectionManager extends IConnectionManager>\n extends TypedEventEmitter<IDeltaManagerInternalEvents>\n implements\n IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n IEventProvider<IDeltaManagerInternalEvents>\n{\n public readonly connectionManager: TConnectionManager;\n\n public get active(): boolean { return this._active(); }\n\n public get disposed() { return this.closed; }\n\n public get IDeltaSender() { return this; }\n\n private pending: ISequencedDocumentMessage[] = [];\n private fetchReason: string | undefined;\n\n // The minimum sequence number and last sequence number received from the server\n private minSequenceNumber: number = 0;\n\n // There are three numbers we track\n // * lastQueuedSequenceNumber is the last queued sequence number. If there are gaps in seq numbers, then this number\n // is not updated until we cover that gap, so it increases each time by 1.\n // * lastObservedSeqNumber is an estimation of last known sequence number for container in storage. It's initially\n // populated at web socket connection time (if storage provides that info) and is updated once ops shows up.\n // It's never less than lastQueuedSequenceNumber\n // * lastProcessedSequenceNumber - last processed sequence number\n private lastQueuedSequenceNumber: number = 0;\n private lastObservedSeqNumber: number = 0;\n private lastProcessedSequenceNumber: number = 0;\n private lastProcessedMessage: ISequencedDocumentMessage | undefined;\n private baseTerm: number = 0;\n\n private prevEnqueueMessagesReason: string | undefined;\n private previouslyProcessedMessage: ISequencedDocumentMessage | undefined;\n\n // The sequence number we initially loaded from\n private initSequenceNumber: number = 0;\n\n private readonly _inbound: DeltaQueue<ISequencedDocumentMessage>;\n private readonly _inboundSignal: DeltaQueue<ISignalMessage>;\n\n private closed = false;\n\n private handler: IDeltaHandlerStrategy | undefined;\n private deltaStorage: IDocumentDeltaStorageService | undefined;\n\n private readonly throttlingIdSet = new Set<string>();\n private timeTillThrottling: number = 0;\n\n private readonly closeAbortController = new AbortController();\n\n private readonly deltaStorageDelayId = uuid();\n private readonly deltaStreamDelayId = uuid();\n\n private messageBuffer: IDocumentMessage[] = [];\n\n private _checkpointSequenceNumber: number | undefined;\n\n public get inbound(): IDeltaQueue<ISequencedDocumentMessage> {\n return this._inbound;\n }\n\n public get inboundSignal(): IDeltaQueue<ISignalMessage> {\n return this._inboundSignal;\n }\n\n public get initialSequenceNumber(): number {\n return this.initSequenceNumber;\n }\n\n public get lastSequenceNumber(): number {\n return this.lastProcessedSequenceNumber;\n }\n\n public get lastMessage() {\n return this.lastProcessedMessage;\n }\n\n public get lastKnownSeqNumber() {\n return this.lastObservedSeqNumber;\n }\n\n public get referenceTerm(): number {\n return this.baseTerm;\n }\n\n public get minimumSequenceNumber(): number {\n return this.minSequenceNumber;\n }\n\n /**\n * Tells if current connection has checkpoint information.\n * I.e. we know how far behind the client was at the time of establishing connection\n */\n public get hasCheckpointSequenceNumber() {\n // Valid to be called only if we have active connection.\n assert(this.connectionManager.connected, 0x0df /* \"Missing active connection\" */);\n return this._checkpointSequenceNumber !== undefined;\n }\n\n // Forwarding connection manager properties / IDeltaManager implementation\n public get maxMessageSize(): number { return this.connectionManager.maxMessageSize; }\n public get version() { return this.connectionManager.version; }\n public get serviceConfiguration() { return this.connectionManager.serviceConfiguration; }\n public get outbound() { return this.connectionManager.outbound; }\n public get readOnlyInfo() { return this.connectionManager.readOnlyInfo; }\n public get clientDetails() { return this.connectionManager.clientDetails; }\n\n public submit(type: MessageType, contents: any, batch = false, metadata?: any) {\n\n const messagePartial: Omit<IDocumentMessage, \"clientSequenceNumber\"> = {\n contents: JSON.stringify(contents),\n metadata,\n referenceSequenceNumber: this.lastProcessedSequenceNumber,\n type,\n };\n\n if (!batch) {\n this.flush();\n }\n\n const message = this.connectionManager.prepareMessageToSend(messagePartial);\n if (message === undefined) {\n return -1;\n }\n\n this.messageBuffer.push(message);\n\n if (!batch) {\n this.flush();\n }\n\n this.emit(\"submitOp\", message);\n return message.clientSequenceNumber;\n }\n\n public submitSignal(content: any) { return this.connectionManager.submitSignal(content); }\n\n public flush() {\n if (this.messageBuffer.length === 0) {\n return;\n }\n\n // The prepareFlush event allows listeners to append metadata to the batch prior to submission.\n this.emit(\"prepareSend\", this.messageBuffer);\n\n this.connectionManager.sendMessages(this.messageBuffer);\n this.messageBuffer = [];\n }\n\n public get connectionProps(): ITelemetryProperties {\n return {\n sequenceNumber: this.lastSequenceNumber,\n ...this.connectionManager.connectionProps,\n };\n }\n\n /**\n * Log error event with a bunch of internal to DeltaManager information about state of op processing\n * Used to diagnose connectivity issues related to op processing (i.e. cases where for some reason\n * we stop processing ops that results in no processing join op and thus moving to connected state)\n * @param event - Event to log.\n */\n public logConnectionIssue(event: ITelemetryErrorEvent) {\n assert(this.connectionManager.connected, 0x238 /* \"called only in connected state\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.logger.sendErrorEvent({\n ...event,\n // This directly tells us if fetching ops is in flight, and thus likely the reason of\n // stalled op processing\n fetchReason: this.fetchReason,\n // A bunch of useful sequence numbers to understand if we are holding some ops from processing\n lastQueuedSequenceNumber: this.lastQueuedSequenceNumber, // last sequential op\n lastProcessedSequenceNumber: this.lastProcessedSequenceNumber, // same as above, but after processing\n lastObserved: this.lastObservedSeqNumber, // last sequence we ever saw; may have gaps with above.\n // connection info\n ...this.connectionManager.connectionVerboseProps,\n pendingOps: this.pending.length, // Do we have any pending ops?\n pendingFirst: pendingSorted[0]?.sequenceNumber, // is the first pending op the one that we are missing?\n haveHandler: this.handler !== undefined, // do we have handler installed?\n inboundLength: this.inbound.length,\n inboundPaused: this.inbound.paused,\n });\n }\n\n constructor(\n private readonly serviceProvider: () => IDocumentService | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly _active: () => boolean,\n createConnectionManager: (props: IConnectionManagerFactoryArgs) => TConnectionManager,\n ) {\n super();\n const props: IConnectionManagerFactoryArgs = {\n incomingOpHandler:(messages: ISequencedDocumentMessage[], reason: string) =>\n this.enqueueMessages(messages, reason),\n signalHandler: (message: ISignalMessage) => this._inboundSignal.push(message),\n reconnectionDelayHandler: (delayMs: number, error: unknown) =>\n this.emitDelayInfo(this.deltaStreamDelayId, delayMs, error),\n closeHandler: (error: any) => this.close(error),\n disconnectHandler: (reason: string) => this.disconnectHandler(reason),\n connectHandler: (connection: IConnectionDetails) => this.connectHandler(connection),\n pongHandler: (latency: number) => this.emit(\"pong\", latency),\n readonlyChangeHandler: (readonly?: boolean) => safeRaiseEvent(this, this.logger, \"readonly\", readonly),\n };\n\n this.connectionManager = createConnectionManager(props);\n\n this._inbound = new DeltaQueue<ISequencedDocumentMessage>(\n (op) => {\n this.processInboundMessage(op);\n });\n\n this._inbound.on(\"error\", (error) => {\n this.close(\n DataProcessingError.wrapIfUnrecognized(error, \"deltaManagerInboundErrorHandler\", this.lastMessage));\n });\n\n // Inbound signal queue\n this._inboundSignal = new DeltaQueue<ISignalMessage>((message) => {\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound signal without a handler attached\");\n }\n this.handler.processSignal({\n clientId: message.clientId,\n content: JSON.parse(message.content as string),\n });\n });\n\n this._inboundSignal.on(\"error\", (error) => {\n this.close(normalizeError(error));\n });\n\n // Initially, all queues are created paused.\n // - outbound is flipped back and forth in setupNewSuccessfulConnection / disconnectFromDeltaStream\n // - inbound & inboundSignal are resumed in attachOpHandler() when we have handler setup\n }\n\n private connectHandler(connection: IConnectionDetails) {\n this.refreshDelayInfo(this.deltaStreamDelayId);\n\n const props = this.connectionManager.connectionVerboseProps;\n props.connectionLastQueuedSequenceNumber = this.lastQueuedSequenceNumber;\n props.connectionLastObservedSeqNumber = this.lastObservedSeqNumber;\n\n const checkpointSequenceNumber = connection.checkpointSequenceNumber;\n this._checkpointSequenceNumber = checkpointSequenceNumber;\n if (checkpointSequenceNumber !== undefined) {\n this.updateLatestKnownOpSeqNumber(checkpointSequenceNumber);\n }\n\n // We cancel all ops on lost of connectivity, and rely on DDSes to resubmit them.\n // Semantics are not well defined for batches (and they are broken right now on disconnects anyway),\n // but it's safe to assume (until better design is put into place) that batches should not exist\n // across multiple connections. Right now we assume runtime will not submit any ops in disconnected\n // state. As requirements change, so should these checks.\n assert(this.messageBuffer.length === 0, 0x0e9 /* \"messageBuffer is not empty on new connection\" */);\n\n this.emit(\n \"connect\",\n connection,\n checkpointSequenceNumber !== undefined ?\n this.lastObservedSeqNumber - this.lastSequenceNumber : undefined);\n\n // If we got some initial ops, then we know the gap and call above fetched ops to fill it.\n // Same is true for \"write\" mode even if we have no ops - we will get \"join\" own op very very soon.\n // However if we are connecting as view-only, then there is no good signal to realize if client is behind.\n // Thus we have to hit storage to see if any ops are there.\n if (checkpointSequenceNumber !== undefined) {\n // We know how far we are behind (roughly). If it's non-zero gap, fetch ops right away.\n if (checkpointSequenceNumber > this.lastQueuedSequenceNumber) {\n this.fetchMissingDeltas(\"AfterConnection\");\n }\n // we do not know the gap, and we will not learn about it if socket is quite - have to ask.\n } else if (connection.mode === \"read\") {\n this.fetchMissingDeltas(\"AfterReadConnection\");\n }\n }\n\n public dispose() {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Sets the sequence number from which inbound messages should be returned\n */\n public async attachOpHandler(\n minSequenceNumber: number,\n sequenceNumber: number,\n term: number,\n handler: IDeltaHandlerStrategy,\n prefetchType: \"cached\" | \"all\" | \"none\" = \"none\",\n ) {\n this.initSequenceNumber = sequenceNumber;\n this.lastProcessedSequenceNumber = sequenceNumber;\n this.baseTerm = term;\n this.minSequenceNumber = minSequenceNumber;\n this.lastQueuedSequenceNumber = sequenceNumber;\n this.lastObservedSeqNumber = sequenceNumber;\n\n // We will use same check in other places to make sure all the seq number above are set properly.\n assert(this.handler === undefined, 0x0e2 /* \"DeltaManager already has attached op handler!\" */);\n this.handler = handler;\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n assert(!!(this.handler as any), 0x0e3 /* \"Newly set op handler is null/undefined!\" */);\n\n // There should be no pending fetch!\n // This API is called right after attachOpHandler by Container.load().\n // We might have connection already and it might have called fetchMissingDeltas() from\n // setupNewSuccessfulConnection. But it should do nothing, because there is no way to fetch ops before\n // we know snapshot sequence number that is set in attachOpHandler. So all such calls should be noop.\n assert(this.fetchReason === undefined, 0x268 /* \"There can't be pending fetch that early in boot sequence!\" */);\n\n if (this.closed) {\n return;\n }\n\n this._inbound.resume();\n this._inboundSignal.resume();\n\n if (prefetchType !== \"none\") {\n const cacheOnly = prefetchType === \"cached\";\n await this.fetchMissingDeltasCore(\"DocumentOpen\", cacheOnly, this.lastQueuedSequenceNumber);\n\n // Keep going with fetching ops from storage once we have all cached ops in.\n // But do not block load and make this request async / not blocking this api.\n // Ops processing will start once cached ops are in and and will stop when queue is empty\n // (which in most cases will happen when we are done processing cached ops)\n if (cacheOnly) {\n // fire and forget\n this.fetchMissingDeltas(\"DocumentOpen\");\n }\n }\n\n // Ensure there is no need to call this.processPendingOps() at the end of boot sequence\n assert(this.fetchReason !== undefined || this.pending.length === 0, 0x269 /* \"pending ops are not dropped\" */);\n }\n\n public connect(args: IConnectionArgs) {\n const fetchOpsFromStorage = args.fetchOpsFromStorage ?? true;\n logIfFalse(\n this.handler !== undefined || !fetchOpsFromStorage,\n this.logger,\n \"CantFetchWithoutBaseline\"); // can't fetch if no baseline\n\n // Note: There is race condition here.\n // We want to issue request to storage as soon as possible, to\n // reduce latency of becoming current, thus this code here.\n // But there is no ordering between fetching OPs and connection to delta stream\n // As result, we might be behind by the time we connect to delta stream\n // In case of r/w connection, that's not an issue, because we will hear our\n // own \"join\" message and realize any gap client has in ops.\n // But for view-only connection, we have no such signal, and with no traffic\n // on the wire, we might be always behind.\n // See comment at the end of \"connect\" handler\n if (fetchOpsFromStorage) {\n this.fetchMissingDeltas(args.reason);\n }\n\n this.connectionManager.connect(args.mode);\n }\n\n private async getDeltas(\n from: number, // inclusive\n to: number | undefined, // exclusive\n callback: (messages: ISequencedDocumentMessage[]) => void,\n cacheOnly: boolean)\n {\n const docService = this.serviceProvider();\n if (docService === undefined) {\n throw new Error(\"Delta manager is not attached\");\n }\n\n if (this.deltaStorage === undefined) {\n this.deltaStorage = await docService.connectToDeltaStorage();\n }\n\n let cancelFetch: (op: ISequencedDocumentMessage) => boolean;\n\n if (to !== undefined) {\n const lastExpectedOp = to - 1; // make it inclusive!\n\n // It is possible that due to asynchrony (including await above), required ops were already\n // received through delta stream. Validate that before moving forward.\n if (this.lastQueuedSequenceNumber >= lastExpectedOp) {\n this.logger.sendPerformanceEvent({\n reason: this.fetchReason,\n eventName: \"ExtraStorageCall\",\n early: true,\n from,\n to,\n ...this.connectionManager.connectionVerboseProps,\n });\n return;\n }\n\n // Be prepared for the case where webSocket would receive the ops that we are trying to fill through\n // storage. Ideally it should never happen (i.e. ops on socket are always ordered, and thus once we\n // detected gap, this gap can't be filled in later on through websocket).\n // And in practice that does look like the case. The place where this code gets hit is if we lost\n // connection and reconnected (likely to another box), and new socket's initial ops contains these ops.\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= lastExpectedOp;\n } else {\n // Unbound requests are made to proactively fetch ops, but also get up to date in cases where socket\n // is silent (and connection is \"read\", thus we might not have any data on how far client is behind).\n // Once we have any op coming in from socket, we can cancel it as it's not needed any more.\n // That said, if we have socket connection, make sure we got ops up to checkpointSequenceNumber!\n cancelFetch = (op: ISequencedDocumentMessage) => op.sequenceNumber >= this.lastObservedSeqNumber;\n }\n\n const controller = new AbortController();\n let opsFromFetch = false;\n\n const opListener = (op: ISequencedDocumentMessage) => {\n assert(op.sequenceNumber === this.lastQueuedSequenceNumber, 0x23a /* \"seq#'s\" */);\n // Ops that are coming from this request should not cancel itself.\n // This is useless for known ranges (to is defined) as it means request is over either way.\n // And it will cancel unbound request too early, not allowing us to learn where the end of the file is.\n if (!opsFromFetch && cancelFetch(op)) {\n controller.abort();\n this._inbound.off(\"push\", opListener);\n }\n };\n\n try {\n this._inbound.on(\"push\", opListener);\n assert(this.closeAbortController.signal.onabort === null, 0x1e8 /* \"reentrancy\" */);\n this.closeAbortController.signal.onabort = () => controller.abort();\n\n const stream = this.deltaStorage.fetchMessages(\n from, // inclusive\n to, // exclusive\n controller.signal,\n cacheOnly,\n this.fetchReason);\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await stream.read();\n if (result.done) {\n break;\n }\n try {\n opsFromFetch = true;\n callback(result.value);\n } finally {\n opsFromFetch = false;\n }\n }\n } finally {\n this.closeAbortController.signal.onabort = null;\n this._inbound.off(\"push\", opListener);\n assert(!opsFromFetch, 0x289 /* \"logic error\" */);\n }\n }\n\n /**\n * Closes the connection and clears inbound & outbound queues.\n */\n public close(error?: ICriticalContainerError): void {\n if (this.closed) {\n return;\n }\n this.closed = true;\n\n this.connectionManager.dispose(error);\n\n this.closeAbortController.abort();\n\n this._inbound.clear();\n this._inboundSignal.clear();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inbound.pause();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._inboundSignal.pause();\n\n // Drop pending messages - this will ensure catchUp() does not go into infinite loop\n this.pending = [];\n\n // This needs to be the last thing we do (before removing listeners), as it causes\n // Container to dispose context and break ability of data stores / runtime to \"hear\"\n // from delta manager, including notification (above) about readonly state.\n this.emit(\"closed\", error);\n\n this.removeAllListeners();\n }\n\n public refreshDelayInfo(id: string) {\n this.throttlingIdSet.delete(id);\n if (this.throttlingIdSet.size === 0) {\n this.timeTillThrottling = 0;\n }\n }\n\n private disconnectHandler(reason: string) {\n if (this.messageBuffer.length > 0) {\n // Behavior is not well defined here RE batches across connections / disconnect.\n // DeltaManager overall policy - drop all ops on disconnection and rely on\n // container runtime to deal with resubmitting any ops that did not make it through.\n // So drop them, but also raise error event to look into details.\n this.logger.sendTelemetryEvent({\n eventName: \"OpenBatchOnDisconnect\",\n length: this.messageBuffer.length,\n reason: {\n value: reason,\n tag: TelemetryDataTag.PackageData,\n }\n });\n this.messageBuffer.length = 0;\n }\n this.emit(\"disconnect\", reason);\n }\n\n /**\n * Emit info about a delay in service communication on account of throttling.\n * @param id - Id of the connection that is delayed\n * @param delayMs - Duration of the delay\n * @param error - error object indicating the throttling\n */\n public emitDelayInfo(id: string, delayMs: number, error: unknown) {\n const timeNow = Date.now();\n this.throttlingIdSet.add(id);\n if (delayMs > 0 && (timeNow + delayMs > this.timeTillThrottling)) {\n this.timeTillThrottling = timeNow + delayMs;\n\n const throttlingWarning: IThrottlingWarning = ThrottlingWarning.wrap(\n error,\n delayMs / 1000 /* retryAfterSeconds */,\n this.logger,\n );\n this.emit(\"throttled\", throttlingWarning);\n }\n }\n\n // returns parts of message (in string format) that should never change for a given message.\n // Used for message comparison. It attempts to avoid comparing fields that potentially may differ.\n // for example, it's not clear if serverMetadata or timestamp property is a property of message or server state.\n // We only extract the most obvious fields that are sufficient (with high probability) to detect sequence number\n // reuse.\n // Also payload goes to telemetry, so no PII, including content!!\n // Note: It's possible for a duplicate op to be broadcasted and have everything the same except the timestamp.\n private comparableMessagePayload(m: ISequencedDocumentMessage) {\n return `${m.clientId}-${m.type}-${m.minimumSequenceNumber}-${m.referenceSequenceNumber}-${m.timestamp}`;\n }\n\n private enqueueMessages(\n messages: ISequencedDocumentMessage[],\n reason: string,\n allowGaps = false,\n ): void {\n if (this.handler === undefined) {\n // We did not setup handler yet.\n // This happens when we connect to web socket faster than we get attributes for container\n // and thus faster than attachOpHandler() is called\n // this.lastProcessedSequenceNumber is still zero, so we can't rely on this.fetchMissingDeltas()\n // to do the right thing.\n this.pending = this.pending.concat(messages);\n return;\n }\n\n // Pending ops should never just hang around for nothing.\n // This invariant will stay true through this function execution,\n // so there is no need to process pending ops here.\n // It's responsibility of\n // - attachOpHandler()\n // - fetchMissingDeltas() after it's done with querying storage\n assert(this.pending.length === 0 || this.fetchReason !== undefined, 0x1e9 /* \"Pending ops\" */);\n\n if (messages.length === 0) {\n return;\n }\n\n const from = messages[0].sequenceNumber;\n const last = messages[messages.length - 1].sequenceNumber;\n\n // Report stats about missing and duplicate ops\n // This helps better understand why we fetch ops from storage, and thus may delay\n // getting current / sending ops\n // It's possible that this batch is already too late - do not bother\n if (last > this.lastQueuedSequenceNumber) {\n let prev = from - 1;\n const initialGap = prev - this.lastQueuedSequenceNumber;\n let firstMissing: number | undefined;\n let duplicate = 0;\n let gap = 0;\n\n // Count all gaps and duplicates\n for (const message of messages) {\n if (message.sequenceNumber === prev) {\n duplicate++;\n } else if (message.sequenceNumber !== prev + 1) {\n gap++;\n if (firstMissing === undefined) {\n firstMissing = prev + 1;\n }\n }\n prev = message.sequenceNumber;\n }\n\n let eventName: string | undefined;\n\n // Report if we found some issues\n if (duplicate !== 0 || gap !== 0 && !allowGaps || initialGap > 0 && this.fetchReason === undefined) {\n eventName = \"enqueueMessages\";\n // Also report if we are fetching ops, and same range comes in, thus making this fetch obsolete.\n } else if (this.fetchReason !== undefined && this.fetchReason !== reason &&\n (from <= this.lastQueuedSequenceNumber + 1 && last > this.lastQueuedSequenceNumber)) {\n eventName = \"enqueueMessagesExtraFetch\";\n }\n\n // Report if there is something to report\n // Do not report when pending fetch is in progress, as such reporting will not\n // correctly take into account pending ops.\n if (eventName !== undefined) {\n this.logger.sendPerformanceEvent({\n eventName,\n reason,\n previousReason: this.prevEnqueueMessagesReason,\n from,\n to: last + 1, // exclusive, being consistent with the other telemetry / APIs\n length: messages.length,\n fetchReason: this.fetchReason,\n duplicate: duplicate > 0 ? duplicate : undefined,\n initialGap: initialGap !== 0 ? initialGap : undefined,\n gap: gap > 0 ? gap : undefined,\n firstMissing,\n dmInitialSeqNumber: this.initialSequenceNumber,\n ...this.connectionManager.connectionVerboseProps,\n });\n }\n }\n\n this.updateLatestKnownOpSeqNumber(messages[messages.length - 1].sequenceNumber);\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n assert(n === undefined || n === this.lastQueuedSequenceNumber,\n 0x0ec /* \"Unexpected value for previously processed message's sequence number\" */);\n\n for (const message of messages) {\n // Check that the messages are arriving in the expected order\n if (message.sequenceNumber <= this.lastQueuedSequenceNumber) {\n // Validate that we do not have data loss, i.e. sequencing is reset and started again\n // with numbers that this client already observed before.\n if (this.previouslyProcessedMessage?.sequenceNumber === message.sequenceNumber) {\n const message1 = this.comparableMessagePayload(this.previouslyProcessedMessage);\n const message2 = this.comparableMessagePayload(message);\n if (message1 !== message2) {\n // This looks like a data corruption but the culprit has been found instead\n // to be the file being overwritten in storage. See PR #5882.\n const error = new NonRetryableError(\n \"Found two messages with the same sequenceNumber but different payloads\",\n DriverErrorType.fileOverwrittenInStorage,\n {\n clientId: this.connectionManager.clientId,\n sequenceNumber: message.sequenceNumber,\n message1,\n message2,\n driverVersion: undefined,\n },\n );\n this.close(error);\n }\n }\n } else if (message.sequenceNumber !== this.lastQueuedSequenceNumber + 1) {\n this.pending.push(message);\n this.fetchMissingDeltas(reason, message.sequenceNumber);\n } else {\n this.lastQueuedSequenceNumber = message.sequenceNumber;\n this.previouslyProcessedMessage = message;\n this._inbound.push(message);\n }\n }\n\n // When / if we report a gap in ops in the future, we want telemetry to correctly reflect source\n // of prior ops. But if we have some out of order ops (this.pending), then reporting current reason\n // becomes not accurate, as the gap existed before current batch, so we should just report \"unknown\".\n this.prevEnqueueMessagesReason = this.pending.length > 0 ? \"unknown\" : reason;\n }\n\n private processInboundMessage(message: ISequencedDocumentMessage): void {\n const startTime = Date.now();\n this.lastProcessedMessage = message;\n\n // All non-system messages are coming from some client, and should have clientId\n // System messages may have no clientId (but some do, like propose, noop, summarize)\n assert(\n message.clientId !== undefined\n || isSystemMessage(message),\n 0x0ed /* \"non-system message have to have clientId\" */,\n );\n\n // TODO Remove after SPO picks up the latest build.\n if (\n typeof message.contents === \"string\"\n && message.contents !== \"\"\n && message.type !== MessageType.ClientLeave\n ) {\n message.contents = JSON.parse(message.contents);\n }\n\n this.connectionManager.beforeProcessingIncomingOp(message);\n\n // Watch the minimum sequence number and be ready to update as needed\n if (this.minSequenceNumber > message.minimumSequenceNumber) {\n throw new DataCorruptionError(\"Found a lower minimumSequenceNumber (msn) than previously recorded\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.minSequenceNumber = message.minimumSequenceNumber;\n\n if (message.sequenceNumber !== this.lastProcessedSequenceNumber + 1) {\n throw new DataCorruptionError(\"Found a non-Sequential sequenceNumber\", {\n ...extractSafePropertiesFromMessage(message),\n clientId: this.connectionManager.clientId,\n });\n }\n this.lastProcessedSequenceNumber = message.sequenceNumber;\n\n // a bunch of code assumes that this is true\n assert(this.lastProcessedSequenceNumber <= this.lastObservedSeqNumber,\n 0x267 /* \"lastObservedSeqNumber should be updated first\" */);\n\n // Back-compat for older server with no term\n if (message.term === undefined) {\n message.term = 1;\n }\n this.baseTerm = message.term;\n\n if (this.handler === undefined) {\n throw new Error(\"Attempted to process an inbound message without a handler attached\");\n }\n this.handler.process(message);\n\n const endTime = Date.now();\n\n // Should be last, after changing this.lastProcessedSequenceNumber above, as many callers\n // test this.lastProcessedSequenceNumber instead of using op.sequenceNumber itself.\n this.emit(\"op\", message, endTime - startTime);\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private fetchMissingDeltas(reasonArg: string, to?: number) {\n this.fetchMissingDeltasCore(reasonArg, false /* cacheOnly */, to).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"fetchMissingDeltasException\" }, error);\n });\n }\n\n /**\n * Retrieves the missing deltas between the given sequence numbers\n */\n private async fetchMissingDeltasCore(\n reason: string,\n cacheOnly: boolean,\n to?: number)\n {\n // Exit out early if we're already fetching deltas\n if (this.fetchReason !== undefined) {\n return;\n }\n\n if (this.closed) {\n this.logger.sendTelemetryEvent({ eventName: \"fetchMissingDeltasClosedConnection\", reason });\n return;\n }\n\n if (this.handler === undefined) {\n // We do not poses yet any information\n assert(this.lastQueuedSequenceNumber === 0, 0x26b /* \"initial state\" */);\n return;\n }\n\n try {\n let from = this.lastQueuedSequenceNumber + 1;\n\n const n = this.previouslyProcessedMessage?.sequenceNumber;\n if (n !== undefined) {\n // If we already processed at least one op, then we have this.previouslyProcessedMessage populated\n // and can use it to validate that we are operating on same file, i.e. it was not overwritten.\n // Knowing about this mechanism, we could ask for op we already observed to increase validation.\n // This is especially useful when coming out of offline mode or loading from\n // very old cached (by client / driver) snapshot.\n assert(n === this.lastQueuedSequenceNumber, 0x0f2 /* \"previouslyProcessedMessage\" */);\n assert(from > 1, 0x0f3 /* \"not positive\" */);\n from--;\n }\n\n const fetchReason = `${reason}_fetch`;\n this.fetchReason = fetchReason;\n\n await this.getDeltas(\n from,\n to,\n (messages) => {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.enqueueMessages(messages, fetchReason);\n },\n cacheOnly);\n } catch (error) {\n this.logger.sendErrorEvent({eventName: \"GetDeltas_Exception\"}, error);\n this.close(normalizeError(error));\n } finally {\n this.refreshDelayInfo(this.deltaStorageDelayId);\n this.fetchReason = undefined;\n this.processPendingOps(reason);\n }\n }\n\n /**\n * Sorts pending ops and attempts to apply them\n */\n private processPendingOps(reason?: string): void {\n if (this.closed) {\n return;\n }\n\n assert(this.handler !== undefined, 0x26c /* \"handler should be installed\" */);\n\n const pendingSorted = this.pending.sort((a, b) => a.sequenceNumber - b.sequenceNumber);\n this.pending = [];\n // Given that we do not track where these ops came from any more, it's not very\n // actionably to report gaps in this range.\n this.enqueueMessages(pendingSorted, `${reason}_pending`, true /* allowGaps */);\n\n // Re-entrancy is ignored by fetchMissingDeltas, execution will come here when it's over\n if (this.fetchReason === undefined) {\n // See issue #7312 for more details\n // We observe cases where client gets into situation where it is not aware of missing ops\n // (i.e. client being behind), and as such, does not attempt to fetch them.\n // In some cases client may not have enough signal (example - \"read\" connection that is silent -\n // there is no easy way for client to realize it's behind, see a bit of commentary / logic at the\n // end of setupNewSuccessfulConnection). In other cases it should be able to learn that info (\"write\"\n // connection, learn by receiving its own join op), but data suggest it does not happen.\n // In 50% of these cases we do know we are behind through checkpointSequenceNumber on connection object\n // and thus can leverage that to trigger recovery. But this is not going to solve all the problems\n // (the other 50%), and thus these errors below should be looked at even if code below results in\n // recovery.\n if (this.lastQueuedSequenceNumber < this.lastObservedSeqNumber) {\n this.fetchMissingDeltas(\"OpsBehind\");\n }\n }\n }\n\n private updateLatestKnownOpSeqNumber(seq: number) {\n if (this.lastObservedSeqNumber < seq) {\n this.lastObservedSeqNumber = seq;\n }\n }\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.58.0-55561";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"0.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"0.58.0-55561\";\n"]}
|
|
@@ -58,7 +58,7 @@ export class RetriableDocumentStorageService {
|
|
|
58
58
|
}
|
|
59
59
|
checkStorageDisposed() {
|
|
60
60
|
if (this._disposed) {
|
|
61
|
-
throw new GenericError("
|
|
61
|
+
throw new GenericError("Storage Service is disposed. Cannot retry", { canRetry: false });
|
|
62
62
|
}
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|