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)
3636 throw new InvalidOperationException ( string . Format ( PowerShellWorkerStrings . FunctionNotLoaded , functionId ) ) ;
3737 }
3838
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+
3947 /// <summary>
4048 /// This method runs once per 'FunctionLoadRequest' during the code start of the worker.
4149 /// 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)
146146 out StatusResult status ) ;
147147 response . FunctionLoadResponse . FunctionId = functionLoadRequest . FunctionId ;
148148
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+
149159 // When a functionLoadRequest comes in, we check to see if a dependency download has failed in a previous call
150160 // or if PowerShell could not be initialized. If this is the case, mark this as a failed request
151161 // and submit the exception to the Host (runtime).
You can’t perform that action at this time.
0 commit comments