Add ML logging (#1504)

This commit is contained in:
Abhinav Kumar 2023-12-13 12:56:08 +05:30 committed by GitHub
commit ebc03b5a69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 29 deletions

View file

@ -211,7 +211,7 @@ class DownloadManagerImpl {
this.thumbnailObjectURLPromises.set(file.id, thumbURLPromise);
}
let thumb = await this.thumbnailObjectURLPromises.get(file.id);
if (!thumb) {
if (!thumb && !localOnly) {
this.thumbnailObjectURLPromises.delete(file.id);
thumb = await this.getThumbnailForPreview(file, localOnly);
}

View file

@ -201,6 +201,7 @@ class MLWorkManager {
}
private async runMLSyncJob(): Promise<MLSyncJobResult> {
try {
// TODO: skipping is not required if we are caching chunks through service worker
// currently worker chunk itself is not loaded when network is not there
if (!navigator.onLine) {
@ -230,6 +231,9 @@ class MLWorkManager {
// TODO: redirect/refresh to gallery in case of session_expired, stop ml sync job
return jobResult;
} catch (e) {
logError(e, 'Failed to run MLSync Job');
}
}
public async startSyncJob() {

View file

@ -1,6 +1,7 @@
import { expose, Remote, wrap } from 'comlink';
import { WorkerSafeElectronClient } from '@ente/shared/electron/worker/client';
import { addLocalLog } from '@ente/shared/logging';
import { logError } from '../sentry';
export class ComlinkWorker<T extends new () => InstanceType<T>> {
public remote: Promise<Remote<InstanceType<T>>>;
@ -12,7 +13,10 @@ export class ComlinkWorker<T extends new () => InstanceType<T>> {
this.worker = worker;
this.worker.onerror = (errorEvent) => {
console.error('Got error event from worker', errorEvent);
logError(Error(errorEvent.message), 'Got error event from worker', {
errorEvent: JSON.stringify(errorEvent),
name: this.name,
});
};
addLocalLog(() => `Initiated ${this.name}`);
const comlink = wrap<T>(this.worker);