From 1f720998761de51d7748ac715d41a5e250fa86c9 Mon Sep 17 00:00:00 2001 From: Navin Agarwal Date: Mon, 20 Oct 2025 16:34:18 -0700 Subject: [PATCH] (compat) Fix incorrect usages of storage service at Runtime and Loader layer --- .../loader/container-loader/src/container.ts | 4 +- .../src/test/containerRuntime.spec.ts | 10 ++--- .../test/deRehydrateContainerTests.spec.ts | 37 ------------------- 3 files changed, 7 insertions(+), 44 deletions(-) diff --git a/packages/loader/container-loader/src/container.ts b/packages/loader/container-loader/src/container.ts index 35ec5f477fbc..cbd68e6bdac7 100644 --- a/packages/loader/container-loader/src/container.ts +++ b/packages/loader/container-loader/src/container.ts @@ -32,6 +32,7 @@ import type { ReadOnlyInfo, ILoader, ILoaderOptions, + IContainerStorageService, } from "@fluidframework/container-definitions/internal"; import { isFluidCodeDetails } from "@fluidframework/container-definitions/internal"; import { @@ -54,7 +55,6 @@ import { import { type IDocumentService, type IDocumentServiceFactory, - type IDocumentStorageService, type IResolvedUrl, type ISnapshot, type IThrottlingWarning, @@ -1887,7 +1887,7 @@ export class Container private async initializeProtocolStateFromSnapshot( attributes: IDocumentAttributes, - storage: IDocumentStorageService, + storage: IContainerStorageService, snapshot: ISnapshotTree | undefined, ): Promise { const quorumSnapshot: IQuorumSnapshot = { diff --git a/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts b/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts index c2ed646ab865..d5f69a5c4aa6 100644 --- a/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts +++ b/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts @@ -18,6 +18,7 @@ import { ContainerErrorTypes, type IContainerContext, type IBatchMessage, + type IContainerStorageService, } from "@fluidframework/container-definitions/internal"; import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal"; import type { @@ -58,7 +59,6 @@ import { type IEnvelope, type ITelemetryContext, type ISummarizeInternalResult, - type IRuntimeStorageService, } from "@fluidframework/runtime-definitions/internal"; import { defaultMinVersionForCollab } from "@fluidframework/runtime-utils/internal"; import { @@ -242,7 +242,7 @@ describe("Runtime", () => { const mockClientId = "mockClientId"; // Mock the storage layer so "submitSummary" works. - const defaultMockStorage: Partial = { + const defaultMockStorage: Partial = { uploadSummaryWithContext: async (summary: ISummaryTree, context: ISummaryContext) => { return "fakeHandle"; }, @@ -251,7 +251,7 @@ describe("Runtime", () => { params: { settings?: Record; logger?: ITelemetryBaseLogger; - mockStorage?: Partial; + mockStorage?: Partial; loadedFromVersion?: IVersion; baseSnapshot?: ISnapshotTree; connected?: boolean; @@ -298,7 +298,7 @@ describe("Runtime", () => { }, clientId, connected, - storage: mockStorage as IRuntimeStorageService, + storage: mockStorage as IContainerStorageService, baseSnapshot, } satisfies Partial; @@ -2119,7 +2119,7 @@ describe("Runtime", () => { summaryRefSeq: 100, summaryLogger: createChildLogger({}), }; - class MockStorageService implements Partial { + class MockStorageService implements Partial { /** * This always returns the same snapshot. Basically, when container runtime receives an ack for the * deleted snapshot and tries to fetch the latest snapshot, return the latest snapshot. diff --git a/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts b/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts index 40e01889f96b..c3c61c54f332 100644 --- a/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts @@ -531,43 +531,6 @@ describeCompat( assert.strictEqual(sparseMatrix.id, sparseMatrixId, "Sparse matrix should exist!!"); }); - it("Storage in detached container", async () => { - const { container } = await createDetachedContainerAndGetEntryPoint(); - - const snapshotTree = container.serialize(); - const defaultDataStore = - await getContainerEntryPointBackCompat(container); - assert( - defaultDataStore.context.storage !== undefined, - "Storage should be present in detached data store", - ); - let success1: boolean | undefined; - await defaultDataStore.context.storage.getSnapshotTree(undefined).catch((err) => { - success1 = false; - }); - assert( - success1 === false, - "Snapshot fetch should not be allowed in detached data store", - ); - - const container2: IContainer = - await loader.rehydrateDetachedContainerFromSnapshot(snapshotTree); - const defaultDataStore2 = - await getContainerEntryPointBackCompat(container2); - assert( - defaultDataStore2.context.storage !== undefined, - "Storage should be present in rehydrated data store", - ); - let success2: boolean | undefined; - await defaultDataStore2.context.storage.getSnapshotTree(undefined).catch((err) => { - success2 = false; - }); - assert( - success2 === false, - "Snapshot fetch should not be allowed in rehydrated data store", - ); - }); - it("Change contents of dds, then rehydrate and then check summary", async () => { const { container } = await createDetachedContainerAndGetEntryPoint();