FluidFramework: Handle Routing Incorrectly Returning DataStore rather than Error

Trying to resolve a handle to a dds from a key on a map which is expected to fail, but instead returns the handle to the data store. Below is the test

        it.only("Failure to Load in Shared String", async ()=>{
            const deltaConnectionServer = LocalDeltaConnectionServer.create();

            const fluidExport: SupportedExportInterfaces = {
                IFluidDataStoreFactory: new TestFluidObjectFactory([[stringId, SharedString.getFactory()]]),
            };
            const text = "hello world";
            const documentId = "sstest";
            { // creating client
                const urlResolver = new LocalResolver();
                const documentServiceFactory = new LocalDocumentServiceFactory(deltaConnectionServer);
                const codeDetails = { package: "no-dynamic-pkg" };
                const codeLoader = new LocalCodeLoader([
                    [codeDetails, fluidExport],
                ]);

                const loader = new Loader({
                    urlResolver,
                    documentServiceFactory,
                    codeLoader,
                });

                const container = await loader.createDetachedContainer(codeDetails);
                const dataObject = await requestFluidObject<ITestFluidObject>(container, "default");
                const sharedString  = await dataObject.root.get<IFluidHandle<SharedString>>(stringId).get();
                sharedString.insertText(0, text);

                await container.attach(urlResolver.createCreateNewRequest(documentId));
            }
            { // normal load client
                const urlResolver = new LocalResolver();
                const documentServiceFactory = new LocalDocumentServiceFactory(deltaConnectionServer);
                const codeDetails = { package: "no-dynamic-pkg" };
                const codeLoader = new LocalCodeLoader([
                    [codeDetails, fluidExport],
                ]);

                const loader = new Loader({
                    urlResolver,
                    documentServiceFactory,
                    codeLoader,
                });

                const container = await loader.resolve(urlResolver.createCreateNewRequest(documentId));
                const dataObject = await requestFluidObject<ITestFluidObject>(container, "default");
                const sharedString  = await dataObject.root.get<IFluidHandle<SharedString>>(stringId).get();
                assert.strictEqual(sharedString.getText(0), text);
            }
            { // failure load client
                const urlResolver = new LocalResolver();
                const realSf: IDocumentServiceFactory =
                    new LocalDocumentServiceFactory(deltaConnectionServer);
                const documentServiceFactory: IDocumentServiceFactory = {
                    ...realSf,
                    createDocumentService: async (resolvedUrl,logger) => {
                        const realDs = await realSf.createDocumentService(resolvedUrl, logger);
                        const mockDs = Object.create(realDs) as IDocumentService;
                        mockDs.policies = {
                            ... mockDs.policies,
                            caching: LoaderCachingPolicy.NoCaching,
                        };
                        mockDs.connectToStorage = async ()=>{
                            const realStorage = await realDs.connectToStorage();
                            const mockstorage = Object.create(realStorage) as IDocumentStorageService;
                            mockstorage.read = async (id)=>{
                                const blob = await realStorage.read(id);
                                const blobObj = JSON.parse(Buffer.from(blob, "Base64").toString());
                                if (blobObj.chunkStartSegmentIndex !== undefined) {
                                    const error = new NetworkErrorBasic(
                                        "Not Found",
                                        undefined,
                                        false,
                                        404);
                                    throw error;
                                }
                                return blob;
                            };
                            return mockstorage;
                        };
                        return mockDs;
                    },
                };
                const codeDetails = { package: "no-dynamic-pkg" };
                const codeLoader = new LocalCodeLoader([
                    [codeDetails, fluidExport],
                ]);

                const loader = new Loader({
                    urlResolver,
                    documentServiceFactory,
                    codeLoader,
                });

                const container = await loader.resolve(urlResolver.createCreateNewRequest(documentId));
                const dataObject = await requestFluidObject<ITestFluidObject>(container, "default");
                const sharedString  = await dataObject.root.get<IFluidHandle<SharedString>>(stringId).get();
                assert.strictEqual(sharedString.getText(0), text);
            }
        });

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

i’m almost thinking that dataStoreRuntime should mirror container runtime and have a resolveHandle method rather than going down the request flow here