From 84d21984e07e14af049cf9a24061cd0efaf8e866 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 8 Apr 2024 13:02:12 +0530 Subject: [PATCH] Test complete Tested logging from both worker (in web app) and when running in Electron. Refs: - https://github.com/GoogleChromeLabs/comlink/issues/506 - https://github.com/GoogleChromeLabs/comlink/issues/568 --- web/apps/photos/src/components/Sidebar/DebugSection.tsx | 2 +- web/apps/photos/src/worker/convert.worker.ts | 3 --- web/packages/shared/sentry/index.ts | 1 - web/packages/shared/storage/localStorage/index.ts | 3 +-- web/packages/shared/worker/comlinkWorker.ts | 6 +++--- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar/DebugSection.tsx b/web/apps/photos/src/components/Sidebar/DebugSection.tsx index b65548377..b2d07bb47 100644 --- a/web/apps/photos/src/components/Sidebar/DebugSection.tsx +++ b/web/apps/photos/src/components/Sidebar/DebugSection.tsx @@ -47,7 +47,7 @@ export default function DebugSection() { const downloadDebugLogs = () => { addLogLine("exporting logs"); - if (false && isElectron()) { + if (isElectron()) { ElectronAPIs.openLogDirectory(); } else { const logs = getDebugLogs(); diff --git a/web/apps/photos/src/worker/convert.worker.ts b/web/apps/photos/src/worker/convert.worker.ts index d3f0441df..d8ab22d3a 100644 --- a/web/apps/photos/src/worker/convert.worker.ts +++ b/web/apps/photos/src/worker/convert.worker.ts @@ -1,4 +1,3 @@ -import { logError } from "@ente/shared/sentry"; import * as Comlink from "comlink"; import HeicConvert from "heic-convert"; import { getUint8ArrayView } from "services/readerService"; @@ -17,8 +16,6 @@ Comlink.expose(DedicatedConvertWorker, self); * Both the input and output are blobs. */ export const convertHEICToJPEG = async (heicBlob: Blob): Promise => { - // throw new Error("test error"); - logError(new Error("test error"), "test message"); const filedata = await getUint8ArrayView(heicBlob); const result = await HeicConvert({ buffer: filedata, format: "JPEG" }); const convertedFileData = new Uint8Array(result); diff --git a/web/packages/shared/sentry/index.ts b/web/packages/shared/sentry/index.ts index f8b14e43d..2dae035b7 100644 --- a/web/packages/shared/sentry/index.ts +++ b/web/packages/shared/sentry/index.ts @@ -18,7 +18,6 @@ export const logError = async ( } ${error?.stack}`); } else { - console.log("here"); addLogLine( `error: ${error?.name} ${error?.message} msg: ${msg} ${info ? `info: ${JSON.stringify(info)}` : ""} diff --git a/web/packages/shared/storage/localStorage/index.ts b/web/packages/shared/storage/localStorage/index.ts index 6a115e8d5..14901fdd4 100644 --- a/web/packages/shared/storage/localStorage/index.ts +++ b/web/packages/shared/storage/localStorage/index.ts @@ -32,8 +32,7 @@ export enum LS_KEYS { export const setData = (key: LS_KEYS, value: object) => { if (typeof localStorage === "undefined") { - console.log("early return"); - // return null; + return null; } localStorage.setItem(key, JSON.stringify(value)); }; diff --git a/web/packages/shared/worker/comlinkWorker.ts b/web/packages/shared/worker/comlinkWorker.ts index 0cbae504c..f8e72778f 100644 --- a/web/packages/shared/worker/comlinkWorker.ts +++ b/web/packages/shared/worker/comlinkWorker.ts @@ -21,7 +21,7 @@ export class ComlinkWorker InstanceType> { addLocalLog(() => `Initiated ${this.name}`); const comlink = wrap(this.worker); this.remote = new comlink() as Promise>>; - expose(workerBridge, this.worker); + expose(workerBridge, worker); } public getName() { @@ -38,8 +38,8 @@ export class ComlinkWorker InstanceType> { * A minimal set of utility functions that we expose to all workers that we * create. * - * Inside the worker's code, this can be accessed by - * `wrap(self).foo`. + * Inside the worker's code, this can be accessed by using the sibling + * `workerBridge` object by importing `worker-bridge.ts`. */ const workerBridge = { logToDisk,