obivandamme / Workshop

This is the repository for the OSE Workshop mod for Kerbal Space Program
Other
11 stars 16 forks source link

"Operation is not valid due to the current state of the object" from Workshop.OseModuleWorkshop.ExecuteManufacturing #34

Open henrybauer opened 7 years ago

henrybauer commented 7 years ago

Hit a bug on my station.  Both of my workshops were stuck at 0/100 (one 3-D Printing Lab, one MK3 Fabricator), and the log is spammed with:

[EXC 10:52:46.985] InvalidOperationException: Operation is not valid due to the current state of the object
    System.Linq.Enumerable.First[WorkshopResource] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback)
    System.Linq.Enumerable.First[WorkshopResource] (IEnumerable`1 source, System.Func`2 predicate)
    Workshop.OseModuleWorkshop.ExecuteManufacturing ()
    Workshop.OseModuleWorkshop.ProcessItem ()
    Workshop.OseModuleWorkshop.OnUpdate ()
    UnityEngine.Debug:LogException(Exception)
    Workshop.OseModuleWorkshop:OnUpdate()
    Part:ModulesOnUpdate()
    Part:Update()
[ERR 10:52:47.061] [OSE] - OseModuleWorkshop_OnUpdate

Logs and persistent.sfs (the affected ship is "TC2 Station"): https://www.dropbox.com/sh/7vb7lnuihz2nrbv/AABqwFZcD3b33TcdclP7CNGta?dl=0

Here's the relevant module info:

ProcessedItem
                    {
                        Name = truss-octo-hub-01
                    }                   
ProcessedBlueprint
                    {
                        Funds = 0
                        WorkshopResource
                        {
                            Name = MaterialKits
                            Units = 499.999976251275
                            Processed = 499.999976277351
                        }
                    }

ProcessedItem
                    {
                        Name = C3.Kontainer.KIS.03
                    }
                    ProcessedBlueprint
                    {
                        Funds = 0
                        WorkshopResource
                        {
                            Name = MaterialKits
                            Units = 10399.9991245568
                            Processed = 10399.999124567
                        }
                    }

If I had to guess, my ship didn't have enough space for the "C3.Kontainer.KIS.03", but it had finished, and got stuck in some weird state.

I changed "Processed =" to 498 and 109398, reloaded, and both parts finished.  Both workshops then went into the next item in the queue and worked fine.

My guess is this line is the problem:

var resourceToConsume = _processedBlueprint.First(r => r.Processed < r.Units);

Since both my blueprints had Processed>Units somehow, there were no "Processed<Units" blueprints.

henrybauer commented 7 years ago

https://github.com/obivandamme/Workshop/pull/35