Skip to content

Commit 2416614

Browse files
committed
With AppInsights enabled by default we noticed a 5 seconds delay in cold startup time.
1 parent c31ff2d commit 2416614

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/WebJobs.Script/Host/ScriptHost.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,9 @@ private JObject ApplyHostConfiguration()
757757
ConfigureLoggerFactory(recreate: true);
758758
_startupLogger = _hostConfig.LoggerFactory.CreateLogger(LogCategories.Startup);
759759
Logger = _hostConfig.LoggerFactory.CreateLogger(ScriptConstants.LogCategoryHostGeneral);
760-
oldLoggerFactory.Dispose();
760+
761+
// Dispose needs to be called in a fire and forget pattern as it has several sleeps and waits in the pipeline and was adding ~5 seconds to cold start.
762+
Task.Run(() => oldLoggerFactory.Dispose());
761763

762764
// Allow tests to modify anything initialized by host.json
763765
ScriptConfig.OnConfigurationApplied?.Invoke(ScriptConfig);

0 commit comments

Comments
 (0)