Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Report a failed canary release lookup as an update error

Petr Bauchd2bf8323b28a
diff --git a/console/apps/switch-console-desktop/src/main/core/updates/update-service.test.ts b/console/apps/switch-console-desktop/src/main/core/updates/update-service.test.ts
index b795ee9c8..9928a33c5 100644
--- a/console/apps/switch-console-desktop/src/main/core/updates/update-service.test.ts
+++ b/console/apps/switch-console-desktop/src/main/core/updates/update-service.test.ts
@@ -62,6 +62,7 @@ vi.mock('@main/lib/logger', () => ({
import type { EventEmitter } from 'node:events';
import { app } from 'electron';
+import type * as AppIdentity from '@shared/app-identity';
import { updateService } from './update-service';
/** The app going down for the installer, as the service observes it. */
@@ -226,6 +227,45 @@ describe('the launch after an install', () => {
});
});
+describe('a canary build', () => {
+ afterEach(() => {
+ vi.doUnmock('@shared/app-identity');
+ vi.doUnmock('./canary-feed');
+ });
+
+ it('reports a failed release lookup as an update error', async () => {
+ // The lookup runs before the updater, so the updater's error listener never
+ // hears about it — and a scheduled check has no caller to show the error.
+ vi.resetModules();
+ vi.doMock('@shared/app-identity', async (importOriginal) => ({
+ ...(await importOriginal<typeof AppIdentity>()),
+ IS_CANARY: true,
+ }));
+ vi.doMock('./canary-feed', () => ({
+ resolveCanaryFeedUrl: async () => {
+ throw new Error('GitHub API returned 403');
+ },
+ }));
+ const { events } = await import('@main/lib/events');
+ const { updateErrorEvent } = await import('@shared/events/updateEvents');
+ const { updateService: canary } = await import('./update-service');
+ await canary.initialize();
+ canary.dispose();
+ vi.mocked(events.emit).mockClear();
+ h.checkForUpdatesAndNotify.mockClear();
+
+ await expect(canary.checkForUpdates('scheduled')).rejects.toThrow('403');
+
+ expect(h.checkForUpdatesAndNotify).not.toHaveBeenCalled();
+ expect(canary.getState()).toMatchObject({ status: 'error' });
+ expect(canary.getState().error).toContain('403');
+ expect(events.emit).toHaveBeenCalledWith(updateErrorEvent, {
+ message: expect.stringContaining('403'),
+ });
+ canary.dispose();
+ });
+});
+
describe('the dev harness', () => {
it('reports one event for a simulated install, not two', async () => {
// A dev build has no binary to restart into, so the harness always unwinds.
diff --git a/console/apps/switch-console-desktop/src/main/core/updates/update-service.ts b/console/apps/switch-console-desktop/src/main/core/updates/update-service.ts
index c7a188623..dbad7f8d4 100644
--- a/console/apps/switch-console-desktop/src/main/core/updates/update-service.ts
+++ b/console/apps/switch-console-desktop/src/main/core/updates/update-service.ts
@@ -294,11 +294,15 @@ class UpdateService implements IInitializable, IDisposable {
if (this.fake) return this.fake.check();
if (IS_CANARY) {
- autoUpdater.setFeedURL({
- provider: 'generic',
- url: await resolveCanaryFeedUrl(),
- channel: 'canary',
- });
+ let url: string;
+ try {
+ url = await resolveCanaryFeedUrl();
+ } catch (error) {
+ // The updater never runs, so its error listener cannot report this.
+ this.signals.failed(error);
+ throw error;
+ }
+ autoUpdater.setFeedURL({ provider: 'generic', url, channel: 'canary' });
} else {
autoUpdater.setFeedURL({
provider: 'github',