PowerShell Universal server crashes with error "Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.DataPage'. "

PowerShell Universal server crashes with error "Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.DataPage'. "

Version: 1.4.x
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
Root Cause:
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. 

    • Related Articles

    • PowerShell Universal Service crashes on startup after an upgrade to 1.4.6

      Version: PowerShell Universal 1.4.6 Issue The PowerShell Universal service will crash with the following error in Event Viewer.  Application: Universal.Server.exe CoreCLR Version: 4.700.19.56402 .NET Core Version: 3.1.0 Description: The process was ...
    • PowerShell Universal crashes after upgrade to 1.5

      Version: 1.5 Issue: The PowerShell Universal service will not start properly when upgrading from 1.4 to 1.5. The following error is shown in the log.  Unhandled exception. System.InvalidCastException: Unable to cast object of type ...
    • KB0025 - Universal Server fails to start automatically

      Applicability This article applies to PowerShell Universal (Kestrel version*) running on Windows. If you have PowerShell Universal running under IIS or another OS then this article does not apply. Symptom Even though the PowerShell Universal service ...
    • KB0035 - How to add the Calendar and other components

      Purpose The purpose of this article is to demonstrate how to install and use the Calendar component (module) Background There is a growing list of add-on components (modules) for PowerShell Universal at ...
    • KB0034 - How to collect logs

      Purpose The purpose of this article is to provide clear ordered steps for users of PowerShell Universal and to submit them to Ironman Software (typically for a support case). Background Having logs from PowerShell Universal is typically needed to ...