From c80c351f6a7cd9ad872ef25788e6388039c5ae90 Mon Sep 17 00:00:00 2001 From: mhoeger Date: Fri, 22 May 2020 15:58:58 -0700 Subject: [PATCH 1/2] do not load proxy functions --- 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..03693050 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) { + 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' From ccdc0504f39863d1405da426e2927ff9a20749ba Mon Sep 17 00:00:00 2001 From: mhoeger Date: Fri, 22 May 2020 16:00:41 -0700 Subject: [PATCH 2/2] check against true --- src/FunctionLoader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FunctionLoader.ts b/src/FunctionLoader.ts index 03693050..a643ffbf 100644 --- a/src/FunctionLoader.ts +++ b/src/FunctionLoader.ts @@ -17,7 +17,7 @@ export class FunctionLoader implements IFunctionLoader { }} = {}; load(functionId: string, metadata: rpc.IRpcFunctionMetadata): void { - if (metadata.isProxy) { + if (metadata.isProxy === true) { return; } let scriptFilePath = (metadata && metadata.scriptFile);