File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,14 @@ internal static AzFunctionInfo GetFunctionInfo(string functionId)
36
36
throw new InvalidOperationException ( string . Format ( PowerShellWorkerStrings . FunctionNotLoaded , functionId ) ) ;
37
37
}
38
38
39
+ /// <summary>
40
+ /// Returns true if the function with the given functionId is already loaded.
41
+ /// </summary>
42
+ public static bool IsLoaded ( string functionId )
43
+ {
44
+ return LoadedFunctions . ContainsKey ( functionId ) ;
45
+ }
46
+
39
47
/// <summary>
40
48
/// This method runs once per 'FunctionLoadRequest' during the code start of the worker.
41
49
/// It will always run synchronously because we process 'FunctionLoadRequest' synchronously.
Original file line number Diff line number Diff line change @@ -146,6 +146,16 @@ internal StreamingMessage ProcessFunctionLoadRequest(StreamingMessage request)
146
146
out StatusResult status ) ;
147
147
response . FunctionLoadResponse . FunctionId = functionLoadRequest . FunctionId ;
148
148
149
+ // The worker may occasionally receive multiple function load requests with
150
+ // the same FunctionId. In order to make function load request idempotent,
151
+ // the worker should ignore the duplicates.
152
+ if ( FunctionLoader . IsLoaded ( functionLoadRequest . FunctionId ) )
153
+ {
154
+ // If FunctionLoader considers this function loaded, this means
155
+ // the previous request was successful, so respond accordingly.
156
+ return response ;
157
+ }
158
+
149
159
// When a functionLoadRequest comes in, we check to see if a dependency download has failed in a previous call
150
160
// or if PowerShell could not be initialized. If this is the case, mark this as a failed request
151
161
// and submit the exception to the Host (runtime).
You can’t perform that action at this time.
0 commit comments