umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
Other
4.49k stars 2.69k forks source link

System.NullReferenceException in InMemoryModelFactory #11169

Closed PhyxionNL closed 2 years ago

PhyxionNL commented 3 years ago

Which exact Umbraco version are you using? For example: 8.13.1 - don't just write v8

v9-rc003

Bug summary

System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryModelFactory.Dispose(System.Boolean disposing) at offset 11
at Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryModelFactory.Dispose()
at Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryModelFactory.Stop(System.Boolean immediate)

Specifics

It should be the watcher https://github.com/umbraco/Umbraco-CMS/blob/v9/dev/src/Umbraco.Web.Common/ModelsBuilder/InMemoryModelFactory.cs#L802

as it isn't always created: https://github.com/umbraco/Umbraco-CMS/blob/v9/dev/src/Umbraco.Web.Common/ModelsBuilder/InMemoryModelFactory.cs#L79

nul800sebastiaan commented 3 years ago

Hi there @PhyxionNL - can you please provide more info? Where do you see this problem and when, what happens before you see the error, how can you reproduce it? I can see you have found some code, how do you think this code is relevant and have you possibly already identified where the problem is? Thanks!

PhyxionNL commented 3 years ago

@nul800sebastiaan This was an error I found in the logs. I don't know how I can reproduce it, but it should always occur when IsHosted is false as it doesn't create the watcher in that case. I don't really have any other information, although it shouldn't matter too much as _watcher should not be disposed when it hasn't been created.

umbrabot commented 2 years ago

Hiya @PhyxionNL,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

PhyxionNL commented 2 years ago

@umbrabot still relevant Not fixed yet, see above.

nul800sebastiaan commented 2 years ago

This one obviously slipped my mind, sorry about that! Yep, it would be good to do a null check before disposing the watcher! We'd love some help with that. 🙏

PhyxionNL commented 2 years ago

@nul800sebastiaan #12169. Not sure how you port changes to v10 branch, but I did the v9 branch here.

nul800sebastiaan commented 2 years ago

Awesome, thanks! No porting needed, we merge everything up to future versions. 👍