Nancy
Nancy copied to clipboard
Razor View Engine faults on 2.0.0-c after application has been running for several days
Prerequisites
- [x] I have written a descriptive issue title
- [x] I have verified that I am running the latest version of Nancy
- [x] I have verified if the problem exist in both
DEBUG
andRELEASE
mode - [x] I have searched open and closed issues to ensure it has not already been reported
Description
We have a web site built on Nancy 2.0.0-clinteastwood that is working fine, for the most part, but twice now has randomly started faulting. The fault that appears indicates that this line:
https://github.com/NancyFx/Nancy/blob/master/src/Nancy.ViewEngines.Razor/RazorViewEngine.cs#L238
...is encountering an exception because the type
parameter to Activator.CreateInstance
is null
. As far as I can tell, it abruptly enters this state after the application pool has been running continuously for some time.
Here is the stack trace:
Error: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Nancy.ViewEngines.Razor.RazorViewEngine.<>c__DisplayClass14_0.<GenerateRazorViewFactory>b__1()
at Nancy.ViewEngines.Razor.RazorViewEngine.GetViewInstance(ViewLocationResult viewLocationResult, IRenderContext renderContext, Object model)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Nancy.ViewEngines.Razor.RazorViewEngine.<>c__DisplayClass9_0.<RenderView>b__0(Stream stream)
at Nancy.Responses.MaterialisingResponse.PreExecute(NancyContext context)
at Nancy.NancyEngine.<InvokeRequestLifeCycle>d__22.MoveNext()
When this happens, other routes with different views continue to function just fine.
Steps to Reproduce
The route on which this error has been occurring looks like this:
Get("/", _ => View["MainMenu"]);
The MainMenu view is simple and contains no logic:
<!DOCTYPE html>
<html>
<head>
<title>Hub Sync Jobs</title>
</head>
<body>
<h1>Hub Sync Jobs</h1>
<ul>
<li><a href="BeginJob">Begin Job</a></li>
<li><a href="GetJobs">View Running Jobs</a></li>
</ul>
</body>
</html>
We have not found a way to trigger this, but simply leaving this running on an installation on Windows Server 2012 DataCenter edition with .NET 4.7 installed ends up in this state after some time has elapsed.
System Configuration
- Nancy version: 2.0.0-clinteastwood
- Nancy host
- [x] Nancy.Hosting.Aspnet
- [ ] Nancy.Hosting.Self
- [ ] Nancy.Owin ()
- [ ] Other:
- Other Nancy packages and versions: Nancy.Bootstrappers.Autofac, Nancy.ViewEngines.Razor
- Environment (Operating system, version and so on): Windows Server 2012 DataCenter
- .NET Framework version: 4.7
- Additional information:
Could this be https://github.com/NancyFx/Nancy/issues/2563 still rearing its head? Maybe the app pool gets recycled at some point, and multiple requests for different views overlap as the new instance is spooling up?? I've tried to intentionally trigger this with an application that hits all endpoints at once, and haven't had any success thus far.
I added a work-around to the error pipeline that specifically detects this error and restarts the app pool in response. The logs show it periodically triggering. But now this same application has taken to displaying not-errors in view compilation:
The "Errors:" part of the view is completely blank and no system events are logged.
Restarting the app pool resolves the issue.
Is there any further information I can gather??