Recently I was experiencing an issue where an ASP.NET site was not appearing to shut down correctly, preventing the application from recycling.

In this specific context, this was a Sitecore site and was reproducable by triggering a change to a configuration file, which causes the application to restart. To confirm the shutdown was happening, I could see the regular shutdown messages appearing in the logs:

19060 13:13:41 INFO ************************************************
19060 13:13:41 WARN Sitecore shutting down
19060 13:13:41 WARN Shutdown message: IIS configuration change
HostingEnvironment initiated shutdown

In a typical Sitecore site, this would be followed by the next log file being generated and filled with logs of the initialization process as the site started up again. However, in this particular instance this wasn’t happening. Additionally to this, requests to the site were simply timing out without a response being served.

Before I get into the diagnosis and solution of this problem, it’s worth noting that though this example is based upon a Sitecore ASP.NET site, the diagnosis, issue and required solution are all applicable to a generic ASP.NET site. So if you are not developing a Sitecore site, this blog post could still prove useful to you.

Diagnosis

To diagnose this issue, I had to do two things. First of all I needed to take a dump of the process in its “hanging” state, so that I could perform some analysis on it to try and find the issue. This can be done in Task Manager. I triggered the shutdown process of the application, and then I created the dump file:

Then, I opened up Microsoft DebugDiag Analysis. This is a useful tool that can help with analysing crashing / hanging issues in Windows processes. Once downloaded, using this is as simple as pointing it at the dump file you’ve just created, selecting CrashHangAnalysis as the analyzer you want to use, and starting the analysis:

The analysis will run and generate you a report. This report is an MHT file, an older HTML web archive file format that you’re best opening with Internet Explorer.

Analysis and resolution

Opening the report and looking at the summary immediately showed something promising as a lead to the issue: “The finalizer thread 16 in this w3wp.DMP is blocked”:

Clicking on the thread number (16) showed more details:

From this part of the report, I could determine that the thread was stuck waiting in the dispose method of MsieJavaScriptEngine.JsRt.Edge.ChakraEdgeJsRtJsEngine. A quick bit of googling turned up this issue on GitHub for the MsieJavaScriptEngine project. It appeared that there was an issue with the version of the package that we had referenced - the site in question was using React.NET which in turn had taken this package as a dependency.

Fortunately in this instance, the resolution was straightforward. The issue had been fixed in a more recent release of the MsieJavaScriptEngine project, so it was just a case of upgrading the package in the solution. This fixed the issue and the site was able to shutdown / recycle as expected.

Nice and simple! Of course, there could be any multitude of reasons why a site may hang or become unresponsive, and it won’t always be so easy to diagnose. Hopefully what worked here may prove useful to you, and the DebugDiag tool could well assist you in the same way it did in this scenario.