Skip to content

electron API and backend API mismatch #11

Description

@theolivenbaum

Discussed in #10

Originally posted by r-pankevicius February 13, 2023
Hi,

there are some things that go unnoticed when upgrading electron, but API changes are not reflected in backend API.

Here is one nasty example resulting in auto-update failures.

At some point downloadUpdate method from electron-updater changed the returned value to string array:
https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppUpdater.ts#L460

But backend API was not changed:
https://github.com/theolivenbaum/electron-sharp/blob/main/ElectronSharp.API/AutoUpdater.cs#L433

The result is Json serialization exception (expected string, got array) and autoupdate fails to install. This is from h5.ElectronNET, but I checked this repo, it's the same.

   2023-02-13 16:53:53.6620 ERROR [ElectronNET.API.BridgeConnector.LogError] Error running handler for event autoUpdaterDownloadUpdateComplete34955f7e-c08e-442e-af0b-89a6d09cc8c9 Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path '', line 1, position 1.
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsString()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at SocketIOClient.Newtonsoft.Json.NewtonsoftJsonSerializer.Deserialize[T](String json, IList`1 bytes) in ...\h5.ElectronNET\ElectronNET.API\SocketIO\NewtonsoftJsonSerializer.cs:line 37
   at SocketIOClient.SocketIOResponse.GetValue[T](Int32 index) in ...\h5.ElectronNET\ElectronNET.API\SocketIO\SocketIOResponse.cs:line 29
   at ElectronNET.API.BridgeConnector.<>c__DisplayClass17_0`1.<On>b__0(SocketIOResponse o) in ...\h5.ElectronNET\ElectronNET.API\BridgeConnector.cs:line 250

I wonder if it's possible to avoid such errors so TS or C# compiler error will point out electron API changes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions