@fluidframework/test-utils 2.41.0-338186 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/TestSummaryUtils.js +1 -1
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerUtils.js +1 -1
- package/dist/containerUtils.js.map +1 -1
- package/dist/loaderContainerTracker.d.ts.map +1 -1
- package/dist/loaderContainerTracker.js +3 -0
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/timeoutUtils.d.ts.map +1 -1
- package/dist/timeoutUtils.js +20 -12
- package/dist/timeoutUtils.js.map +1 -1
- package/lib/TestSummaryUtils.js +1 -1
- package/lib/TestSummaryUtils.js.map +1 -1
- package/lib/containerUtils.js +1 -1
- package/lib/containerUtils.js.map +1 -1
- package/lib/loaderContainerTracker.d.ts.map +1 -1
- package/lib/loaderContainerTracker.js +3 -0
- package/lib/loaderContainerTracker.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/timeoutUtils.d.ts.map +1 -1
- package/lib/timeoutUtils.js +20 -12
- package/lib/timeoutUtils.js.map +1 -1
- package/package.json +23 -23
- package/src/TestSummaryUtils.ts +1 -1
- package/src/containerUtils.ts +1 -1
- package/src/loaderContainerTracker.ts +3 -0
- package/src/packageVersion.ts +1 -1
- package/src/timeoutUtils.ts +19 -11
package/CHANGELOG.md
CHANGED
package/dist/TestSummaryUtils.js
CHANGED
|
@@ -25,7 +25,7 @@ async function getSummarizerBackCompat(container) {
|
|
|
25
25
|
if (container.getEntryPoint !== undefined) {
|
|
26
26
|
const entryPoint = await container.getEntryPoint();
|
|
27
27
|
// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running
|
|
28
|
-
// cross
|
|
28
|
+
// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the
|
|
29
29
|
// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined
|
|
30
30
|
// since the container's runtime will be on version 1.X, which does not have an entry point defined.
|
|
31
31
|
if (entryPoint !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestSummaryUtils.js","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6EAIwD;AAaxD,kEAA6D;AAE7D,0EAA2E;AAM3E,qDAA4D;AAC5D,gDAAgD;AAChD,iFAA6F;AAC7F,2DAAiE;AACjE,6HAG8D;AAE9D,uDAAiD;AAEjD,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,KAAK,UAAU,uBAAuB,CAAC,SAAqB;IAC3D,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACnD,0GAA0G;QAC1G,qGAAqG;QACrG,gHAAgH;QAChH,oGAAoG;QACpG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,UAAyB,CAAC;QAClC,CAAC;IACF,CAAC;IACD,MAAM,QAAQ,GAAc,MAAO,SAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAC;IACrF,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,kDAAkD,CAAC,CAAC;IACpF,OAAO,QAAQ,CAAC,KAAoB,CAAC;AACtC,CAAC;AAED,gBAAgB;AACT,KAAK,UAAU,oBAAoB,CACzC,SAAqB,EACrB,MAAmB,EACnB,cAAuB;IAEvB,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,EAAE,CA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AI,CAAC,WAAW;QAC1C,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM;QAC/D,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,uBAAuB;KACxD,CAAC;AACH,CAAC;AAzCD,oCAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainer,\n\tIHostLoader,\n\tLoaderHeader,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\t// eslint-disable-next-line import/no-deprecated\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport {\n\tIConfigProviderBase,\n\tIRequest,\n\tIResponse,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { createTestConfigProvider } from \"./TestConfigs.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"./containerRuntimeFactories.js\";\nimport { waitForContainerConnection } from \"./containerUtils.js\";\nimport {\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tcreateContainerRuntimeFactoryWithDefaultDataStore,\n} from \"./testContainerRuntimeFactoryWithDefaultDataStore.js\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider.js\";\nimport { timeoutAwait } from \"./timeoutUtils.js\";\n\nconst summarizerClientType = \"summarizer\";\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nasync function getSummarizerBackCompat(container: IContainer): Promise<ISummarizer> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross version compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as ISummarizer;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"_summarizer\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as ISummarizer;\n}\n\n/** @internal */\nexport async function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n) {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\t// Old loaders will not have getEntryPoint API on the container. So, use getSummarizerBackCompat which\n\t// will use request pattern to get the summarizer in these old loaders.\n\tconst fluidObject = await getSummarizerBackCompat(summarizerContainer);\n\tif (fluidObject.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType?: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = createTestConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tcontainerRuntimeFactoryType ?? ContainerRuntimeFactoryWithDefaultDataStore,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? createTestConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n): Promise<SummaryInfo> {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted, {\n\t\terrorMsg: \"Promise timed out: summarySubmitted\",\n\t});\n\tif (!submitResult.success) {\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted, {\n\t\terrorMsg: \"Promise timed out: summaryOpBroadcasted\",\n\t});\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack, {\n\t\terrorMsg: \"Promise timed out: receivedSummaryAckOrNack\",\n\t});\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n\n/**\n * Summary information containing the summary tree, summary version, and summary sequence number.\n * @internal\n */\nexport interface SummaryInfo {\n\t/**\n\t * The summary tree generated\n\t */\n\tsummaryTree: ISummaryTree;\n\t/**\n\t * Handle of the completed summary\n\t */\n\tsummaryVersion: string;\n\t/**\n\t * Reference sequence number of the current summary generation\n\t */\n\tsummaryRefSeq: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TestSummaryUtils.js","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6EAIwD;AAaxD,kEAA6D;AAE7D,0EAA2E;AAM3E,qDAA4D;AAC5D,gDAAgD;AAChD,iFAA6F;AAC7F,2DAAiE;AACjE,6HAG8D;AAE9D,uDAAiD;AAEjD,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,KAAK,UAAU,uBAAuB,CAAC,SAAqB;IAC3D,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACnD,0GAA0G;QAC1G,oGAAoG;QACpG,gHAAgH;QAChH,oGAAoG;QACpG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,UAAyB,CAAC;QAClC,CAAC;IACF,CAAC;IACD,MAAM,QAAQ,GAAc,MAAO,SAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAC;I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AA6C;KACvD,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,aAAa,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1D,OAAO;QACN,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,WAAW;QAC1C,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM;QAC/D,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,uBAAuB;KACxD,CAAC;AACH,CAAC;AAzCD,oCAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainer,\n\tIHostLoader,\n\tLoaderHeader,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\t// eslint-disable-next-line import/no-deprecated\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport {\n\tIConfigProviderBase,\n\tIRequest,\n\tIResponse,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { createTestConfigProvider } from \"./TestConfigs.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"./containerRuntimeFactories.js\";\nimport { waitForContainerConnection } from \"./containerUtils.js\";\nimport {\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tcreateContainerRuntimeFactoryWithDefaultDataStore,\n} from \"./testContainerRuntimeFactoryWithDefaultDataStore.js\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider.js\";\nimport { timeoutAwait } from \"./timeoutUtils.js\";\n\nconst summarizerClientType = \"summarizer\";\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nasync function getSummarizerBackCompat(container: IContainer): Promise<ISummarizer> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as ISummarizer;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"_summarizer\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as ISummarizer;\n}\n\n/** @internal */\nexport async function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n) {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\t// Old loaders will not have getEntryPoint API on the container. So, use getSummarizerBackCompat which\n\t// will use request pattern to get the summarizer in these old loaders.\n\tconst fluidObject = await getSummarizerBackCompat(summarizerContainer);\n\tif (fluidObject.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType?: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = createTestConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tcontainerRuntimeFactoryType ?? ContainerRuntimeFactoryWithDefaultDataStore,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? createTestConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n): Promise<SummaryInfo> {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted, {\n\t\terrorMsg: \"Promise timed out: summarySubmitted\",\n\t});\n\tif (!submitResult.success) {\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted, {\n\t\terrorMsg: \"Promise timed out: summaryOpBroadcasted\",\n\t});\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack, {\n\t\terrorMsg: \"Promise timed out: receivedSummaryAckOrNack\",\n\t});\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n\n/**\n * Summary information containing the summary tree, summary version, and summary sequence number.\n * @internal\n */\nexport interface SummaryInfo {\n\t/**\n\t * The summary tree generated\n\t */\n\tsummaryTree: ISummaryTree;\n\t/**\n\t * Handle of the completed summary\n\t */\n\tsummaryVersion: string;\n\t/**\n\t * Reference sequence number of the current summary generation\n\t */\n\tsummaryRefSeq: number;\n}\n"]}
|
package/dist/containerUtils.js
CHANGED
|
@@ -54,7 +54,7 @@ async function getContainerEntryPointBackCompat(container) {
|
|
|
54
54
|
if (container.getEntryPoint !== undefined) {
|
|
55
55
|
const entryPoint = await container.getEntryPoint();
|
|
56
56
|
// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running
|
|
57
|
-
// cross
|
|
57
|
+
// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the
|
|
58
58
|
// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined
|
|
59
59
|
// since the container's runtime will be on version 1.X, which does not have an entry point defined.
|
|
60
60
|
if (entryPoint !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerUtils.js","sourceRoot":"","sources":["../src/containerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAAmE;AAEnE,kEAA6D;AAQ7D,uDAAsF;AAEtF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,0BAA0B,CAC/C,SAAqB,EACrB,uBAAgC,IAAI,EACpC,cAAiC;IAEjC,IAAI,SAAS,CAAC,eAAe,KAAK,kCAAe,CAAC,SAAS,EAAE,CAAC;QAC7D,MAAM,QAAQ,GAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrD,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7C,IAAI,oBAAoB,EAAE,CAAC;gBAC1B,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACpD,CAAC;QACF,CAAC,CAAC;QAEF,OAAO,cAAc,KAAK,SAAS;YAClC,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC;YACvB,CAAC,CAAC,IAAA,gCAAc,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;AACF,CAAC;AAjBD,gEAiBC;AAED;;;;;GAKG;AACI,KAAK,UAAU,gCAAgC,CAAI,SAAqB;IAC9E,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACnD,0GAA0G;QAC1G,
|
|
1
|
+
{"version":3,"file":"containerUtils.js","sourceRoot":"","sources":["../src/containerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAAmE;AAEnE,kEAA6D;AAQ7D,uDAAsF;AAEtF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,0BAA0B,CAC/C,SAAqB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B;IAC9E,IAAI,SAAS,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,EAAgB,CAAC;IACjD,CAAC;IACD,MAAM,QAAQ,GAAc,MAAO,SAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1E,IAAA,iBAAM,EAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,yCAAyC,CAAC,CAAC;IAC3E,OAAO,QAAQ,CAAC,KAAU,CAAC;AAC5B,CAAC;AAPD,4EAOC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAClC,YAEsB;IAEtB,IAAA,iBAAM,EACL,SAAS,IAAI,YAAY,IAAI,UAAU,IAAI,YAAY,EACvD,sDAAsD,CACtD,CAAC;IACF,OAAO,YAE2E,CAAC;AACpF,CAAC;AAZD,kDAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainer,\n\tIDeltaManager,\n\ttype IDeltaManagerFull,\n} from \"@fluidframework/container-definitions/internal\";\nimport { ConnectionState } from \"@fluidframework/container-loader\";\nimport { IResponse } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IDeltaManagerErased } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { IDataStore } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { PromiseExecutor, TimeoutWithError, timeoutPromise } from \"./timeoutUtils.js\";\n\n/**\n * Utility function to wait for the specified Container to be in Connected state.\n * If the Container is already connected, the Promise returns immediately; otherwise it resolves when the Container emits\n * its 'connected' event.\n * If failOnContainerClose === true, the returned Promise will be rejected if the container emits a 'closed' event\n * before a 'connected' event.\n * @param container - The container to wait for.\n * @param failOnContainerClose - If true, the returned Promise will be rejected if the container emits a 'closed' event\n * before a 'connected' event.\n * Defaults to true.\n * @param timeoutOptions - Options related to the behavior of the timeout.\n * If provided, the returned Promise will reject if the container hasn't emitted relevant events in timeoutOptions.durationMs.\n * If not provided, the Promise will wait indefinitely for the Container to emit its 'connected' (or 'closed', if\n * failOnContainerClose === true) event.\n *\n * @returns A Promise that either:\n * - Resolves when the specified container emits a 'connected' event (or immediately if the Container is already connected).\n * - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.\n * - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant\n * events, within that timeframe.\n * @internal\n */\nexport async function waitForContainerConnection(\n\tcontainer: IContainer,\n\tfailOnContainerClose: boolean = true,\n\ttimeoutOptions?: TimeoutWithError,\n): Promise<void> {\n\tif (container.connectionState !== ConnectionState.Connected) {\n\t\tconst executor: PromiseExecutor = (resolve, reject) => {\n\t\t\tcontainer.once(\"connected\", () => resolve());\n\t\t\tif (failOnContainerClose) {\n\t\t\t\tcontainer.once(\"closed\", (error) => reject(error));\n\t\t\t}\n\t\t};\n\n\t\treturn timeoutOptions === undefined\n\t\t\t? new Promise(executor)\n\t\t\t: timeoutPromise(executor, timeoutOptions);\n\t}\n}\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nexport async function getContainerEntryPointBackCompat<T>(container: IContainer): Promise<T> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as T;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"/\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as T;\n}\n\n/**\n * This function should ONLY be used for back compat purposes\n * Older supported versions of IDataStore do not have the \"entryPoint\" property, so we need to fallback to \"request\"\n * This function can be removed once back-compat support for IDataStore moves to 2.0.0-internal.7.0.0\n *\n * @internal\n */\nexport async function getDataStoreEntryPointBackCompat<T>(dataStore: IDataStore): Promise<T> {\n\tif (dataStore.entryPoint !== undefined) {\n\t\treturn dataStore.entryPoint.get() as Promise<T>;\n\t}\n\tconst response: IResponse = await (dataStore as any).request({ url: \"\" });\n\tassert(response.status === 200, \"empty request should return data object\");\n\treturn response.value as T;\n}\n\n/**\n * @internal\n */\nexport function toIDeltaManagerFull(\n\tdeltaManager:\n\t\t| IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>\n\t\t| IDeltaManagerErased,\n): IDeltaManagerFull {\n\tassert(\n\t\t\"inbound\" in deltaManager && \"outbound\" in deltaManager,\n\t\t\"Delta manager does not have inbound/outbound queues.\",\n\t);\n\treturn deltaManager as unknown as\n\t\t| IDeltaManagerErased\n\t\t| IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> as IDeltaManagerFull;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaderContainerTracker.d.ts","sourceRoot":"","sources":["../src/loaderContainerTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,UAAU,EACV,KAAK,WAAW,EAChB,MAAM,gDAAgD,CAAC;AAkBxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAuBlE;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,uBAAuB;IAIzD,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAHlD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;IACrE,OAAO,CAAC,kBAAkB,CAAa;gBAEV,qBAAqB,GAAE,OAAe;IAEnE;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BnD;;;;;;;;OAQG;IACU,eAAe,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE;IAexD;;;;;;;;OAQG;YACW,cAAc;IAyD5B;;;;;;OAMG;IACU,eAAe,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE;IAOxD;;;;;;OAMG;IACU,eAAe,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE;IAOxD;;OAEG;YACW,YAAY;IAgD1B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IA4BzB;;OAEG;IACH,OAAO,CAAC,UAAU;IAuElB;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAKrB"}
|
|
@@ -142,6 +142,9 @@ class LoaderContainerTracker {
|
|
|
142
142
|
this.lastProposalSeqNum = 0;
|
|
143
143
|
for (const container of this.containers.keys()) {
|
|
144
144
|
container.close();
|
|
145
|
+
// Optional chaining here is because containers made with LTS loaders don't have a dispose method or process
|
|
146
|
+
// and this package is used with various previous versions of Fluid layers in our compat testing.
|
|
147
|
+
container.dispose?.();
|
|
145
148
|
}
|
|
146
149
|
this.containers.clear();
|
|
147
150
|
// REVIEW: do we need to unpatch the loaders?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaderContainerTracker.js","sourceRoot":"","sources":["../src/loaderContainerTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAAmE;AAMnE,kEAA6D;AAC7D,0EAIqD;AACrD,oEAAgF;AAEhF,2DAAsF;AACtF,yCAAmC;AACnC,iEAA6E;AAE7E,uDAAiE;AAEjE,MAAM,OAAO,GAAG,gBAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,MAAM,SAAS,GAAG,gBAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAmBvC;;;GAGG;AACH,MAAa,sBAAsB;IAIlC,YAA6B,wBAAiC,KAAK;QAAtC,0BAAqB,GAArB,qBAAqB,CAAiB;QAHlD,eAAU,GAAG,IAAI,GAAG,EAA+B,CAA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,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC3E,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;CACD;AA1tBD,wDA0tBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDeltaQueue,\n\tIContainer,\n\ttype IHostLoader,\n} from \"@fluidframework/container-definitions/internal\";\nimport { ConnectionState } from \"@fluidframework/container-loader\";\nimport {\n\tIContainerCreateProps,\n\tIContainerLoadProps,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"@fluidframework/container-loader/internal/test/container\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { canBeCoalescedByService } from \"@fluidframework/driver-utils/internal\";\n\nimport { toIDeltaManagerFull, waitForContainerConnection } from \"./containerUtils.js\";\nimport { debug } from \"./debug.js\";\nimport { isNonEmptyArray, type NonEmptyArray } from \"./nonEmptyArrayType.js\";\nimport { IOpProcessingController } from \"./testObjectProvider.js\";\nimport { timeoutAwait, timeoutPromise } from \"./timeoutUtils.js\";\n\nconst debugOp = debug.extend(\"ops\");\nconst debugWait = debug.extend(\"wait\");\n\ninterface ContainerRecord {\n\t// A short number for debug output\n\tindex: number;\n\n\t// LoaderContainerTracker paused state\n\tpaused: boolean;\n\tpauseP?: Promise<void>; // promise for for the pause that is in progress\n\n\t// Tracking trailing no-op that may or may be acked by the server so we can discount them\n\t// See issue #5629\n\tstartTrailingNoOps: number;\n\ttrailingNoOps: number;\n\n\t// Track last proposal to ensure no unresolved proposal\n\tlastProposal: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport class LoaderContainerTracker implements IOpProcessingController {\n\tprivate readonly containers = new Map<IContainer, ContainerRecord>();\n\tprivate lastProposalSeqNum: number = 0;\n\n\tconstructor(private readonly syncSummarizerClients: boolean = false) {}\n\n\t/**\n\t * Add a loader to start to track any container created from them\n\t * @param loader - loader to start tracking any container created.\n\t */\n\tpublic add<LoaderType extends IHostLoader>(loader: LoaderType) {\n\t\t// TODO: Expose Loader API to able to intercept container creation (See issue #5114)\n\t\tconst patch = <T, C extends IContainer>(fn: (...args) => Promise<C>) => {\n\t\t\tconst boundFn = fn.bind(loader);\n\t\t\treturn async (...args: T[]) => {\n\t\t\t\tconst container = await boundFn(...args);\n\t\t\t\tthis.addContainer(container);\n\t\t\t\treturn container;\n\t\t\t};\n\t\t};\n\t\t/* eslint-disable @typescript-eslint/unbound-method */\n\t\tloader.resolve = patch(loader.resolve);\n\t\tloader.createDetachedContainer = patch(loader.createDetachedContainer);\n\t\tloader.rehydrateDetachedContainerFromSnapshot = patch(\n\t\t\tloader.rehydrateDetachedContainerFromSnapshot,\n\t\t);\n\t\t/* eslint-enable @typescript-eslint/unbound-method */\n\t}\n\n\t/**\n\t * Utility function to add container to be tracked.\n\t *\n\t * @param container - container to add\n\t */\n\tpublic addContainer(container: IContainer) {\n\t\t// don't add container that is already tracked\n\t\tif (this.containers.has(container)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Container has a `clone` method that can be used to create another container without going through\n\t\t// the Loader. Such containers won't be added by the `add` method so do it here. For example, summarizer\n\t\t// containers are created via the `clone` method.\n\t\t// Created a type with clone (which is not on IContainer and is readonly) rather than typing to any.\n\t\ttype ContainerWithClone = IContainer & {\n\t\t\tclone: (\n\t\t\t\tloadProps: IContainerLoadProps,\n\t\t\t\tcreateParamOverrides: Partial<IContainerCreateProps>,\n\t\t\t) => Promise<IContainer>;\n\t\t};\n\t\tconst containerWithClone = container as ContainerWithClone;\n\n\t\t// back-compat: Check for undefined because this function was added recently and older containers won't have it.\n\t\tif (containerWithClone.clone !== undefined) {\n\t\t\tconst patch = <T, C extends IContainer>(fn: (...args) => Promise<C>) => {\n\t\t\t\tconst boundFn = fn.bind(containerWithClone);\n\t\t\t\treturn async (...args: T[]) => {\n\t\t\t\t\tconst newContainer = await boundFn(...args);\n\t\t\t\t\tthis.addContainer(newContainer);\n\t\t\t\t\treturn newContainer;\n\t\t\t\t};\n\t\t\t};\n\t\t\tcontainerWithClone.clone = patch(containerWithClone.clone);\n\t\t}\n\n\t\t// ignore summarizer\n\t\tif (\n\t\t\t!container.deltaManager.clientDetails.capabilities.interactive &&\n\t\t\t!this.syncSummarizerClients\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = {\n\t\t\tindex: this.containers.size,\n\t\t\tpaused: false,\n\t\t\tstartTrailingNoOps: 0,\n\t\t\ttrailingNoOps: 0,\n\t\t\tlastProposal: 0,\n\t\t};\n\t\tthis.containers.set(container, record);\n\t\tthis.trackTrailingNoOps(container, record);\n\t\tthis.trackLastProposal(container);\n\t\tthis.setupTrace(container, record.index);\n\t}\n\n\t/**\n\t * Keep track of the trailing NoOp that was sent so we can discount them in the clientSequenceNumber tracking.\n\t * The server might coalesce them with other ops, or a single NoOp, or delay it if it don't think it is necessary.\n\t *\n\t * @param container - the container to track\n\t * @param record - the record to update the trailing op information\n\t */\n\tprivate trackTrailingNoOps(container: IContainer, record: ContainerRecord) {\n\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\tdeltaManagerFull.outbound.on(\"op\", (messages) => {\n\t\t\tfor (const msg of messages) {\n\t\t\t\tif (canBeCoalescedByService(msg)) {\n\t\t\t\t\t// Track the NoOp that was sent.\n\t\t\t\t\tif (record.trailingNoOps === 0) {\n\t\t\t\t\t\t// record the starting sequence number of the trailing no ops if we haven't been tracking yet.\n\t\t\t\t\t\trecord.startTrailingNoOps = msg.clientSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\trecord.trailingNoOps++;\n\t\t\t\t} else {\n\t\t\t\t\t// Other ops has been sent. We would like to see those ack'ed, so no more need to track NoOps\n\t\t\t\t\trecord.trailingNoOps = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tdeltaManagerFull.inbound.on(\"push\", (message) => {\n\t\t\t// Received the no op back, update the record if we are tracking\n\t\t\tif (\n\t\t\t\tcanBeCoalescedByService(message) &&\n\t\t\t\tmessage.clientId === container.clientId &&\n\t\t\t\trecord.trailingNoOps !== 0 &&\n\t\t\t\trecord.startTrailingNoOps <= message.clientSequenceNumber\n\t\t\t) {\n\t\t\t\t// NoOp might have coalesced and skipped ahead some sequence number\n\t\t\t\t// update the record and skip ahead as well\n\t\t\t\tconst oldStartTrailingNoOps = record.startTrailingNoOps;\n\t\t\t\trecord.startTrailingNoOps = message.clientSequenceNumber + 1;\n\t\t\t\trecord.trailingNoOps -= record.startTrailingNoOps - oldStartTrailingNoOps;\n\t\t\t}\n\t\t});\n\n\t\tcontainer.on(\"disconnected\", () => {\n\t\t\t// reset on disconnect.\n\t\t\trecord.trailingNoOps = 0;\n\t\t});\n\t}\n\n\tprivate trackLastProposal(container: IContainer) {\n\t\tcontainer.on(\"codeDetailsProposed\", (value, proposal) => {\n\t\t\tif (proposal.sequenceNumber > this.lastProposalSeqNum) {\n\t\t\t\tthis.lastProposalSeqNum = proposal.sequenceNumber;\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Reset the tracker, closing all containers and stop tracking them.\n\t */\n\tpublic reset() {\n\t\tthis.lastProposalSeqNum = 0;\n\t\tfor (const container of this.containers.keys()) {\n\t\t\tcontainer.close();\n\t\t}\n\t\tthis.containers.clear();\n\n\t\t// REVIEW: do we need to unpatch the loaders?\n\t}\n\n\t/**\n\t * Make sure all the tracked containers are synchronized.\n\t *\n\t * No isDirty (non-readonly) containers\n\t * No extra clientId in quorum of any container that is not tracked and still opened.\n\t * - i.e. no pending Join/Leave message.\n\t * No unresolved proposal (minSeqNum \\>= lastProposalSeqNum)\n\t * lastSequenceNumber of all container is the same\n\t * clientSequenceNumberObserved is the same as clientSequenceNumber sent\n\t * - this overlaps with !isDirty, but include task scheduler ops.\n\t * - Trailing NoOp is tracked and don't count as pending ops.\n\t *\n\t * Containers that are already pause will resume process and paused again once\n\t * everything is synchronized. Containers that aren't paused will remain unpaused when this\n\t * function returns.\n\t */\n\tpublic async ensureSynchronized(...containers: IContainer[]): Promise<void> {\n\t\tconst resumed = this.resumeProcessing(...containers);\n\n\t\tlet waitingSequenceNumberSynchronized: string | undefined;\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\t// yield a turn to allow side effect of resuming or the ops we just processed execute before we check\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tsetTimeout(resolve, 0);\n\t\t\t});\n\n\t\t\tconst containersToApply = this.getContainers(containers);\n\t\t\tif (!isNonEmptyArray(containersToApply)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Ignore readonly dirty containers, because it can't sent ops and nothing can be done about it being dirty\n\t\t\tconst dirtyContainers = containersToApply.filter((c) => {\n\t\t\t\tconst { deltaManager, isDirty } = c;\n\t\t\t\treturn deltaManager.readOnlyInfo.readonly !== true && isDirty;\n\t\t\t});\n\t\t\tif (dirtyContainers.length === 0) {\n\t\t\t\t// Wait for all the leave messages\n\t\t\t\tconst pendingClients = this.getPendingClients(containersToApply);\n\t\t\t\tif (pendingClients.length === 0) {\n\t\t\t\t\tconst needSync = this.needSequenceNumberSynchronize(containersToApply);\n\t\t\t\t\tif (needSync === undefined) {\n\t\t\t\t\t\t// done, we are in sync\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (waitingSequenceNumberSynchronized !== needSync.reason) {\n\t\t\t\t\t\t// Don't repeat writing to console if it is the same reason\n\t\t\t\t\t\twaitingSequenceNumberSynchronized = needSync.reason;\n\t\t\t\t\t\tdebugWait(needSync.message);\n\t\t\t\t\t}\n\t\t\t\t\t// Wait for one inbounds ops which might change the state of things\n\t\t\t\t\tawait timeoutAwait(this.waitForAnyInboundOps(containersToApply), {\n\t\t\t\t\t\terrorMsg: `Timeout on ${needSync.message}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\twaitingSequenceNumberSynchronized = undefined;\n\t\t\t\t\tawait timeoutAwait(this.waitForPendingClients(pendingClients), {\n\t\t\t\t\t\terrorMsg: \"Timeout on waiting for pending join or leave op\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Wait for all the containers to be saved\n\t\t\t\tdebugWait(\n\t\t\t\t\t`Waiting container to be saved ${this.containerIndexStrings(dirtyContainers)}`,\n\t\t\t\t);\n\t\t\t\twaitingSequenceNumberSynchronized = undefined;\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tdirtyContainers.map(async (c) =>\n\t\t\t\t\t\tPromise.race([\n\t\t\t\t\t\t\ttimeoutPromise((resolve) => c.once(\"saved\", () => resolve()), {\n\t\t\t\t\t\t\t\terrorMsg: \"Timeout on waiting a container to be saved\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tnew Promise((resolve) => c.once(\"closed\", resolve)),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Pause all container that was resumed\n\t\t// don't call pause if resumed is empty and pause everything, which is not what we want\n\t\tif (resumed.length !== 0) {\n\t\t\tawait timeoutAwait(this.pauseProcessing(...resumed), {\n\t\t\t\terrorMsg: \"Timeout on waiting for pausing all resumed containers\",\n\t\t\t});\n\t\t}\n\n\t\tdebugWait(\"Synchronized\");\n\t}\n\n\t/**\n\t * Utility to calculate the set of clientId per container in quorum that is NOT associated with\n\t * any container we tracked, indicating there is a pending join or leave op that we need to wait.\n\t *\n\t * @param containersToApply - the set of containers to check\n\t */\n\tprivate getPendingClients(containersToApply: IContainer[]) {\n\t\t// All the clientId we track should be a superset of the quorum, otherwise, we are missing\n\t\t// leave messages\n\t\tconst openedDocuments = Array.from(this.containers.keys()).filter((c) => !c.closed);\n\t\tconst openedClientId = openedDocuments.map((container) => container.clientId);\n\n\t\tconst pendingClients: [IContainer, Set<string>][] = [];\n\t\tcontainersToApply.forEach((container) => {\n\t\t\tconst pendingClientId = new Set<string>();\n\t\t\tconst quorum = container.getQuorum();\n\t\t\tquorum.getMembers().forEach((client, clientId) => {\n\t\t\t\t// ignore summarizer\n\t\t\t\tif (!client.client.details.capabilities.interactive && !this.syncSummarizerClients) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!openedClientId.includes(clientId)) {\n\t\t\t\t\tpendingClientId.add(clientId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (pendingClientId.size !== 0) {\n\t\t\t\tpendingClients.push([container, pendingClientId]);\n\t\t\t}\n\t\t});\n\t\treturn pendingClients;\n\t}\n\n\t/**\n\t * Utility to check synchronization based on sequence number\n\t * See ensureSynchronized for more detail\n\t *\n\t * @param containersToApply - the set of containers to check\n\t */\n\tprivate needSequenceNumberSynchronize(containersToApply: NonEmptyArray<IContainer>) {\n\t\t// If there is a pending proposal, wait for it to be accepted\n\t\tconst minSeqNum = containersToApply[0].deltaManager.minimumSequenceNumber;\n\t\tif (minSeqNum < this.lastProposalSeqNum) {\n\t\t\treturn {\n\t\t\t\treason: \"Proposal\",\n\t\t\t\tmessage: `waiting for MSN to advance to proposal at sequence number ${this.lastProposalSeqNum}`,\n\t\t\t};\n\t\t}\n\n\t\t// clientSequenceNumber check detects ops in flight, both on the wire and in the outbound queue\n\t\t// We need both client sequence number and isDirty check because:\n\t\t// - Currently isDirty flag ignores ops for task scheduler, so we need the client sequence number check\n\t\t// - But isDirty flags include ops during forceReadonly and disconnected, because we don't submit\n\t\t// the ops in the first place, clientSequenceNumber is not assigned\n\n\t\tconst containerWithInflightOps = containersToApply.filter((container) => {\n\t\t\tif (container.deltaManager.readOnlyInfo.readonly === true) {\n\t\t\t\t// Ignore readonly container. the clientSeqNum and clientSeqNumObserved might be out of sync\n\t\t\t\t// because we transition to readonly when outbound is not empty or the in transit op got lost\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// Note that in read only mode, the op won't be submitted\n\t\t\tlet deltaManager = container.deltaManager as any;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst { trailingNoOps } = this.containers.get(container)!;\n\t\t\t// Back-compat: lastSubmittedClientId/clientSequenceNumber/clientSequenceNumberObserved moved to ConnectionManager in 0.53\n\t\t\tif (!(\"clientSequenceNumber\" in deltaManager)) {\n\t\t\t\tdeltaManager = deltaManager.connectionManager;\n\t\t\t}\n\t\t\tassert(\"clientSequenceNumber\" in deltaManager, \"no clientSequenceNumber\");\n\t\t\tassert(\"clientSequenceNumberObserved\" in deltaManager, \"no clientSequenceNumber\");\n\t\t\t// If last submittedClientId isn't the current clientId, then we haven't send any ops\n\t\t\treturn (\n\t\t\t\tdeltaManager.lastSubmittedClientId === container.clientId &&\n\t\t\t\tdeltaManager.clientSequenceNumber !==\n\t\t\t\t\t(deltaManager.clientSequenceNumberObserved as number) + trailingNoOps\n\t\t\t);\n\t\t});\n\n\t\tif (containerWithInflightOps.length !== 0) {\n\t\t\treturn {\n\t\t\t\treason: \"InflightOps\",\n\t\t\t\tmessage: `waiting for containers with inflight ops: ${this.containerIndexStrings(\n\t\t\t\t\tcontainerWithInflightOps,\n\t\t\t\t)}`,\n\t\t\t};\n\t\t}\n\n\t\t// Check to see if all the container has process the same number of ops.\n\t\tconst maxSeqNum = Math.max(\n\t\t\t...containersToApply.map((c) => c.deltaManager.lastSequenceNumber),\n\t\t);\n\t\tconst containerWithPendingIncoming = containersToApply.filter(\n\t\t\t(c) => c.deltaManager.lastSequenceNumber !== maxSeqNum,\n\t\t);\n\t\tif (containerWithPendingIncoming.length !== 0) {\n\t\t\treturn {\n\t\t\t\treason: \"Pending\",\n\t\t\t\tmessage: `waiting for containers with pending incoming ops up to sequence number ${maxSeqNum}: ${this.containerIndexStrings(\n\t\t\t\t\tcontainerWithPendingIncoming,\n\t\t\t\t)}`,\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate containerIndexStrings(containers: IContainer[]) {\n\t\treturn containers.map(\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(c) => this.containers.get(c)!.index,\n\t\t);\n\t}\n\n\t/**\n\t * Utility to wait for any clientId in quorum that is NOT associated with any container we\n\t * tracked, indicating there is a pending join or leave op that we need to wait.\n\t *\n\t * Note that this function doesn't account for container that got added after we started waiting\n\t *\n\t * @param containersToApply - the set of containers to wait for any inbound ops for\n\t */\n\tprivate async waitForPendingClients(pendingClients: [IContainer, Set<string>][]) {\n\t\tconst unconnectedClients = Array.from(this.containers.keys()).filter(\n\t\t\t(c) => !c.closed && c.connectionState !== ConnectionState.Connected,\n\t\t);\n\t\treturn Promise.all(\n\t\t\tpendingClients.map(async ([container, pendingClientId]) => {\n\t\t\t\treturn new Promise<void>((resolve) => {\n\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\tunconnectedClients.forEach((c) => c.off(\"connected\", handler));\n\t\t\t\t\t\tcontainer.getQuorum().off(\"removeMember\", handler);\n\t\t\t\t\t};\n\t\t\t\t\tconst handler = (clientId: string) => {\n\t\t\t\t\t\tpendingClientId.delete(clientId);\n\t\t\t\t\t\tif (pendingClientId.size === 0) {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst index = this.containers.get(container)!.index;\n\t\t\t\t\tdebugWait(\n\t\t\t\t\t\t`${index}: Waiting for pending clients ${Array.from(pendingClientId.keys())}`,\n\t\t\t\t\t);\n\t\t\t\t\tunconnectedClients.forEach((c) => c.on(\"connected\", handler));\n\t\t\t\t\tcontainer.getQuorum().on(\"removeMember\", handler);\n\t\t\t\t\tcontainer.on(\"closed\", () => {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Utility to wait for any inbound ops from a set of containers\n\t * @param containersToApply - the set of containers to wait for any inbound ops for\n\t */\n\tprivate async waitForAnyInboundOps(containersToApply: IContainer[]) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tconst handler = () => {\n\t\t\t\tcontainersToApply.map((c) => {\n\t\t\t\t\ttoIDeltaManagerFull(c.deltaManager).inbound.off(\"push\", handler);\n\t\t\t\t});\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tcontainersToApply.map((c) => {\n\t\t\t\ttoIDeltaManagerFull(c.deltaManager).inbound.on(\"push\", handler);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Resume all queue activities on all paused tracked containers and return them\n\t */\n\tpublic resumeProcessing(...containers: IContainer[]) {\n\t\tconst resumed: IContainer[] = [];\n\t\tconst containersToApply = this.getContainers(containers);\n\t\tfor (const container of containersToApply) {\n\t\t\tconst record = this.containers.get(container);\n\t\t\tassert(\n\t\t\t\trecord?.pauseP === undefined,\n\t\t\t\t\"Cannot resume container while pausing is in progress\",\n\t\t\t);\n\t\t\tif (record?.paused === true) {\n\t\t\t\tdebugWait(`${record.index}: container resumed`);\n\t\t\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\t\t\tdeltaManagerFull.inbound.resume();\n\t\t\t\tdeltaManagerFull.outbound.resume();\n\t\t\t\tresumed.push(container);\n\t\t\t\trecord.paused = false;\n\t\t\t}\n\t\t}\n\t\treturn resumed;\n\t}\n\n\t/**\n\t * Pause all queue activities on the containers given, or all tracked containers\n\t * Any containers given that is not tracked will be ignored.\n\t *\n\t * When a container is paused, it is assumed that we want fine grain control over op\n\t * sequencing. This function will prepare the container and force it into write mode to\n\t * avoid missing join messages or change the sequence of event when switching from read to\n\t * write mode.\n\t */\n\tpublic async pauseProcessing(...containers: IContainer[]) {\n\t\tconst waitP: Promise<void>[] = [];\n\t\tconst containersToApply = this.getContainers(containers);\n\t\tfor (const container of containersToApply) {\n\t\t\tconst record = this.containers.get(container);\n\t\t\tif (record !== undefined && !record.paused) {\n\t\t\t\tif (record.pauseP === undefined) {\n\t\t\t\t\trecord.pauseP = this.pauseContainer(container, record);\n\t\t\t\t}\n\t\t\t\twaitP.push(record.pauseP);\n\t\t\t}\n\t\t}\n\t\tawait Promise.all(waitP);\n\t}\n\n\t/**\n\t * When a container is paused, it is assumed that we want fine grain control over op\n\t * sequencing. This function will prepare the container and force it into write mode to\n\t * avoid missing join messages or change the sequence of event when switching from read to\n\t * write mode.\n\t *\n\t * @param container - the container to pause\n\t * @param record - the record for the container\n\t */\n\tprivate async pauseContainer(container: IContainer, record: ContainerRecord) {\n\t\tdebugWait(`${record.index}: pausing container`);\n\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\tassert(!deltaManagerFull.outbound.paused, \"Container should not be paused yet\");\n\t\tassert(!deltaManagerFull.inbound.paused, \"Container should not be paused yet\");\n\n\t\t// Pause outbound\n\t\tdebugWait(`${record.index}: pausing container outbound queues`);\n\t\tawait deltaManagerFull.outbound.pause();\n\n\t\t// Ensure the container is connected first.\n\t\tif (container.connectionState !== ConnectionState.Connected) {\n\t\t\tdebugWait(`${record.index}: Wait for container connection`);\n\t\t\tawait waitForContainerConnection(container);\n\t\t}\n\n\t\t// Check if the container is in write mode\n\t\tif (!container.deltaManager.active) {\n\t\t\tlet proposalP: Promise<boolean> | undefined;\n\t\t\tif (deltaManagerFull.outbound.idle) {\n\t\t\t\t// Need to generate an op to force write mode\n\t\t\t\tdebugWait(`${record.index}: container force write connection`);\n\t\t\t\tconst maybeContainer = container as Partial<IContainer>;\n\t\t\t\tconst codeProposal = maybeContainer.getLoadedCodeDetails\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tcontainer.getLoadedCodeDetails()!\n\t\t\t\t\t: (container as any).chaincodePackage;\n\n\t\t\t\tproposalP = container.proposeCodeDetails(codeProposal);\n\t\t\t}\n\n\t\t\t// Wait for nack\n\t\t\tdebugWait(`${record.index}: Wait for container disconnect`);\n\t\t\tdeltaManagerFull.outbound.resume();\n\t\t\tawait new Promise<void>((resolve) => container.once(\"disconnected\", resolve));\n\t\t\tconst accepted = proposalP ? await proposalP : false;\n\t\t\tassert(!accepted, \"A proposal in read mode should be rejected\");\n\t\t\tawait deltaManagerFull.outbound.pause();\n\n\t\t\t// Ensure the container is reconnect.\n\t\t\tif (container.connectionState !== ConnectionState.Connected) {\n\t\t\t\tdebugWait(`${record.index}: Wait for container reconnection`);\n\t\t\t\tawait waitForContainerConnection(container);\n\t\t\t}\n\t\t}\n\n\t\tdebugWait(`${record.index}: pausing container inbound queues`);\n\n\t\t// Pause inbound\n\t\tawait deltaManagerFull.inbound.pause();\n\n\t\tdebugWait(`${record.index}: container paused`);\n\n\t\trecord.pauseP = undefined;\n\t\trecord.paused = true;\n\t}\n\n\t/**\n\t * Pause all queue activities on all tracked containers, and resume only\n\t * inbound to process ops until it is idle. All queues are left in the paused state\n\t * after the function.\n\t *\n\t * Pausing will switch the container to write mode. See `pauseProcessing`\n\t */\n\tpublic async processIncoming(...containers: IContainer[]) {\n\t\treturn this.processQueue(\n\t\t\tcontainers,\n\t\t\t(container) => toIDeltaManagerFull(container.deltaManager).inbound,\n\t\t);\n\t}\n\n\t/**\n\t * Pause all queue activities on all tracked containers, and resume only\n\t * outbound to process ops until it is idle. All queues are left in the paused state\n\t * after the function.\n\t *\n\t * Pausing will switch the container to write mode. See `pauseProcessing`\n\t */\n\tpublic async processOutgoing(...containers: IContainer[]) {\n\t\treturn this.processQueue(\n\t\t\tcontainers,\n\t\t\t(container) => toIDeltaManagerFull(container.deltaManager).outbound,\n\t\t);\n\t}\n\n\t/**\n\t * Implementation of processIncoming and processOutgoing\n\t */\n\tprivate async processQueue<U>(\n\t\tcontainers: IContainer[],\n\t\tgetQueue: (container: IContainer) => IDeltaQueue<U>,\n\t) {\n\t\tawait this.pauseProcessing(...containers);\n\t\tconst resumed: IDeltaQueue<U>[] = [];\n\n\t\tconst containersToApply = this.getContainers(containers);\n\n\t\tconst inflightTracker = new Map<IContainer, number>();\n\t\tconst cleanup: (() => void)[] = [];\n\t\tfor (const container of containersToApply) {\n\t\t\tassert(\n\t\t\t\tcontainer.deltaManager.active,\n\t\t\t\t\"Container should be connected in write mode already\",\n\t\t\t);\n\n\t\t\tconst queue = getQueue(container);\n\n\t\t\t// track the outgoing ops (if any) to make sure they make the round trip to at least to the same client\n\t\t\t// to make sure they are sequenced.\n\t\t\tcleanup.push(this.setupInOutTracker(container, inflightTracker));\n\t\t\tqueue.resume();\n\t\t\tresumed.push(queue);\n\t\t}\n\n\t\twhile (resumed.some((queue) => !queue.idle)) {\n\t\t\tdebugWait(\"Wait until queue is idle\");\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tsetTimeout(resolve, 0);\n\t\t\t});\n\t\t}\n\n\t\t// Make sure all the op that we sent out are acked first\n\t\t// This is no op if we are processing incoming\n\t\tif (inflightTracker.size) {\n\t\t\tdebugWait(\"Wait for inflight ops\");\n\t\t\tdo {\n\t\t\t\tawait this.waitForAnyInboundOps(containersToApply);\n\t\t\t} while (inflightTracker.size);\n\t\t}\n\n\t\t// remove the handlers\n\t\tcleanup.forEach((clean) => clean());\n\n\t\tawait Promise.all(resumed.map(async (queue) => queue.pause()));\n\t}\n\n\t/**\n\t * Utility to set up listener to track the outbound ops until it round trip back\n\t * Returns a function to remove the handler after it is done.\n\t *\n\t * @param container - the container to setup\n\t * @param inflightTracker - a map to track the clientSequenceNumber per container it expect to get ops back\n\t */\n\tprivate setupInOutTracker(container: IContainer, inflightTracker: Map<IContainer, number>) {\n\t\tconst outHandler = (messages: IDocumentMessage[]) => {\n\t\t\tfor (const message of messages) {\n\t\t\t\tif (!canBeCoalescedByService(message)) {\n\t\t\t\t\tinflightTracker.set(container, message.clientSequenceNumber);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst inHandler = (message: ISequencedDocumentMessage) => {\n\t\t\tif (\n\t\t\t\t!canBeCoalescedByService(message) &&\n\t\t\t\tmessage.clientId === container.clientId &&\n\t\t\t\tinflightTracker.get(container) === message.clientSequenceNumber\n\t\t\t) {\n\t\t\t\tinflightTracker.delete(container);\n\t\t\t}\n\t\t};\n\n\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\tdeltaManagerFull.outbound.on(\"op\", outHandler);\n\t\tdeltaManagerFull.inbound.on(\"push\", inHandler);\n\n\t\treturn () => {\n\t\t\tdeltaManagerFull.outbound.off(\"op\", outHandler);\n\t\t\tdeltaManagerFull.inbound.off(\"push\", inHandler);\n\t\t};\n\t}\n\n\t/**\n\t * Setup debug traces for connection and ops\n\t */\n\tprivate setupTrace(container: IContainer, index: number) {\n\t\tif (debugOp.enabled) {\n\t\t\tconst getContentsString = (type: string, msgContents: any) => {\n\t\t\t\ttry {\n\t\t\t\t\tif (type !== MessageType.Operation) {\n\t\t\t\t\t\tif (typeof msgContents === \"string\") {\n\t\t\t\t\t\t\treturn msgContents;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn JSON.stringify(msgContents);\n\t\t\t\t\t}\n\t\t\t\t\tlet address = \"\";\n\n\t\t\t\t\t// contents comes in the wire as JSON string (\"push\" event)\n\t\t\t\t\t// But already parsed when apply (\"op\" event)\n\t\t\t\t\tlet contents =\n\t\t\t\t\t\ttypeof msgContents === \"string\" ? JSON.parse(msgContents) : msgContents;\n\t\t\t\t\twhile (contents !== undefined && contents !== null) {\n\t\t\t\t\t\tif (contents.contents?.address !== undefined) {\n\t\t\t\t\t\t\taddress += `/${contents.contents.address}`;\n\t\t\t\t\t\t\tcontents = contents.contents.contents;\n\t\t\t\t\t\t} else if (contents.content?.address !== undefined) {\n\t\t\t\t\t\t\taddress += `/${contents.content.address}`;\n\t\t\t\t\t\t\tcontents = contents.content.contents;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (address) {\n\t\t\t\t\t\treturn `${address} ${JSON.stringify(contents)}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn JSON.stringify(contents);\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\treturn `${e.message}: ${e.stack}`;\n\t\t\t\t}\n\t\t\t};\n\t\t\tdebugOp(`${index}: ADD: clientId: ${container.clientId}`);\n\t\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\t\tdeltaManagerFull.outbound.on(\"op\", (messages) => {\n\t\t\t\tfor (const msg of messages) {\n\t\t\t\t\tdebugOp(\n\t\t\t\t\t\t`${index}: OUT: ` +\n\t\t\t\t\t\t\t`cli: ${msg.clientSequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`rsq: ${msg.referenceSequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`${msg.type} ${getContentsString(msg.type, msg.contents)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst getInboundHandler = (type: string) => {\n\t\t\t\treturn (msg: ISequencedDocumentMessage) => {\n\t\t\t\t\tconst clientSeq =\n\t\t\t\t\t\tmsg.clientId === container.clientId\n\t\t\t\t\t\t\t? `cli: ${msg.clientSequenceNumber.toString().padStart(3)}`\n\t\t\t\t\t\t\t: \" \";\n\t\t\t\t\tdebugOp(\n\t\t\t\t\t\t`${index}: ${type}: seq: ${msg.sequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`${clientSeq} min: ${msg.minimumSequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`${msg.type} ${getContentsString(msg.type, msg.contents)}`,\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t};\n\t\t\tdeltaManagerFull.inbound.on(\"push\", getInboundHandler(\"IN \"));\n\t\t\tdeltaManagerFull.inbound.on(\"op\", getInboundHandler(\"OP \"));\n\t\t\tcontainer.deltaManager.on(\"connect\", (details) => {\n\t\t\t\tdebugOp(`${index}: CON: clientId: ${details.clientId}`);\n\t\t\t});\n\t\t\tcontainer.deltaManager.on(\"disconnect\", (reason) => {\n\t\t\t\tdebugOp(`${index}: DIS: ${reason}`);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Filter out the opened containers based on param.\n\t * @param containers - The container to filter to. If the array is empty, it means don't filter and return\n\t * all open containers.\n\t */\n\tprivate getContainers(containers: IContainer[]) {\n\t\tconst containersToApply =\n\t\t\tcontainers.length === 0 ? Array.from(this.containers.keys()) : containers;\n\t\treturn containersToApply.filter((container) => !container.closed);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loaderContainerTracker.js","sourceRoot":"","sources":["../src/loaderContainerTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAAmE;AAMnE,kEAA6D;AAC7D,0EAIqD;AACrD,oEAAgF;AAEhF,2DAAsF;AACtF,yCAAmC;AACnC,iEAA6E;AAE7E,uDAAiE;AAEjE,MAAM,OAAO,GAAG,gBAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,MAAM,SAAS,GAAG,gBAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAmBvC;;;GAGG;AACH,MAAa,sBAAsB;IAIlC,YAA6B,wBAAiC,KAAK;QAAtC,0BAAqB,GAArB,qBAAqB,CAAiB;QAHlD,eAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC7D,uBAAkB,GAAW,CAAC,CAAC;IAE+B,CAAC;IAEvE;;;OAGG;IACI,GAAG,CAAiC,MAAkB;QAC5D,oFAAoF;QACpF,MAAM,KAAK,GAAG,CAA0B,EAA2B,EAAE,EAAE;YACtE,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAChC,OAAO,KAAK,EAAE,GAAG,IAAS,EAAE,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AAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;CACD;AA7tBD,wDA6tBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDeltaQueue,\n\tIContainer,\n\ttype IHostLoader,\n} from \"@fluidframework/container-definitions/internal\";\nimport { ConnectionState } from \"@fluidframework/container-loader\";\nimport {\n\tIContainerCreateProps,\n\tIContainerLoadProps,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"@fluidframework/container-loader/internal/test/container\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { canBeCoalescedByService } from \"@fluidframework/driver-utils/internal\";\n\nimport { toIDeltaManagerFull, waitForContainerConnection } from \"./containerUtils.js\";\nimport { debug } from \"./debug.js\";\nimport { isNonEmptyArray, type NonEmptyArray } from \"./nonEmptyArrayType.js\";\nimport { IOpProcessingController } from \"./testObjectProvider.js\";\nimport { timeoutAwait, timeoutPromise } from \"./timeoutUtils.js\";\n\nconst debugOp = debug.extend(\"ops\");\nconst debugWait = debug.extend(\"wait\");\n\ninterface ContainerRecord {\n\t// A short number for debug output\n\tindex: number;\n\n\t// LoaderContainerTracker paused state\n\tpaused: boolean;\n\tpauseP?: Promise<void>; // promise for for the pause that is in progress\n\n\t// Tracking trailing no-op that may or may be acked by the server so we can discount them\n\t// See issue #5629\n\tstartTrailingNoOps: number;\n\ttrailingNoOps: number;\n\n\t// Track last proposal to ensure no unresolved proposal\n\tlastProposal: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport class LoaderContainerTracker implements IOpProcessingController {\n\tprivate readonly containers = new Map<IContainer, ContainerRecord>();\n\tprivate lastProposalSeqNum: number = 0;\n\n\tconstructor(private readonly syncSummarizerClients: boolean = false) {}\n\n\t/**\n\t * Add a loader to start to track any container created from them\n\t * @param loader - loader to start tracking any container created.\n\t */\n\tpublic add<LoaderType extends IHostLoader>(loader: LoaderType) {\n\t\t// TODO: Expose Loader API to able to intercept container creation (See issue #5114)\n\t\tconst patch = <T, C extends IContainer>(fn: (...args) => Promise<C>) => {\n\t\t\tconst boundFn = fn.bind(loader);\n\t\t\treturn async (...args: T[]) => {\n\t\t\t\tconst container = await boundFn(...args);\n\t\t\t\tthis.addContainer(container);\n\t\t\t\treturn container;\n\t\t\t};\n\t\t};\n\t\t/* eslint-disable @typescript-eslint/unbound-method */\n\t\tloader.resolve = patch(loader.resolve);\n\t\tloader.createDetachedContainer = patch(loader.createDetachedContainer);\n\t\tloader.rehydrateDetachedContainerFromSnapshot = patch(\n\t\t\tloader.rehydrateDetachedContainerFromSnapshot,\n\t\t);\n\t\t/* eslint-enable @typescript-eslint/unbound-method */\n\t}\n\n\t/**\n\t * Utility function to add container to be tracked.\n\t *\n\t * @param container - container to add\n\t */\n\tpublic addContainer(container: IContainer) {\n\t\t// don't add container that is already tracked\n\t\tif (this.containers.has(container)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Container has a `clone` method that can be used to create another container without going through\n\t\t// the Loader. Such containers won't be added by the `add` method so do it here. For example, summarizer\n\t\t// containers are created via the `clone` method.\n\t\t// Created a type with clone (which is not on IContainer and is readonly) rather than typing to any.\n\t\ttype ContainerWithClone = IContainer & {\n\t\t\tclone: (\n\t\t\t\tloadProps: IContainerLoadProps,\n\t\t\t\tcreateParamOverrides: Partial<IContainerCreateProps>,\n\t\t\t) => Promise<IContainer>;\n\t\t};\n\t\tconst containerWithClone = container as ContainerWithClone;\n\n\t\t// back-compat: Check for undefined because this function was added recently and older containers won't have it.\n\t\tif (containerWithClone.clone !== undefined) {\n\t\t\tconst patch = <T, C extends IContainer>(fn: (...args) => Promise<C>) => {\n\t\t\t\tconst boundFn = fn.bind(containerWithClone);\n\t\t\t\treturn async (...args: T[]) => {\n\t\t\t\t\tconst newContainer = await boundFn(...args);\n\t\t\t\t\tthis.addContainer(newContainer);\n\t\t\t\t\treturn newContainer;\n\t\t\t\t};\n\t\t\t};\n\t\t\tcontainerWithClone.clone = patch(containerWithClone.clone);\n\t\t}\n\n\t\t// ignore summarizer\n\t\tif (\n\t\t\t!container.deltaManager.clientDetails.capabilities.interactive &&\n\t\t\t!this.syncSummarizerClients\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = {\n\t\t\tindex: this.containers.size,\n\t\t\tpaused: false,\n\t\t\tstartTrailingNoOps: 0,\n\t\t\ttrailingNoOps: 0,\n\t\t\tlastProposal: 0,\n\t\t};\n\t\tthis.containers.set(container, record);\n\t\tthis.trackTrailingNoOps(container, record);\n\t\tthis.trackLastProposal(container);\n\t\tthis.setupTrace(container, record.index);\n\t}\n\n\t/**\n\t * Keep track of the trailing NoOp that was sent so we can discount them in the clientSequenceNumber tracking.\n\t * The server might coalesce them with other ops, or a single NoOp, or delay it if it don't think it is necessary.\n\t *\n\t * @param container - the container to track\n\t * @param record - the record to update the trailing op information\n\t */\n\tprivate trackTrailingNoOps(container: IContainer, record: ContainerRecord) {\n\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\tdeltaManagerFull.outbound.on(\"op\", (messages) => {\n\t\t\tfor (const msg of messages) {\n\t\t\t\tif (canBeCoalescedByService(msg)) {\n\t\t\t\t\t// Track the NoOp that was sent.\n\t\t\t\t\tif (record.trailingNoOps === 0) {\n\t\t\t\t\t\t// record the starting sequence number of the trailing no ops if we haven't been tracking yet.\n\t\t\t\t\t\trecord.startTrailingNoOps = msg.clientSequenceNumber;\n\t\t\t\t\t}\n\t\t\t\t\trecord.trailingNoOps++;\n\t\t\t\t} else {\n\t\t\t\t\t// Other ops has been sent. We would like to see those ack'ed, so no more need to track NoOps\n\t\t\t\t\trecord.trailingNoOps = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tdeltaManagerFull.inbound.on(\"push\", (message) => {\n\t\t\t// Received the no op back, update the record if we are tracking\n\t\t\tif (\n\t\t\t\tcanBeCoalescedByService(message) &&\n\t\t\t\tmessage.clientId === container.clientId &&\n\t\t\t\trecord.trailingNoOps !== 0 &&\n\t\t\t\trecord.startTrailingNoOps <= message.clientSequenceNumber\n\t\t\t) {\n\t\t\t\t// NoOp might have coalesced and skipped ahead some sequence number\n\t\t\t\t// update the record and skip ahead as well\n\t\t\t\tconst oldStartTrailingNoOps = record.startTrailingNoOps;\n\t\t\t\trecord.startTrailingNoOps = message.clientSequenceNumber + 1;\n\t\t\t\trecord.trailingNoOps -= record.startTrailingNoOps - oldStartTrailingNoOps;\n\t\t\t}\n\t\t});\n\n\t\tcontainer.on(\"disconnected\", () => {\n\t\t\t// reset on disconnect.\n\t\t\trecord.trailingNoOps = 0;\n\t\t});\n\t}\n\n\tprivate trackLastProposal(container: IContainer) {\n\t\tcontainer.on(\"codeDetailsProposed\", (value, proposal) => {\n\t\t\tif (proposal.sequenceNumber > this.lastProposalSeqNum) {\n\t\t\t\tthis.lastProposalSeqNum = proposal.sequenceNumber;\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Reset the tracker, closing all containers and stop tracking them.\n\t */\n\tpublic reset() {\n\t\tthis.lastProposalSeqNum = 0;\n\t\tfor (const container of this.containers.keys()) {\n\t\t\tcontainer.close();\n\t\t\t// Optional chaining here is because containers made with LTS loaders don't have a dispose method or process\n\t\t\t// and this package is used with various previous versions of Fluid layers in our compat testing.\n\t\t\tcontainer.dispose?.();\n\t\t}\n\t\tthis.containers.clear();\n\n\t\t// REVIEW: do we need to unpatch the loaders?\n\t}\n\n\t/**\n\t * Make sure all the tracked containers are synchronized.\n\t *\n\t * No isDirty (non-readonly) containers\n\t * No extra clientId in quorum of any container that is not tracked and still opened.\n\t * - i.e. no pending Join/Leave message.\n\t * No unresolved proposal (minSeqNum \\>= lastProposalSeqNum)\n\t * lastSequenceNumber of all container is the same\n\t * clientSequenceNumberObserved is the same as clientSequenceNumber sent\n\t * - this overlaps with !isDirty, but include task scheduler ops.\n\t * - Trailing NoOp is tracked and don't count as pending ops.\n\t *\n\t * Containers that are already pause will resume process and paused again once\n\t * everything is synchronized. Containers that aren't paused will remain unpaused when this\n\t * function returns.\n\t */\n\tpublic async ensureSynchronized(...containers: IContainer[]): Promise<void> {\n\t\tconst resumed = this.resumeProcessing(...containers);\n\n\t\tlet waitingSequenceNumberSynchronized: string | undefined;\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\t// yield a turn to allow side effect of resuming or the ops we just processed execute before we check\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tsetTimeout(resolve, 0);\n\t\t\t});\n\n\t\t\tconst containersToApply = this.getContainers(containers);\n\t\t\tif (!isNonEmptyArray(containersToApply)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Ignore readonly dirty containers, because it can't sent ops and nothing can be done about it being dirty\n\t\t\tconst dirtyContainers = containersToApply.filter((c) => {\n\t\t\t\tconst { deltaManager, isDirty } = c;\n\t\t\t\treturn deltaManager.readOnlyInfo.readonly !== true && isDirty;\n\t\t\t});\n\t\t\tif (dirtyContainers.length === 0) {\n\t\t\t\t// Wait for all the leave messages\n\t\t\t\tconst pendingClients = this.getPendingClients(containersToApply);\n\t\t\t\tif (pendingClients.length === 0) {\n\t\t\t\t\tconst needSync = this.needSequenceNumberSynchronize(containersToApply);\n\t\t\t\t\tif (needSync === undefined) {\n\t\t\t\t\t\t// done, we are in sync\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (waitingSequenceNumberSynchronized !== needSync.reason) {\n\t\t\t\t\t\t// Don't repeat writing to console if it is the same reason\n\t\t\t\t\t\twaitingSequenceNumberSynchronized = needSync.reason;\n\t\t\t\t\t\tdebugWait(needSync.message);\n\t\t\t\t\t}\n\t\t\t\t\t// Wait for one inbounds ops which might change the state of things\n\t\t\t\t\tawait timeoutAwait(this.waitForAnyInboundOps(containersToApply), {\n\t\t\t\t\t\terrorMsg: `Timeout on ${needSync.message}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\twaitingSequenceNumberSynchronized = undefined;\n\t\t\t\t\tawait timeoutAwait(this.waitForPendingClients(pendingClients), {\n\t\t\t\t\t\terrorMsg: \"Timeout on waiting for pending join or leave op\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Wait for all the containers to be saved\n\t\t\t\tdebugWait(\n\t\t\t\t\t`Waiting container to be saved ${this.containerIndexStrings(dirtyContainers)}`,\n\t\t\t\t);\n\t\t\t\twaitingSequenceNumberSynchronized = undefined;\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tdirtyContainers.map(async (c) =>\n\t\t\t\t\t\tPromise.race([\n\t\t\t\t\t\t\ttimeoutPromise((resolve) => c.once(\"saved\", () => resolve()), {\n\t\t\t\t\t\t\t\terrorMsg: \"Timeout on waiting a container to be saved\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tnew Promise((resolve) => c.once(\"closed\", resolve)),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Pause all container that was resumed\n\t\t// don't call pause if resumed is empty and pause everything, which is not what we want\n\t\tif (resumed.length !== 0) {\n\t\t\tawait timeoutAwait(this.pauseProcessing(...resumed), {\n\t\t\t\terrorMsg: \"Timeout on waiting for pausing all resumed containers\",\n\t\t\t});\n\t\t}\n\n\t\tdebugWait(\"Synchronized\");\n\t}\n\n\t/**\n\t * Utility to calculate the set of clientId per container in quorum that is NOT associated with\n\t * any container we tracked, indicating there is a pending join or leave op that we need to wait.\n\t *\n\t * @param containersToApply - the set of containers to check\n\t */\n\tprivate getPendingClients(containersToApply: IContainer[]) {\n\t\t// All the clientId we track should be a superset of the quorum, otherwise, we are missing\n\t\t// leave messages\n\t\tconst openedDocuments = Array.from(this.containers.keys()).filter((c) => !c.closed);\n\t\tconst openedClientId = openedDocuments.map((container) => container.clientId);\n\n\t\tconst pendingClients: [IContainer, Set<string>][] = [];\n\t\tcontainersToApply.forEach((container) => {\n\t\t\tconst pendingClientId = new Set<string>();\n\t\t\tconst quorum = container.getQuorum();\n\t\t\tquorum.getMembers().forEach((client, clientId) => {\n\t\t\t\t// ignore summarizer\n\t\t\t\tif (!client.client.details.capabilities.interactive && !this.syncSummarizerClients) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!openedClientId.includes(clientId)) {\n\t\t\t\t\tpendingClientId.add(clientId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (pendingClientId.size !== 0) {\n\t\t\t\tpendingClients.push([container, pendingClientId]);\n\t\t\t}\n\t\t});\n\t\treturn pendingClients;\n\t}\n\n\t/**\n\t * Utility to check synchronization based on sequence number\n\t * See ensureSynchronized for more detail\n\t *\n\t * @param containersToApply - the set of containers to check\n\t */\n\tprivate needSequenceNumberSynchronize(containersToApply: NonEmptyArray<IContainer>) {\n\t\t// If there is a pending proposal, wait for it to be accepted\n\t\tconst minSeqNum = containersToApply[0].deltaManager.minimumSequenceNumber;\n\t\tif (minSeqNum < this.lastProposalSeqNum) {\n\t\t\treturn {\n\t\t\t\treason: \"Proposal\",\n\t\t\t\tmessage: `waiting for MSN to advance to proposal at sequence number ${this.lastProposalSeqNum}`,\n\t\t\t};\n\t\t}\n\n\t\t// clientSequenceNumber check detects ops in flight, both on the wire and in the outbound queue\n\t\t// We need both client sequence number and isDirty check because:\n\t\t// - Currently isDirty flag ignores ops for task scheduler, so we need the client sequence number check\n\t\t// - But isDirty flags include ops during forceReadonly and disconnected, because we don't submit\n\t\t// the ops in the first place, clientSequenceNumber is not assigned\n\n\t\tconst containerWithInflightOps = containersToApply.filter((container) => {\n\t\t\tif (container.deltaManager.readOnlyInfo.readonly === true) {\n\t\t\t\t// Ignore readonly container. the clientSeqNum and clientSeqNumObserved might be out of sync\n\t\t\t\t// because we transition to readonly when outbound is not empty or the in transit op got lost\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// Note that in read only mode, the op won't be submitted\n\t\t\tlet deltaManager = container.deltaManager as any;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst { trailingNoOps } = this.containers.get(container)!;\n\t\t\t// Back-compat: lastSubmittedClientId/clientSequenceNumber/clientSequenceNumberObserved moved to ConnectionManager in 0.53\n\t\t\tif (!(\"clientSequenceNumber\" in deltaManager)) {\n\t\t\t\tdeltaManager = deltaManager.connectionManager;\n\t\t\t}\n\t\t\tassert(\"clientSequenceNumber\" in deltaManager, \"no clientSequenceNumber\");\n\t\t\tassert(\"clientSequenceNumberObserved\" in deltaManager, \"no clientSequenceNumber\");\n\t\t\t// If last submittedClientId isn't the current clientId, then we haven't send any ops\n\t\t\treturn (\n\t\t\t\tdeltaManager.lastSubmittedClientId === container.clientId &&\n\t\t\t\tdeltaManager.clientSequenceNumber !==\n\t\t\t\t\t(deltaManager.clientSequenceNumberObserved as number) + trailingNoOps\n\t\t\t);\n\t\t});\n\n\t\tif (containerWithInflightOps.length !== 0) {\n\t\t\treturn {\n\t\t\t\treason: \"InflightOps\",\n\t\t\t\tmessage: `waiting for containers with inflight ops: ${this.containerIndexStrings(\n\t\t\t\t\tcontainerWithInflightOps,\n\t\t\t\t)}`,\n\t\t\t};\n\t\t}\n\n\t\t// Check to see if all the container has process the same number of ops.\n\t\tconst maxSeqNum = Math.max(\n\t\t\t...containersToApply.map((c) => c.deltaManager.lastSequenceNumber),\n\t\t);\n\t\tconst containerWithPendingIncoming = containersToApply.filter(\n\t\t\t(c) => c.deltaManager.lastSequenceNumber !== maxSeqNum,\n\t\t);\n\t\tif (containerWithPendingIncoming.length !== 0) {\n\t\t\treturn {\n\t\t\t\treason: \"Pending\",\n\t\t\t\tmessage: `waiting for containers with pending incoming ops up to sequence number ${maxSeqNum}: ${this.containerIndexStrings(\n\t\t\t\t\tcontainerWithPendingIncoming,\n\t\t\t\t)}`,\n\t\t\t};\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate containerIndexStrings(containers: IContainer[]) {\n\t\treturn containers.map(\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(c) => this.containers.get(c)!.index,\n\t\t);\n\t}\n\n\t/**\n\t * Utility to wait for any clientId in quorum that is NOT associated with any container we\n\t * tracked, indicating there is a pending join or leave op that we need to wait.\n\t *\n\t * Note that this function doesn't account for container that got added after we started waiting\n\t *\n\t * @param containersToApply - the set of containers to wait for any inbound ops for\n\t */\n\tprivate async waitForPendingClients(pendingClients: [IContainer, Set<string>][]) {\n\t\tconst unconnectedClients = Array.from(this.containers.keys()).filter(\n\t\t\t(c) => !c.closed && c.connectionState !== ConnectionState.Connected,\n\t\t);\n\t\treturn Promise.all(\n\t\t\tpendingClients.map(async ([container, pendingClientId]) => {\n\t\t\t\treturn new Promise<void>((resolve) => {\n\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\tunconnectedClients.forEach((c) => c.off(\"connected\", handler));\n\t\t\t\t\t\tcontainer.getQuorum().off(\"removeMember\", handler);\n\t\t\t\t\t};\n\t\t\t\t\tconst handler = (clientId: string) => {\n\t\t\t\t\t\tpendingClientId.delete(clientId);\n\t\t\t\t\t\tif (pendingClientId.size === 0) {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst index = this.containers.get(container)!.index;\n\t\t\t\t\tdebugWait(\n\t\t\t\t\t\t`${index}: Waiting for pending clients ${Array.from(pendingClientId.keys())}`,\n\t\t\t\t\t);\n\t\t\t\t\tunconnectedClients.forEach((c) => c.on(\"connected\", handler));\n\t\t\t\t\tcontainer.getQuorum().on(\"removeMember\", handler);\n\t\t\t\t\tcontainer.on(\"closed\", () => {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Utility to wait for any inbound ops from a set of containers\n\t * @param containersToApply - the set of containers to wait for any inbound ops for\n\t */\n\tprivate async waitForAnyInboundOps(containersToApply: IContainer[]) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tconst handler = () => {\n\t\t\t\tcontainersToApply.map((c) => {\n\t\t\t\t\ttoIDeltaManagerFull(c.deltaManager).inbound.off(\"push\", handler);\n\t\t\t\t});\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tcontainersToApply.map((c) => {\n\t\t\t\ttoIDeltaManagerFull(c.deltaManager).inbound.on(\"push\", handler);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Resume all queue activities on all paused tracked containers and return them\n\t */\n\tpublic resumeProcessing(...containers: IContainer[]) {\n\t\tconst resumed: IContainer[] = [];\n\t\tconst containersToApply = this.getContainers(containers);\n\t\tfor (const container of containersToApply) {\n\t\t\tconst record = this.containers.get(container);\n\t\t\tassert(\n\t\t\t\trecord?.pauseP === undefined,\n\t\t\t\t\"Cannot resume container while pausing is in progress\",\n\t\t\t);\n\t\t\tif (record?.paused === true) {\n\t\t\t\tdebugWait(`${record.index}: container resumed`);\n\t\t\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\t\t\tdeltaManagerFull.inbound.resume();\n\t\t\t\tdeltaManagerFull.outbound.resume();\n\t\t\t\tresumed.push(container);\n\t\t\t\trecord.paused = false;\n\t\t\t}\n\t\t}\n\t\treturn resumed;\n\t}\n\n\t/**\n\t * Pause all queue activities on the containers given, or all tracked containers\n\t * Any containers given that is not tracked will be ignored.\n\t *\n\t * When a container is paused, it is assumed that we want fine grain control over op\n\t * sequencing. This function will prepare the container and force it into write mode to\n\t * avoid missing join messages or change the sequence of event when switching from read to\n\t * write mode.\n\t */\n\tpublic async pauseProcessing(...containers: IContainer[]) {\n\t\tconst waitP: Promise<void>[] = [];\n\t\tconst containersToApply = this.getContainers(containers);\n\t\tfor (const container of containersToApply) {\n\t\t\tconst record = this.containers.get(container);\n\t\t\tif (record !== undefined && !record.paused) {\n\t\t\t\tif (record.pauseP === undefined) {\n\t\t\t\t\trecord.pauseP = this.pauseContainer(container, record);\n\t\t\t\t}\n\t\t\t\twaitP.push(record.pauseP);\n\t\t\t}\n\t\t}\n\t\tawait Promise.all(waitP);\n\t}\n\n\t/**\n\t * When a container is paused, it is assumed that we want fine grain control over op\n\t * sequencing. This function will prepare the container and force it into write mode to\n\t * avoid missing join messages or change the sequence of event when switching from read to\n\t * write mode.\n\t *\n\t * @param container - the container to pause\n\t * @param record - the record for the container\n\t */\n\tprivate async pauseContainer(container: IContainer, record: ContainerRecord) {\n\t\tdebugWait(`${record.index}: pausing container`);\n\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\tassert(!deltaManagerFull.outbound.paused, \"Container should not be paused yet\");\n\t\tassert(!deltaManagerFull.inbound.paused, \"Container should not be paused yet\");\n\n\t\t// Pause outbound\n\t\tdebugWait(`${record.index}: pausing container outbound queues`);\n\t\tawait deltaManagerFull.outbound.pause();\n\n\t\t// Ensure the container is connected first.\n\t\tif (container.connectionState !== ConnectionState.Connected) {\n\t\t\tdebugWait(`${record.index}: Wait for container connection`);\n\t\t\tawait waitForContainerConnection(container);\n\t\t}\n\n\t\t// Check if the container is in write mode\n\t\tif (!container.deltaManager.active) {\n\t\t\tlet proposalP: Promise<boolean> | undefined;\n\t\t\tif (deltaManagerFull.outbound.idle) {\n\t\t\t\t// Need to generate an op to force write mode\n\t\t\t\tdebugWait(`${record.index}: container force write connection`);\n\t\t\t\tconst maybeContainer = container as Partial<IContainer>;\n\t\t\t\tconst codeProposal = maybeContainer.getLoadedCodeDetails\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tcontainer.getLoadedCodeDetails()!\n\t\t\t\t\t: (container as any).chaincodePackage;\n\n\t\t\t\tproposalP = container.proposeCodeDetails(codeProposal);\n\t\t\t}\n\n\t\t\t// Wait for nack\n\t\t\tdebugWait(`${record.index}: Wait for container disconnect`);\n\t\t\tdeltaManagerFull.outbound.resume();\n\t\t\tawait new Promise<void>((resolve) => container.once(\"disconnected\", resolve));\n\t\t\tconst accepted = proposalP ? await proposalP : false;\n\t\t\tassert(!accepted, \"A proposal in read mode should be rejected\");\n\t\t\tawait deltaManagerFull.outbound.pause();\n\n\t\t\t// Ensure the container is reconnect.\n\t\t\tif (container.connectionState !== ConnectionState.Connected) {\n\t\t\t\tdebugWait(`${record.index}: Wait for container reconnection`);\n\t\t\t\tawait waitForContainerConnection(container);\n\t\t\t}\n\t\t}\n\n\t\tdebugWait(`${record.index}: pausing container inbound queues`);\n\n\t\t// Pause inbound\n\t\tawait deltaManagerFull.inbound.pause();\n\n\t\tdebugWait(`${record.index}: container paused`);\n\n\t\trecord.pauseP = undefined;\n\t\trecord.paused = true;\n\t}\n\n\t/**\n\t * Pause all queue activities on all tracked containers, and resume only\n\t * inbound to process ops until it is idle. All queues are left in the paused state\n\t * after the function.\n\t *\n\t * Pausing will switch the container to write mode. See `pauseProcessing`\n\t */\n\tpublic async processIncoming(...containers: IContainer[]) {\n\t\treturn this.processQueue(\n\t\t\tcontainers,\n\t\t\t(container) => toIDeltaManagerFull(container.deltaManager).inbound,\n\t\t);\n\t}\n\n\t/**\n\t * Pause all queue activities on all tracked containers, and resume only\n\t * outbound to process ops until it is idle. All queues are left in the paused state\n\t * after the function.\n\t *\n\t * Pausing will switch the container to write mode. See `pauseProcessing`\n\t */\n\tpublic async processOutgoing(...containers: IContainer[]) {\n\t\treturn this.processQueue(\n\t\t\tcontainers,\n\t\t\t(container) => toIDeltaManagerFull(container.deltaManager).outbound,\n\t\t);\n\t}\n\n\t/**\n\t * Implementation of processIncoming and processOutgoing\n\t */\n\tprivate async processQueue<U>(\n\t\tcontainers: IContainer[],\n\t\tgetQueue: (container: IContainer) => IDeltaQueue<U>,\n\t) {\n\t\tawait this.pauseProcessing(...containers);\n\t\tconst resumed: IDeltaQueue<U>[] = [];\n\n\t\tconst containersToApply = this.getContainers(containers);\n\n\t\tconst inflightTracker = new Map<IContainer, number>();\n\t\tconst cleanup: (() => void)[] = [];\n\t\tfor (const container of containersToApply) {\n\t\t\tassert(\n\t\t\t\tcontainer.deltaManager.active,\n\t\t\t\t\"Container should be connected in write mode already\",\n\t\t\t);\n\n\t\t\tconst queue = getQueue(container);\n\n\t\t\t// track the outgoing ops (if any) to make sure they make the round trip to at least to the same client\n\t\t\t// to make sure they are sequenced.\n\t\t\tcleanup.push(this.setupInOutTracker(container, inflightTracker));\n\t\t\tqueue.resume();\n\t\t\tresumed.push(queue);\n\t\t}\n\n\t\twhile (resumed.some((queue) => !queue.idle)) {\n\t\t\tdebugWait(\"Wait until queue is idle\");\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tsetTimeout(resolve, 0);\n\t\t\t});\n\t\t}\n\n\t\t// Make sure all the op that we sent out are acked first\n\t\t// This is no op if we are processing incoming\n\t\tif (inflightTracker.size) {\n\t\t\tdebugWait(\"Wait for inflight ops\");\n\t\t\tdo {\n\t\t\t\tawait this.waitForAnyInboundOps(containersToApply);\n\t\t\t} while (inflightTracker.size);\n\t\t}\n\n\t\t// remove the handlers\n\t\tcleanup.forEach((clean) => clean());\n\n\t\tawait Promise.all(resumed.map(async (queue) => queue.pause()));\n\t}\n\n\t/**\n\t * Utility to set up listener to track the outbound ops until it round trip back\n\t * Returns a function to remove the handler after it is done.\n\t *\n\t * @param container - the container to setup\n\t * @param inflightTracker - a map to track the clientSequenceNumber per container it expect to get ops back\n\t */\n\tprivate setupInOutTracker(container: IContainer, inflightTracker: Map<IContainer, number>) {\n\t\tconst outHandler = (messages: IDocumentMessage[]) => {\n\t\t\tfor (const message of messages) {\n\t\t\t\tif (!canBeCoalescedByService(message)) {\n\t\t\t\t\tinflightTracker.set(container, message.clientSequenceNumber);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst inHandler = (message: ISequencedDocumentMessage) => {\n\t\t\tif (\n\t\t\t\t!canBeCoalescedByService(message) &&\n\t\t\t\tmessage.clientId === container.clientId &&\n\t\t\t\tinflightTracker.get(container) === message.clientSequenceNumber\n\t\t\t) {\n\t\t\t\tinflightTracker.delete(container);\n\t\t\t}\n\t\t};\n\n\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\tdeltaManagerFull.outbound.on(\"op\", outHandler);\n\t\tdeltaManagerFull.inbound.on(\"push\", inHandler);\n\n\t\treturn () => {\n\t\t\tdeltaManagerFull.outbound.off(\"op\", outHandler);\n\t\t\tdeltaManagerFull.inbound.off(\"push\", inHandler);\n\t\t};\n\t}\n\n\t/**\n\t * Setup debug traces for connection and ops\n\t */\n\tprivate setupTrace(container: IContainer, index: number) {\n\t\tif (debugOp.enabled) {\n\t\t\tconst getContentsString = (type: string, msgContents: any) => {\n\t\t\t\ttry {\n\t\t\t\t\tif (type !== MessageType.Operation) {\n\t\t\t\t\t\tif (typeof msgContents === \"string\") {\n\t\t\t\t\t\t\treturn msgContents;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn JSON.stringify(msgContents);\n\t\t\t\t\t}\n\t\t\t\t\tlet address = \"\";\n\n\t\t\t\t\t// contents comes in the wire as JSON string (\"push\" event)\n\t\t\t\t\t// But already parsed when apply (\"op\" event)\n\t\t\t\t\tlet contents =\n\t\t\t\t\t\ttypeof msgContents === \"string\" ? JSON.parse(msgContents) : msgContents;\n\t\t\t\t\twhile (contents !== undefined && contents !== null) {\n\t\t\t\t\t\tif (contents.contents?.address !== undefined) {\n\t\t\t\t\t\t\taddress += `/${contents.contents.address}`;\n\t\t\t\t\t\t\tcontents = contents.contents.contents;\n\t\t\t\t\t\t} else if (contents.content?.address !== undefined) {\n\t\t\t\t\t\t\taddress += `/${contents.content.address}`;\n\t\t\t\t\t\t\tcontents = contents.content.contents;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (address) {\n\t\t\t\t\t\treturn `${address} ${JSON.stringify(contents)}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn JSON.stringify(contents);\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\treturn `${e.message}: ${e.stack}`;\n\t\t\t\t}\n\t\t\t};\n\t\t\tdebugOp(`${index}: ADD: clientId: ${container.clientId}`);\n\t\t\tconst deltaManagerFull = toIDeltaManagerFull(container.deltaManager);\n\t\t\tdeltaManagerFull.outbound.on(\"op\", (messages) => {\n\t\t\t\tfor (const msg of messages) {\n\t\t\t\t\tdebugOp(\n\t\t\t\t\t\t`${index}: OUT: ` +\n\t\t\t\t\t\t\t`cli: ${msg.clientSequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`rsq: ${msg.referenceSequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`${msg.type} ${getContentsString(msg.type, msg.contents)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst getInboundHandler = (type: string) => {\n\t\t\t\treturn (msg: ISequencedDocumentMessage) => {\n\t\t\t\t\tconst clientSeq =\n\t\t\t\t\t\tmsg.clientId === container.clientId\n\t\t\t\t\t\t\t? `cli: ${msg.clientSequenceNumber.toString().padStart(3)}`\n\t\t\t\t\t\t\t: \" \";\n\t\t\t\t\tdebugOp(\n\t\t\t\t\t\t`${index}: ${type}: seq: ${msg.sequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`${clientSeq} min: ${msg.minimumSequenceNumber.toString().padStart(3)} ` +\n\t\t\t\t\t\t\t`${msg.type} ${getContentsString(msg.type, msg.contents)}`,\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t};\n\t\t\tdeltaManagerFull.inbound.on(\"push\", getInboundHandler(\"IN \"));\n\t\t\tdeltaManagerFull.inbound.on(\"op\", getInboundHandler(\"OP \"));\n\t\t\tcontainer.deltaManager.on(\"connect\", (details) => {\n\t\t\t\tdebugOp(`${index}: CON: clientId: ${details.clientId}`);\n\t\t\t});\n\t\t\tcontainer.deltaManager.on(\"disconnect\", (reason) => {\n\t\t\t\tdebugOp(`${index}: DIS: ${reason}`);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Filter out the opened containers based on param.\n\t * @param containers - The container to filter to. If the array is empty, it means don't filter and return\n\t * all open containers.\n\t */\n\tprivate getContainers(containers: IContainer[]) {\n\t\tconst containersToApply =\n\t\t\tcontainers.length === 0 ? Array.from(this.containers.keys()) : containers;\n\t\treturn containersToApply.filter((container) => !container.closed);\n\t}\n}\n"]}
|
package/dist/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/test-utils";
|
|
8
|
-
export declare const pkgVersion = "2.41.0
|
|
8
|
+
export declare const pkgVersion = "2.41.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,+BAA+B,CAAC;AACpD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,+BAA+B,CAAC;AACpD,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/test-utils";
|
|
11
|
-
exports.pkgVersion = "2.41.0
|
|
11
|
+
exports.pkgVersion = "2.41.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,QAAQ,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/test-utils\";\nexport const pkgVersion = \"2.41.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeoutUtils.d.ts","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"timeoutUtils.d.ts","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsGH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC9D,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,KAAK,CAAC,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAE,SAAQ,qBAAqB;IACxE,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACT;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,IAAI,IAAI,CACvC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAC1B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,IAAI,EAC1C,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EACvB,cAAc,GAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAM,GACzD,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,IAAI,EAC5C,QAAQ,EAAE,CACT,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAC1B,IAAI,EACT,cAAc,GAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAM,GACzD,OAAO,CAAC,CAAC,CAAC,CA6BZ"}
|
package/dist/timeoutUtils.js
CHANGED
|
@@ -13,17 +13,13 @@ const timeBuffer = 15; // leave 15 ms leeway for finish processing
|
|
|
13
13
|
// before that happens.
|
|
14
14
|
// Once rejected, a new TestTimeout object will be create for the timeout.
|
|
15
15
|
class TestTimeout {
|
|
16
|
-
static
|
|
17
|
-
TestTimeout.
|
|
16
|
+
static updateOnYield(runnable) {
|
|
17
|
+
TestTimeout.instance.clearTimer();
|
|
18
18
|
TestTimeout.instance.resetTimer(runnable);
|
|
19
19
|
}
|
|
20
|
-
static
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
TestTimeout.instance.clearTimer();
|
|
26
|
-
}
|
|
20
|
+
static reset() {
|
|
21
|
+
TestTimeout.instance.clearTimer();
|
|
22
|
+
TestTimeout.instance = new TestTimeout();
|
|
27
23
|
}
|
|
28
24
|
static getInstance() {
|
|
29
25
|
return TestTimeout.instance;
|
|
@@ -72,14 +68,26 @@ if (globalThis.getMochaModule !== undefined) {
|
|
|
72
68
|
const runnablePrototype = mochaModule.Runnable.prototype;
|
|
73
69
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
74
70
|
const oldResetTimeoutFunc = runnablePrototype.resetTimeout;
|
|
71
|
+
let resetTimeoutCallDepth = 0;
|
|
72
|
+
// Mocha invokes resetTimeout after each async yield a test performs.
|
|
75
73
|
runnablePrototype.resetTimeout = function () {
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
resetTimeoutCallDepth++;
|
|
75
|
+
try {
|
|
76
|
+
oldResetTimeoutFunc.call(this);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
resetTimeoutCallDepth--;
|
|
80
|
+
}
|
|
81
|
+
TestTimeout.updateOnYield(this);
|
|
78
82
|
};
|
|
79
83
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
80
84
|
const oldClearTimeoutFunc = runnablePrototype.clearTimeout;
|
|
81
85
|
runnablePrototype.clearTimeout = function () {
|
|
82
|
-
|
|
86
|
+
if (resetTimeoutCallDepth === 0) {
|
|
87
|
+
// Mocha's runnable invokes clearTimeout as part of its resetTimeout as well as at the end of Runnables.
|
|
88
|
+
// We only want to fully reset the TestTimeout instance at the end of each runnable, not on JS turn boundaries.
|
|
89
|
+
TestTimeout.reset();
|
|
90
|
+
}
|
|
83
91
|
oldClearTimeoutFunc.call(this);
|
|
84
92
|
};
|
|
85
93
|
}
|
package/dist/timeoutUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAuE;AAGvE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ributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport type * as Mocha from \"mocha\";\n\nconst timeBuffer = 15; // leave 15 ms leeway for finish processing\n\n// TestTimeout class that manages tracking of test timeout. It creates a timer when timeout is in effect,\n// and provides a promise that will be rejected some time (as defined by `timeBuffer`) before the test timeout happens.\n// This will ensure that async awaits in tests do not end up timing out the tests but resolve / reject\n// before that happens.\n// Once rejected, a new TestTimeout object will be create for the timeout.\nclass TestTimeout {\n\tprivate timeout: number = 0;\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate deferred: Deferred<void> = new Deferred<void>();\n\n\tprivate static instance: TestTimeout = new TestTimeout();\n\tpublic static reset(runnable: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\tTestTimeout.instance.resetTimer(runnable);\n\t}\n\n\tpublic static clear() {\n\t\tif (TestTimeout.instance.deferred.isCompleted) {\n\t\t\tTestTimeout.instance = new TestTimeout();\n\t\t} else {\n\t\t\tTestTimeout.instance.clearTimer();\n\t\t}\n\t}\n\n\tpublic static getInstance() {\n\t\treturn TestTimeout.instance;\n\t}\n\n\tpublic async getPromise() {\n\t\treturn this.deferred.promise;\n\t}\n\n\tpublic getTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\tprivate constructor() {}\n\n\tprivate resetTimer(runnable: Mocha.Runnable) {\n\t\tassert(!this.timer, \"clearTimer should have been called before reset\");\n\t\tassert(!this.deferred.isCompleted, \"can't reset a completed TestTimeout\");\n\n\t\t// Check the test timeout setting\n\t\tconst timeoutFromMochaTest = runnable.timeout();\n\t\tif (!(Number.isFinite(timeoutFromMochaTest) && timeoutFromMochaTest > 0)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// subtract a buffer\n\t\tthis.timeout = Math.max(timeoutFromMochaTest - timeBuffer, 1);\n\n\t\t// Set up timer to reject near the test timeout.\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.deferred.reject(this);\n\t\t}, this.timeout);\n\t}\n\tprivate clearTimer() {\n\t\tif (this.timer) {\n\t\t\tthis.deferred = new Deferred();\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n// Only register if we are running with mocha-test-setup loaded (that package is what sets globalThis.getMochaModule).\nif (globalThis.getMochaModule !== undefined) {\n\t// Patch the private methods resetTimeout and clearTimeout on Mocha's runnable objects so we can do the appropriate\n\t// calls in TestTimeout above when the Mocha methods are called.\n\t// These are not part of the public API so if Mocha changes how it works, this could break.\n\t// See https://github.com/mochajs/mocha/blob/8d0ca3ed77ba8a704b2aa8b58267a084a475a51b/lib/runnable.js#L234.\n\tconst mochaModule = globalThis.getMochaModule() as typeof Mocha;\n\tconst runnablePrototype = mochaModule.Runnable.prototype;\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldResetTimeoutFunc = runnablePrototype.resetTimeout;\n\trunnablePrototype.resetTimeout = function (this: Mocha.Runnable) {\n\t\toldResetTimeoutFunc.call(this);\n\t\tTestTimeout.reset(this);\n\t};\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldClearTimeoutFunc = runnablePrototype.clearTimeout;\n\trunnablePrototype.clearTimeout = function (this: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\toldClearTimeoutFunc.call(this);\n\t};\n}\n\n/**\n * @internal\n */\nexport interface TimeoutDurationOption {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n}\n\n/**\n * @internal\n */\nexport interface TimeoutWithError extends TimeoutDurationOption {\n\treject?: true;\n\terrorMsg?: string;\n\t// Since there are no required properties, this type explicitly\n\t// rejects `value` to avoid confusion with TimeoutWithValue.\n\tvalue?: never;\n}\n\n/**\n * @internal\n */\nexport interface TimeoutWithValue<T = void> extends TimeoutDurationOption {\n\treject: false;\n\tvalue: T;\n}\n\nexport type PromiseExecutor<T = void> = (\n\tresolve: (value: T | PromiseLike<T>) => void,\n\treject: (reason?: any) => void,\n) => void;\n\n/**\n * Wraps the given promise with another one that will complete after a specific timeout if the original promise does\n * not resolve by then.\n *\n * @remarks\n * If used inside a mocha test, it uses the test timeout by default and completes the returned promise just before\n * the test timeout hits, so that tests don't time out because of unpredictable awaits.\n * In that scenario the timeout can still be overridden via `timeoutOptions` but it's recommended to use the default value.\n *\n * @param promise - The promise to be wrapped.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when\n * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.\n * @returns A new promise that will complete when the given promise resolves or the timeout expires.\n * @internal\n */\nexport async function timeoutAwait<T = void>(\n\tpromise: PromiseLike<T>,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\treturn Promise.race([promise, timeoutPromise<T>(() => {}, timeoutOptions)]);\n}\n\n/**\n * Creates a promise from the given executor that will complete after a specific timeout.\n *\n * @remarks\n * If used inside a mocha test, it uses the test timeout by default and completes the returned promise just before\n * the test timeout hits, so that tests don't time out because of unpredictable awaits.\n * In that scenario the timeout can still be overridden via `timeoutOptions` but it's recommended to use the default value.\n *\n * @param executor - The executor for the promise.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when\n * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.\n * @returns A new promise that will complete when the given executor resolves or the timeout expires.\n * @internal\n */\nexport async function timeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\t// create the timeout error outside the async task, so its callstack includes\n\t// the original call site, this makes it easier to debug\n\tconst err =\n\t\ttimeoutOptions.reject === false\n\t\t\t? undefined\n\t\t\t: new Error(timeoutOptions.errorMsg ?? \"Timed out\");\n\tconst executorPromise = getTimeoutPromise(executor, timeoutOptions, err);\n\n\tconst currentTestTimeout = TestTimeout.getInstance();\n\tif (currentTestTimeout === undefined) {\n\t\treturn executorPromise;\n\t}\n\n\treturn Promise.race([executorPromise, currentTestTimeout.getPromise()]).catch((e) => {\n\t\tif (e === currentTestTimeout) {\n\t\t\tif (timeoutOptions.reject !== false) {\n\t\t\t\t// If the rejection is because of the timeout then\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst errorObject = err!;\n\t\t\t\terrorObject.message = `${\n\t\t\t\t\ttimeoutOptions.errorMsg ?? \"Forcing timeout before test does\"\n\t\t\t\t} (${currentTestTimeout.getTimeout()}ms)`;\n\t\t\t\tthrow errorObject;\n\t\t\t}\n\t\t\treturn timeoutOptions.value;\n\t\t}\n\t\tthrow e;\n\t}) as Promise<T>;\n}\n\n// Create a promise based on the timeout options\nasync function getTimeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T>,\n\terr: Error | undefined,\n) {\n\tconst timeout = timeoutOptions.durationMs ?? 0;\n\tif (timeout <= 0 || !Number.isFinite(timeout)) {\n\t\treturn new Promise(executor);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timeoutRejections = () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst errorObject = err!;\n\t\t\terrorObject.message = `${errorObject.message} (${timeout}ms)`;\n\t\t\treject(err);\n\t\t};\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\ttimeoutOptions.reject === false ? resolve(timeoutOptions.value) : timeoutRejections(),\n\t\t\ttimeout,\n\t\t);\n\n\t\texecutor(\n\t\t\t(value) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tclearTimeout(timer);\n\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AC;QAEF,QAAQ,CACP,CAAC,KAAK,EAAE,EAAE;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,EACD,CAAC,MAAM,EAAE,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,CAAC;QAChB,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport type * as Mocha from \"mocha\";\n\nconst timeBuffer = 15; // leave 15 ms leeway for finish processing\n\n// TestTimeout class that manages tracking of test timeout. It creates a timer when timeout is in effect,\n// and provides a promise that will be rejected some time (as defined by `timeBuffer`) before the test timeout happens.\n// This will ensure that async awaits in tests do not end up timing out the tests but resolve / reject\n// before that happens.\n// Once rejected, a new TestTimeout object will be create for the timeout.\nclass TestTimeout {\n\tprivate timeout: number = 0;\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate deferred: Deferred<void> = new Deferred<void>();\n\n\tprivate static instance: TestTimeout = new TestTimeout();\n\tpublic static updateOnYield(runnable: Mocha.Runnable) {\n\t\tTestTimeout.instance.clearTimer();\n\t\tTestTimeout.instance.resetTimer(runnable);\n\t}\n\n\tpublic static reset() {\n\t\tTestTimeout.instance.clearTimer();\n\t\tTestTimeout.instance = new TestTimeout();\n\t}\n\n\tpublic static getInstance() {\n\t\treturn TestTimeout.instance;\n\t}\n\n\tpublic async getPromise() {\n\t\treturn this.deferred.promise;\n\t}\n\n\tpublic getTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\tprivate constructor() {}\n\n\tprivate resetTimer(runnable: Mocha.Runnable) {\n\t\tassert(!this.timer, \"clearTimer should have been called before reset\");\n\t\tassert(!this.deferred.isCompleted, \"can't reset a completed TestTimeout\");\n\n\t\t// Check the test timeout setting\n\t\tconst timeoutFromMochaTest = runnable.timeout();\n\t\tif (!(Number.isFinite(timeoutFromMochaTest) && timeoutFromMochaTest > 0)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// subtract a buffer\n\t\tthis.timeout = Math.max(timeoutFromMochaTest - timeBuffer, 1);\n\n\t\t// Set up timer to reject near the test timeout.\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.deferred.reject(this);\n\t\t}, this.timeout);\n\t}\n\tprivate clearTimer() {\n\t\tif (this.timer) {\n\t\t\tthis.deferred = new Deferred();\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n// Only register if we are running with mocha-test-setup loaded (that package is what sets globalThis.getMochaModule).\nif (globalThis.getMochaModule !== undefined) {\n\t// Patch the private methods resetTimeout and clearTimeout on Mocha's runnable objects so we can do the appropriate\n\t// calls in TestTimeout above when the Mocha methods are called.\n\t// These are not part of the public API so if Mocha changes how it works, this could break.\n\t// See https://github.com/mochajs/mocha/blob/8d0ca3ed77ba8a704b2aa8b58267a084a475a51b/lib/runnable.js#L234.\n\tconst mochaModule = globalThis.getMochaModule() as typeof Mocha;\n\tconst runnablePrototype = mochaModule.Runnable.prototype;\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldResetTimeoutFunc = runnablePrototype.resetTimeout;\n\tlet resetTimeoutCallDepth = 0;\n\t// Mocha invokes resetTimeout after each async yield a test performs.\n\trunnablePrototype.resetTimeout = function (this: Mocha.Runnable) {\n\t\tresetTimeoutCallDepth++;\n\t\ttry {\n\t\t\toldResetTimeoutFunc.call(this);\n\t\t} finally {\n\t\t\tresetTimeoutCallDepth--;\n\t\t}\n\t\tTestTimeout.updateOnYield(this);\n\t};\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldClearTimeoutFunc = runnablePrototype.clearTimeout;\n\trunnablePrototype.clearTimeout = function (this: Mocha.Runnable) {\n\t\tif (resetTimeoutCallDepth === 0) {\n\t\t\t// Mocha's runnable invokes clearTimeout as part of its resetTimeout as well as at the end of Runnables.\n\t\t\t// We only want to fully reset the TestTimeout instance at the end of each runnable, not on JS turn boundaries.\n\t\t\tTestTimeout.reset();\n\t\t}\n\t\toldClearTimeoutFunc.call(this);\n\t};\n}\n\n/**\n * @internal\n */\nexport interface TimeoutDurationOption {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n}\n\n/**\n * @internal\n */\nexport interface TimeoutWithError extends TimeoutDurationOption {\n\treject?: true;\n\terrorMsg?: string;\n\t// Since there are no required properties, this type explicitly\n\t// rejects `value` to avoid confusion with TimeoutWithValue.\n\tvalue?: never;\n}\n\n/**\n * @internal\n */\nexport interface TimeoutWithValue<T = void> extends TimeoutDurationOption {\n\treject: false;\n\tvalue: T;\n}\n\nexport type PromiseExecutor<T = void> = (\n\tresolve: (value: T | PromiseLike<T>) => void,\n\treject: (reason?: any) => void,\n) => void;\n\n/**\n * Wraps the given promise with another one that will complete after a specific timeout if the original promise does\n * not resolve by then.\n *\n * @remarks\n * If used inside a mocha test, it uses the test timeout by default and completes the returned promise just before\n * the test timeout hits, so that tests don't time out because of unpredictable awaits.\n * In that scenario the timeout can still be overridden via `timeoutOptions` but it's recommended to use the default value.\n *\n * @param promise - The promise to be wrapped.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when\n * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.\n * @returns A new promise that will complete when the given promise resolves or the timeout expires.\n * @internal\n */\nexport async function timeoutAwait<T = void>(\n\tpromise: PromiseLike<T>,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\treturn Promise.race([promise, timeoutPromise<T>(() => {}, timeoutOptions)]);\n}\n\n/**\n * Creates a promise from the given executor that will complete after a specific timeout.\n *\n * @remarks\n * If used inside a mocha test, it uses the test timeout by default and completes the returned promise just before\n * the test timeout hits, so that tests don't time out because of unpredictable awaits.\n * In that scenario the timeout can still be overridden via `timeoutOptions` but it's recommended to use the default value.\n *\n * @param executor - The executor for the promise.\n * @param timeoutOptions - Options that can be used to override the timeout and / or define the behavior when\n * the promise is not fulfilled. For example, instead of rejecting the promise, resolve with a specific value.\n * @returns A new promise that will complete when the given executor resolves or the timeout expires.\n * @internal\n */\nexport async function timeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\t// create the timeout error outside the async task, so its callstack includes\n\t// the original call site, this makes it easier to debug\n\tconst err =\n\t\ttimeoutOptions.reject === false\n\t\t\t? undefined\n\t\t\t: new Error(timeoutOptions.errorMsg ?? \"Timed out\");\n\tconst executorPromise = getTimeoutPromise(executor, timeoutOptions, err);\n\n\tconst currentTestTimeout = TestTimeout.getInstance();\n\tif (currentTestTimeout === undefined) {\n\t\treturn executorPromise;\n\t}\n\n\treturn Promise.race([executorPromise, currentTestTimeout.getPromise()]).catch((e) => {\n\t\tif (e === currentTestTimeout) {\n\t\t\tif (timeoutOptions.reject !== false) {\n\t\t\t\t// If the rejection is because of the timeout then\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst errorObject = err!;\n\t\t\t\terrorObject.message = `${\n\t\t\t\t\ttimeoutOptions.errorMsg ?? \"Forcing timeout before test does\"\n\t\t\t\t} (${currentTestTimeout.getTimeout()}ms)`;\n\t\t\t\tthrow errorObject;\n\t\t\t}\n\t\t\treturn timeoutOptions.value;\n\t\t}\n\t\tthrow e;\n\t}) as Promise<T>;\n}\n\n// Create a promise based on the timeout options\nasync function getTimeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T>,\n\terr: Error | undefined,\n) {\n\tconst timeout = timeoutOptions.durationMs ?? 0;\n\tif (timeout <= 0 || !Number.isFinite(timeout)) {\n\t\treturn new Promise(executor);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timeoutRejections = () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst errorObject = err!;\n\t\t\terrorObject.message = `${errorObject.message} (${timeout}ms)`;\n\t\t\treject(err);\n\t\t};\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\ttimeoutOptions.reject === false ? resolve(timeoutOptions.value) : timeoutRejections(),\n\t\t\ttimeout,\n\t\t);\n\n\t\texecutor(\n\t\t\t(value) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(reason);\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
|
package/lib/TestSummaryUtils.js
CHANGED
|
@@ -22,7 +22,7 @@ async function getSummarizerBackCompat(container) {
|
|
|
22
22
|
if (container.getEntryPoint !== undefined) {
|
|
23
23
|
const entryPoint = await container.getEntryPoint();
|
|
24
24
|
// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running
|
|
25
|
-
// cross
|
|
25
|
+
// cross-client compat testing scenarios, if we create with 1.X container and load with 2.X then the
|
|
26
26
|
// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined
|
|
27
27
|
// since the container's runtime will be on version 1.X, which does not have an entry point defined.
|
|
28
28
|
if (entryPoint !== undefined) {
|