Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
737 stars 358 forks source link

NRE in ShutdownListener #2927

Open fartwhif opened 1 year ago

fartwhif commented 1 year ago

NullReferenceException thrown crashing the webjob

Repro steps

Provide the steps required to reproduce the problem

  1. Step start the webjob

Expected behavior

WebJob starts and remains running

Actual behavior

WebJob crashes

Known workarounds

None yet

Related information

Application: dotnet.exe
CoreCLR Version: 5.0.1722.21314
.NET Version: 5.0.17
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.WebJobs.Host.Listeners.ShutdownListener.Cancel() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\ShutdownListener.cs:line 40
   at System.Threading.CancellationToken.<>c.<.cctor>b__26_0(Object obj)
   at System.Threading.CancellationTokenSource.InternalRegister(Action`1 callback, Object stateForCallback, SynchronizationContext syncContext, ExecutionContext executionContext)
   at System.Threading.CancellationToken.Register(Action`1 callback, Object state, Boolean useSynchronizationContext, Boolean useExecutionContext)
   at System.Threading.CancellationToken.Register(Action callback)
   at Microsoft.Azure.WebJobs.Host.Listeners.ShutdownListener..ctor(CancellationToken shutdownToken, IListener innerListener) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\ShutdownListener.cs:line 20
   at Microsoft.Azure.WebJobs.Host.Executors.NullDashboardLoggingSetup.Setup(IFunctionIndex functions, IListenerFactory functionsListenerFactory, IFunctionExecutor& hostCallExecutor, IListener& listener, HostOutputMessage& hostOutputMessage, String hostId, CancellationToken shutdownToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Loggers\IDashboardLoggingSetup.cs:line 46
   at Microsoft.Azure.WebJobs.Host.Executors.JobHostContextFactory.Create(JobHost host, CancellationToken shutdownToken, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\JobHostContextFactory.cs:line 130
   at Microsoft.Azure.WebJobs.JobHost.InitializeHostAsync(CancellationToken cancellationToken, TaskCompletionSource`1 initializationTask) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 347
   at Microsoft.Azure.WebJobs.JobHost.StartAsyncCore(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 95
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at BackgroundTasks.Program.Main() in C:\projects\git\clients\REDACTED\REDACTED\BackgroundTasks\Program.cs:line 107
   at BackgroundTasks.Program.Main() in C:\projects\git\clients\REDACTED\REDACTED\BackgroundTasks\Program.cs:line 117
   at BackgroundTasks.Program.<Main>()

I'm sorry that's all I was able to glean from the situation.

AspNetCore.AzureKeyVault.HostingStartup 2.0.4 Azure.WebJobs 3.0.31 Azure.WebJobs.Extensions 4.0.1 Azure.WebJobs.Extensions.Storage 5.0.0 Azure.WebJobs.Logging.ApplicationInsights 3.0.30 Extensions.Hosting.Abstractions 6.0.0 Extensions.Logging.Console 6.0.0

mathewc commented 1 year ago

Can you provide a sample program that builds/starts the JobHost in a way that leads to this? I.e. we need a full repro, thanks.