andrewdavey / cassette

Manages .NET web application assets (scripts, css and templates)
http://getcassette.net
MIT License
534 stars 143 forks source link

Cached Manifest.xml being empty breaks website #481

Open zymurgybc opened 6 years ago

zymurgybc commented 6 years ago

We've had a production system down for a couple weeks now that traced back to a failing assumption in Cassette. Its not the fault of Cassette, but just an obscurity that repeatedly failed to clean itself up. It all started when the site's drive filled and, it appears, the cached Manifest.xml was created as an empty file. Its off in a corner of the system with a path like : C:\ProgramData\IsolatedStorage\u3ppbmt4.yyp\h1rm2zob.w3v\Url.e4kb21nzmyiduzdwqklmohnseoizhjuj\AssemFiles\Manifest.xml (on my system, the hash-style values change per-server, but there are only single folders. YMMV)

I've looked at the code around reading this file and see how it handles 'Does not exist' by returning a simple false. I'd have to suggest: a) if the file's length is zero, or some other minimal size, you should also ignore it (delete it?) and return false. b) handle the XmlException better.

Thanks for the consideration of this.

Zym

`Root element is missing. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: Root element is missing.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[XmlException: Root element is missing.] System.Xml.XmlTextReaderImpl.Throw(Exception e) +72 System.Xml.XmlTextReaderImpl.ParseDocumentContent() +5469911 System.Xml.XmlTextReaderImpl.Read() +163 System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) +44 Cassette.Aspnet.WebHostSettingsConfiguration.IsStaticCacheManifest(CassetteSettings settings) +106 Cassette.Aspnet.WebHostSettingsConfiguration.Configure(CassetteSettings settings) +221 Cassette.ConfigurationEnumerableExtensions.Configure(IEnumerable1 configurations, T configurable) +151 Cassette.CassetteSettings..ctor(IEnumerable1 configurations) +33

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +180 Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +669

[TinyIoCResolutionException: Unable to resolve type: Cassette.CassetteSettings] Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +704 Cassette.TinyIoC.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) +124 Cassette.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) +86 Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +374

[TinyIoCResolutionException: Unable to resolve type: Cassette.FileSystemWatchingBundleRebuilder] Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +521 Cassette.TinyIoC.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) +124 Cassette.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) +86 Cassette.TinyIoC.TinyIoCContainer.b45(TypeRegistration registration) +32 System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +164 System.Linq.d95`1.MoveNext() +176 Cassette.HostBase.RunStartUpTasks() +65 Cassette.HostBase.Initialize() +147 Cassette.Aspnet.CassetteHttpModule.InitWithoutTraceLogging() +34 Cassette.Aspnet.CassetteHttpModule.InitWithTraceLogging() +122 Cassette.Aspnet.CassetteHttpModule.Init(HttpApplication httpApplication) +121 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +536 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Unable to resolve type: Cassette.FileSystemWatchingBundleRebuilder] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10043436 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254`