-
-
Notifications
You must be signed in to change notification settings - Fork 535
When unexpected power outage, settings.json may half save. #1275
Copy link
Copy link
Closed as not planned
Labels
bugSomething isn't workingSomething isn't workingstaleStale issue or inactive for long period of timeStale issue or inactive for long period of time
Description
What happened?
If the application is in the process of saving settings.json when an unexpected power outage occurs, the file may not be fully written to disk, resulting in possible corruption. This issue could leave users without a way to recover their settings, causing frustration and loss of important configurations. A backup or recovery system could be implemented to ensure settings are preserved even in cases of abrupt shutdowns.
Steps to reproduce
- Run the application and modify settings.
- Allow the application to save
settings.json. - Close the application.
- Manually open
settings.jsonin a text editor and delete a few lines at the end to simulate an incomplete save. - Open the application again and observe how it handles the corrupted file.
This version should make it easier to reproduce the issue reliably without the power outage.
Relevant logs
2025-05-22 13:05:36.4092|WARN|StabilityMatrix.Avalonia.Program|Unhandled "JsonException": "'0x00' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 3293 | BytePositionInLine: 9."|System.Text.Json.JsonException: '0x00' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 3293 | BytePositionInLine: 9.
---> System.Text.Json.JsonReaderException: '0x00' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 3293 | BytePositionInLine: 9.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan`1 data, Int32 idx)
at System.Text.Json.Utf8JsonReader.ConsumeString()
at System.Text.Json.Utf8JsonReader.ConsumePropertyName()
at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker)
at System.Text.Json.Utf8JsonReader.ConsumeNextTokenOrRollback(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, T& value)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Stream utf8Json)
at StabilityMatrix.Core.Services.SettingsManager.LoadSettings(CancellationToken cancellationToken)
at StabilityMatrix.Core.Services.SettingsManager.TryFindLibrary(Boolean forceReload)
at StabilityMatrix.Avalonia.App.ConfigureServiceProvider()
at StabilityMatrix.Avalonia.App.OnFrameworkInitializationCompleted()
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
at StabilityMatrix.Avalonia.Program.Main(String[] args)Version
v2.14.1
What Operating System are you using?
Windows
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstaleStale issue or inactive for long period of timeStale issue or inactive for long period of time