Wenwu
Wenwu

Reputation: 65

Electron autoUpdater Error: Update check failed. The server sent an invalid JSON response

I am implementing auto update feature for my Electron app. I am encountering an error:

[Error: Update check failed. The server sent an invalid response. Try again later.] {
  code: 6,
  domain: 'SQRLUpdaterErrorDomain'
}

This error is thrown from inside Electron node module, specifically from Squirrel.framework:

Binary file ./dist/Electron.app/Contents/Frameworks/Squirrel.framework/Versions/A/Squirrel

Part of my electron main.js code:

    const { app, autoUpdater } = require('electron');

    let version  = app.getVersion();
    let server   = 'https://colube-deploy-pnjad1iun-wenwu.vercel.app';
    //let url    = `${server}/update/${process.platform}/${app.getVersion()}`;
    let platform = process.platform + '_arm64';
    let url      = `${server}/update/${platform}/${version}`;

    autoUpdater.setFeedURL({ url });

    setInterval(() => {
        autoUpdater.checkForUpdates();
    }, 15 * 60 * 1000);

    setTimeout(() => {
        autoUpdater.checkForUpdates();
    }, 3000);

    autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {

releaseName, releaseNotes);

        const dialogOpts = {
            type    : 'info',
            buttons : ['Restart', 'Later'],
            title   : 'Application Update',
            message : process.platform === 'win32' ? releaseNotes : releaseName,
            detail  : 'A new version has been downloaded. Restart the application to apply the updates.',
        }

        dialog.showMessageBox(dialogOpts).then((returnValue) => {
            if (returnValue.response === 0) autoUpdater.quitAndInstall();
        })
    });

    autoUpdater.on('before-quit-for-update', () => {
    });

    autoUpdater.on('error', (message) => {
        console.error('There was a problem updating the application.');
        console.error(message);
    });

Some background information:

{
    name: 'v0.9.17',
    notes: '',
    pub_date: '2022-07-31T13:47:34Z',
    url: 'colube-deploy-pnjad1iun-wenwu.vercel.app/download/darwin_arm64?update=true'
}

Upvotes: 1

Views: 2042

Answers (0)

Related Questions