Skip to content

ApplyReleases shutdowns the app #1059

Open
@sergei-pankratov

Description

@sergei-pankratov

Hi.

I have a following update code

                    var updateInfo = mgr.CheckForUpdate().Result;
                    if (updateInfo.CurrentlyInstalledVersion.Version < updateInfo.FutureReleaseEntry.Version)
                    {
                        mgr.DownloadReleases(updateInfo.ReleasesToApply).Wait();
                        Log("update downloaded");
                        mgr.ApplyReleases(updateInfo).Wait();
                        Log("update applied");
                        if (ShouldRestart()) //question user or check if a user is afk
                            UpdateManager.RestartApp();
                    }

I also have HandleEvents as soon as possible:

    public partial class App : Application
    {
        public App()
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) => TreatException(sender, (Exception)args.ExceptionObject);
            TaskScheduler.UnobservedTaskException += (sender, args) => TreatException(sender, args.Exception);
            System.Windows.Forms.Application.ThreadException += (sender, args) => TreatException(sender, args.Exception);
            DispatcherUnhandledException += (sender, args) => TreatException(sender, args.Exception);
            if (Updater.IsDeployed)
                using (var mgr = new UpdateManager(Updater.UpdatePath))
                {
                    SquirrelAwareApp.HandleEvents(
                          onInitialInstall: v => mgr.CreateShortcutForThisExe(),
                          onAppUninstall: v => mgr.RemoveShortcutForThisExe());
                }

Updater.IsDeployed checks that there is Update.exe one level above an application file.

The issue is, that on my machine when update is availlable the ShouldRestart method is always called after ApplyReleases.
However when I collect logs from all the users, I see that basically 1/3 of them have an issue, that an app is restarted during ApplyReleases
I judge by the fact that after all users have updated I see 122 update downloaded log messages, but only 75 update applied messages. I don't see any exceptions in logs.

Can anyone suggest how can I fix it or investigate it futher? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:old-versionIssues that target a very old version of the library, and should be retested if possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions