Skip to content

Commit 07ffcc9

Browse files
authored
Change order of logic for dotnet-isolated that has worker config in functions (#7167)
* change order of logic for dotnet-isolated that has worker config in function defs * Add comment to avoid future issues
1 parent 13a43aa commit 07ffcc9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,23 @@ public async Task InitializeAsync(IEnumerable<FunctionMetadata> functions, Cance
171171
return;
172172
}
173173

174+
if (functions == null || functions.Count() == 0)
175+
{
176+
// do not initialize function dispatcher if there are no functions
177+
return;
178+
}
179+
174180
var workerConfig = _workerConfigs.Where(c => c.Description.Language.Equals(_workerRuntime, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
175181
if (workerConfig == null)
176182
{
183+
// Only throw if workerConfig is null AND some functions have been found.
184+
// With .NET out-of-proc, worker config comes from functions.
177185
throw new InvalidOperationException($"WorkerCofig for runtime: {_workerRuntime} not found");
178186
}
179187
_maxProcessCount = workerConfig.CountOptions.ProcessCount;
180188
_debounceMilliSeconds = (int)workerConfig.CountOptions.ProcessStartupInterval.TotalMilliseconds;
181189
ErrorEventsThreshold = 3 * _maxProcessCount;
182190

183-
if (functions == null || functions.Count() == 0)
184-
{
185-
// do not initialize function dispatcher if there are no functions
186-
return;
187-
}
188-
189191
if (Utility.IsSupportedRuntime(_workerRuntime, _workerConfigs))
190192
{
191193
State = FunctionInvocationDispatcherState.Initializing;

0 commit comments

Comments
 (0)