Azure / Azure/azure-functions-host

Null Ref WebJobsScriptHostService.ShutdownHostIfUnhealthy()

Open
#9,925 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

Discovered this when investigating a CRI (https://portal.microsofticm.com/imp/v3/incidents/incident/480190531/summary) - in that case the host was failing to start due to file share issues. That was the underlying issue, but the below code also failed with a NullRef after that:

```
System.AggregateException : One or more errors occurred. (Object reference not set to an instance of an object.) ---> Object reference not set to an instance of an object.
---> (Inner Exception #0) System.NullReferenceException : Object reference not set to an instance of an object.
at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.ShutdownHostIfUnhealthy() at /_/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs : 751
at async Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.UnsynchronizedStartHostAsync(ScriptHostStartupOperation activeOperation,Int32 attemptCount,JobHostStartupMode startupMode) at /_/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs : 403
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.RestartHostAsync(CancellationToken cancellationToken) at /_/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs : 573
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.StandbyManager.SpecializeHostCoreAsync() at /_/src/WebJobs.Script.WebHost/Standby/StandbyManager.cs : 122<---
```

Here's a query showing that the error appears to be new, happening for versions 4.30 and up, and 3.22:

All("FunctionsLogs")
| where PreciseTimeStamp > ago(1d)
| where Level == 2
| where Details contains "Object reference not set to an instance of an object." and Details contains "WebJobsScriptHostService.ShutdownHostIfUnhealthy()"
| summarize dcount(AppName) by HostVersion

Contributor guide

Open the contributing guide

Research direction

Start in src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs at ShutdownHostIfUnhealthy() around line 751, then trace the calls shown in the stack trace. Review the failure path described for hosts that cannot start because of file-share issues and use the provided FunctionsLogs query to check affected versions. Done means this path no longer raises a NullReferenceException.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.