advanced-cms / advanced-reviews

This is an Open Source add-on that improves the reviewing process and lets external users to view & review content items or whole projects without the need to access the Edit Mode. Created and maintained by Bartosz Sekuła and Grzegorz Wiecheć
Apache License 2.0
17 stars 15 forks source link

Occasional 500 Error thrown while unpacking content from Lazy Loader #244

Open samuelthomson62 opened 10 months ago

samuelthomson62 commented 10 months ago

I have an instance of Advanced.Cms.AdvancedReviews v1.3.6 on Episerver.Cms v12.22.5 that infrequently throws a 500 server error while accessing an external review link. The exception reads similarly to the one that is thrown if you had a deleted piece of content in a content area and tried to render an external review link. The main difference is, the content is not deleted and it is instead trying to pull it from the lazy loader. From what I've read about this kind of exception, is that it is generally caused by reentrance and having the content loaded a second time.

System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at EPiServer.Core.ContentAreaItem.CreateWritableClone()
   at EPiServer.SpecializedProperties.PropertyContentArea.<>c.<CreateWritableClone>b__27_0(ContentAreaItem c)
   at System.Linq.Enumerable.SelectIListIterator`2.ToList()
   at EPiServer.SpecializedProperties.PropertyContentArea.CreateWritableClone()
   at EPiServer.Core.PropertyDataCollection.CreateWritableClone()
   at EPiServer.Core.ContentData.CreateWriteableCloneImplementation()
   at EPiServer.Core.PageData.CreateWriteableCloneImplementation()
   at EPiServer.Core.PageData.CreateWritableClone()
   at Advanced.CMS.ExternalReviews.ContentExtensions.AllowAccessToEveryone(IContent content)
   at Advanced.CMS.ExternalReviews.CustomContentLoaderInitialization.Events_LoadingContent(Object sender, ContentEventArgs e)
   at EPiServer.Core.Internal.DefaultContentEvents.RaiseContentEvent(String key, ContentEventArgs eventArgs)
   at EPiServer.Core.Internal.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
   at Advanced.CMS.ExternalReviews.DraftContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions settings, T& content)
   at EPiServer.Core.Html.StringParsing.ContentFragment.GetContent(Boolean enableMasterLanguageFallback)
   at EPiServer.Core.Html.StringParsing.ContentFragment.GetSecurityDescriptor()
   at EPiServer.Core.ContentAreaItem.<>c__DisplayClass10_0.<.ctor>b__0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
barteksekula commented 5 days ago

241 seems similar, there might be something wrong in https://github.com/advanced-cms/advanced-reviews/blob/master/src/Advanced.CMS.ExternalReviews/ContentExtensions.cs#L14-L33

Will look but would appreciate thoughts as well as I don't see anything wrong with this code at first glance.