From cd90fe59dc22b762b9246f258db68e05bea79547 Mon Sep 17 00:00:00 2001 From: Marie Hoeger Date: Tue, 26 May 2020 15:08:22 -0700 Subject: [PATCH] Ignore proxy functions for loading (#299) * do not load proxy functions * check against true --- src/FunctionLoader.ts | 3 +++ test/FunctionLoaderTests.ts | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/FunctionLoader.ts b/src/FunctionLoader.ts index 439d0e5b..a643ffbf 100644 --- a/src/FunctionLoader.ts +++ b/src/FunctionLoader.ts @@ -17,6 +17,9 @@ export class FunctionLoader implements IFunctionLoader { }} = {}; load(functionId: string, metadata: rpc.IRpcFunctionMetadata): void { + if (metadata.isProxy === true) { + return; + } let scriptFilePath = (metadata && metadata.scriptFile); let script = require(scriptFilePath); let entryPoint = (metadata && metadata.entryPoint); diff --git a/test/FunctionLoaderTests.ts b/test/FunctionLoaderTests.ts index 67f3ef18..1b3eb9a8 100644 --- a/test/FunctionLoaderTests.ts +++ b/test/FunctionLoaderTests.ts @@ -36,6 +36,17 @@ describe('FunctionLoader', () => { }).to.throw("Unable to determine function entry point. If multiple functions are exported, you must indicate the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property."); }); + it ('does not load proxy function', () => { + mock('test', {}); + loader.load('functionId', { + isProxy: true + }); + + expect(() => { + loader.getFunc('functionId'); + }).to.throw("Function code for 'functionId' is not loaded and cannot be invoked."); + }); + it ('throws unable to determine function entry point with entryPoint name', () => { mock('test', { test: {} }); let entryPoint = 'wrongEntryPoint'