@@ -19,11 +19,12 @@ namespace Microsoft.Azure.WebJobs.Script
19
19
// TODO: make this internal
20
20
public class NodeFunctionInvoker : IFunctionInvoker
21
21
{
22
- private readonly Func < object , Task < object > > _scriptFunc ;
22
+ private Func < object , Task < object > > _scriptFunc ;
23
23
private static string FunctionTemplate ;
24
24
private readonly Collection < Binding > _inputBindings ;
25
25
private readonly Collection < Binding > _outputBindings ;
26
26
private readonly string _triggerParameterName ;
27
+ private readonly string _script ;
27
28
28
29
static NodeFunctionInvoker ( )
29
30
{
@@ -34,13 +35,26 @@ static NodeFunctionInvoker()
34
35
}
35
36
}
36
37
38
+ private Func < object , Task < object > > ScriptFunc
39
+ {
40
+ get
41
+ {
42
+ if ( _scriptFunc == null )
43
+ {
44
+ // We delay create the script function so any syntax errors in
45
+ // the function will be reported to the Dashboard as an invocation
46
+ // error rather than a host startup error
47
+ _scriptFunc = Edge . Func ( _script ) ;
48
+ }
49
+ return _scriptFunc ;
50
+ }
51
+ }
52
+
37
53
internal NodeFunctionInvoker ( string triggerParameterName , string scriptFilePath , Collection < Binding > inputBindings , Collection < Binding > outputBindings )
38
54
{
39
55
_triggerParameterName = triggerParameterName ;
40
56
scriptFilePath = scriptFilePath . Replace ( '\\ ' , '/' ) ;
41
- string script = string . Format ( FunctionTemplate , scriptFilePath ) ;
42
- _scriptFunc = Edge . Func ( script ) ;
43
-
57
+ _script = string . Format ( FunctionTemplate , scriptFilePath ) ;
44
58
_inputBindings = inputBindings ;
45
59
_outputBindings = outputBindings ;
46
60
}
@@ -87,7 +101,7 @@ public async Task Invoke(object[] parameters)
87
101
context [ "output" ] = output ;
88
102
}
89
103
90
- await _scriptFunc ( context ) ;
104
+ await ScriptFunc ( context ) ;
91
105
92
106
// process output bindings
93
107
if ( functionOutput != null )
0 commit comments