Add ML logging (#1504)
This commit is contained in:
commit
ebc03b5a69
|
@ -211,7 +211,7 @@ class DownloadManagerImpl {
|
||||||
this.thumbnailObjectURLPromises.set(file.id, thumbURLPromise);
|
this.thumbnailObjectURLPromises.set(file.id, thumbURLPromise);
|
||||||
}
|
}
|
||||||
let thumb = await this.thumbnailObjectURLPromises.get(file.id);
|
let thumb = await this.thumbnailObjectURLPromises.get(file.id);
|
||||||
if (!thumb) {
|
if (!thumb && !localOnly) {
|
||||||
this.thumbnailObjectURLPromises.delete(file.id);
|
this.thumbnailObjectURLPromises.delete(file.id);
|
||||||
thumb = await this.getThumbnailForPreview(file, localOnly);
|
thumb = await this.getThumbnailForPreview(file, localOnly);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,35 +201,39 @@ class MLWorkManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runMLSyncJob(): Promise<MLSyncJobResult> {
|
private async runMLSyncJob(): Promise<MLSyncJobResult> {
|
||||||
// TODO: skipping is not required if we are caching chunks through service worker
|
try {
|
||||||
// currently worker chunk itself is not loaded when network is not there
|
// TODO: skipping is not required if we are caching chunks through service worker
|
||||||
if (!navigator.onLine) {
|
// currently worker chunk itself is not loaded when network is not there
|
||||||
addLogLine(
|
if (!navigator.onLine) {
|
||||||
'Skipping ml-sync job run as not connected to internet.'
|
addLogLine(
|
||||||
);
|
'Skipping ml-sync job run as not connected to internet.'
|
||||||
return {
|
);
|
||||||
shouldBackoff: true,
|
return {
|
||||||
mlSyncResult: undefined,
|
shouldBackoff: true,
|
||||||
|
mlSyncResult: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = getToken();
|
||||||
|
const userID = getUserID();
|
||||||
|
const jobWorkerProxy = await this.getSyncJobWorker();
|
||||||
|
|
||||||
|
const mlSyncResult = await jobWorkerProxy.sync(token, userID);
|
||||||
|
|
||||||
|
// this.terminateSyncJobWorker();
|
||||||
|
const jobResult: MLSyncJobResult = {
|
||||||
|
shouldBackoff:
|
||||||
|
!!mlSyncResult.error || mlSyncResult.nOutOfSyncFiles < 1,
|
||||||
|
mlSyncResult,
|
||||||
};
|
};
|
||||||
|
addLogLine('ML Sync Job result: ', JSON.stringify(jobResult));
|
||||||
|
|
||||||
|
// 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = getToken();
|
|
||||||
const userID = getUserID();
|
|
||||||
const jobWorkerProxy = await this.getSyncJobWorker();
|
|
||||||
|
|
||||||
const mlSyncResult = await jobWorkerProxy.sync(token, userID);
|
|
||||||
|
|
||||||
// this.terminateSyncJobWorker();
|
|
||||||
const jobResult: MLSyncJobResult = {
|
|
||||||
shouldBackoff:
|
|
||||||
!!mlSyncResult.error || mlSyncResult.nOutOfSyncFiles < 1,
|
|
||||||
mlSyncResult,
|
|
||||||
};
|
|
||||||
addLogLine('ML Sync Job result: ', JSON.stringify(jobResult));
|
|
||||||
|
|
||||||
// TODO: redirect/refresh to gallery in case of session_expired, stop ml sync job
|
|
||||||
|
|
||||||
return jobResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async startSyncJob() {
|
public async startSyncJob() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { expose, Remote, wrap } from 'comlink';
|
import { expose, Remote, wrap } from 'comlink';
|
||||||
import { WorkerSafeElectronClient } from '@ente/shared/electron/worker/client';
|
import { WorkerSafeElectronClient } from '@ente/shared/electron/worker/client';
|
||||||
import { addLocalLog } from '@ente/shared/logging';
|
import { addLocalLog } from '@ente/shared/logging';
|
||||||
|
import { logError } from '../sentry';
|
||||||
|
|
||||||
export class ComlinkWorker<T extends new () => InstanceType<T>> {
|
export class ComlinkWorker<T extends new () => InstanceType<T>> {
|
||||||
public remote: Promise<Remote<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 = worker;
|
||||||
|
|
||||||
this.worker.onerror = (errorEvent) => {
|
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}`);
|
addLocalLog(() => `Initiated ${this.name}`);
|
||||||
const comlink = wrap<T>(this.worker);
|
const comlink = wrap<T>(this.worker);
|
||||||
|
|
Loading…
Reference in a new issue