From d828bcb0711f7e4a57a849099b19f7e53469e65b Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 10 Apr 2024 09:53:30 +0530 Subject: [PATCH] [web] Fix SSR build Fixes the following error on the nightly build Error: Attempting to assert globalThis.electron in a non-electron context at r (/home/runner/work/ente/ente/web/apps/photos/.next/server/chunks/676.js:1:25418) ... > Build error occurred Error: Failed to collect page data for /gallery at /home/runner/work/ente/ente/web/node_modules/next/dist/build/utils.js:1258:15 { type: 'Error' } --- web/apps/photos/src/services/clip-service.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/web/apps/photos/src/services/clip-service.ts b/web/apps/photos/src/services/clip-service.ts index c6a94213f..253d8097e 100644 --- a/web/apps/photos/src/services/clip-service.ts +++ b/web/apps/photos/src/services/clip-service.ts @@ -1,6 +1,5 @@ import { ensureElectron } from "@/next/electron"; import log from "@/next/log"; -import type { Electron } from "@/next/types/ipc"; import ComlinkCryptoWorker from "@ente/shared/crypto"; import { CustomError } from "@ente/shared/error"; import { Events, eventBus } from "@ente/shared/events"; @@ -65,7 +64,6 @@ export interface CLIPIndexingStatus { * itself, is the same across clients - web and mobile. */ class CLIPService { - private electron: Electron; private embeddingExtractionInProgress: AbortController | null = null; private reRunNeeded = false; private indexingStatus: CLIPIndexingStatus = { @@ -80,7 +78,6 @@ class CLIPService { private unsupportedPlatform = false; constructor() { - this.electron = ensureElectron(); this.liveEmbeddingExtractionQueue = new PQueue({ concurrency: 1, }); @@ -193,7 +190,7 @@ class CLIPService { getTextEmbedding = async (text: string): Promise => { try { - return electron.clipTextEmbedding(text); + return ensureElectron().clipTextEmbedding(text); } catch (e) { if (e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)) { this.unsupportedPlatform = true; @@ -321,7 +318,7 @@ class CLIPService { const file = await localFile .arrayBuffer() .then((buffer) => new Uint8Array(buffer)); - return await electron.clipImageEmbedding(file); + return await ensureElectron().clipImageEmbedding(file); }; private encryptAndUploadEmbedding = async (