PowerShell Universal server crashes with error "Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.DataPage'. "
An error is thrown when running jobs that states:
Error executing job 31: Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.DataPage'. at LiteDB.PageService.GetPage[T](UInt32 pageID)
This only happens with jobs that write to the output streams. The PowerShell Universal server will crash after writing this error to the log.
To resolve this issue, you will need to stop the PowerShell Universal server and delete the database.db file in the %ProgramData%\UniversalAutomation folder. When you start PowerShell Universal again, it will recreate the database
When this error is encountered, the LiteDB reporting and configuration caching database has become corrupt. The table that is responsible for storing the output of jobs is no longer in a valid state. Since configuration of the PowerShell Universal server is stored within PS1 files, your configuration is not lost. This corruption can happen when you have a job that writes an excessive amount of output to the PowerShell output streams. To prevent this error from happening, limit the amount of output that is written to the output stream by using cmdlets like Out-Null.