From 4a5093addff8441ef799df3e07d487e2e746cc3c Mon Sep 17 00:00:00 2001 From: ShiKhu Date: Tue, 21 Jun 2022 01:05:20 +0200 Subject: [PATCH 01/14] refactor(tracker/BatchWriter): explicit logic --- tracker/tracker/src/webworker/BatchWriter.ts | 58 +++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/tracker/tracker/src/webworker/BatchWriter.ts b/tracker/tracker/src/webworker/BatchWriter.ts index 7ddf97dbe..e5b9c3674 100644 --- a/tracker/tracker/src/webworker/BatchWriter.ts +++ b/tracker/tracker/src/webworker/BatchWriter.ts @@ -16,11 +16,25 @@ export default class BatchWriter { private timestamp: number, private onBatch: (batch: Uint8Array) => void ) { - this.prepareBatchMeta() + this.prepare() } - private prepareBatchMeta(): boolean { - return new BatchMeta(this.pageNo, this.nextIndex, this.timestamp).encode(this.writer) + private prepare(): void { + if (!this.writer.isEmpty()) { + //console.log("") + return + } + new BatchMeta(this.pageNo, this.nextIndex, this.timestamp).encode(this.writer) + } + + private write(message: Message): boolean { + const wasWritten = message.encode(this.writer) + if (wasWritten) { + this.isEmpty = false + this.writer.checkpoint() + this.nextIndex++ + } + return wasWritten } private beaconSizeLimit = 1e6 @@ -28,41 +42,31 @@ export default class BatchWriter { this.beaconSizeLimit = limit } - // TODO: clear workflow writeMessage(message: Message) { if (message instanceof Timestamp) { this.timestamp = (message).timestamp } - - if (!message.encode(this.writer)) { - if (!this.isEmpty) { - this.onBatch(this.writer.flush()) - this.prepareBatchMeta() - } - - while (!message.encode(this.writer)) { - if (this.beaconSize === this.beaconSizeLimit) { - console.warn("OpenReplay: beacon size overflow. Skipping large message."); - this.writer.reset() - this.prepareBatchMeta() - this.isEmpty = true - return - } - // MBTODO: tempWriter for one message? - this.beaconSize = Math.min(this.beaconSize*2, this.beaconSizeLimit) - this.writer = new PrimitiveWriter(this.beaconSize) - this.prepareBatchMeta() + while (!this.write(message)) { + this.finaliseBatch() + if (this.beaconSize === this.beaconSizeLimit) { + console.warn("OpenReplay: beacon size overflow. Skipping large message."); + this.writer.reset() + this.prepare() + this.isEmpty = true + return } + // MBTODO: tempWriter for one message? + this.beaconSize = Math.min(this.beaconSize*2, this.beaconSizeLimit) + this.writer = new PrimitiveWriter(this.beaconSize) + this.prepare() + this.isEmpty = true } - this.writer.checkpoint() - this.nextIndex++ - this.isEmpty = false } finaliseBatch() { if (this.isEmpty) { return } this.onBatch(this.writer.flush()) - this.prepareBatchMeta() + this.prepare() this.isEmpty = true } From 869a25169f4f4081ac3f4a79968f014b8b4cf760 Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 15 Jun 2022 10:59:30 +0200 Subject: [PATCH 02/14] fix(tracker): potential fix for writer busy status --- tracker/tracker/src/common/webworker.ts | 15 ++++++++++- tracker/tracker/src/main/app/index.ts | 4 ++- tracker/tracker/src/webworker/index.ts | 34 +++++++++++++++++++++---- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/tracker/tracker/src/common/webworker.ts b/tracker/tracker/src/common/webworker.ts index 34ac7f582..3f2cc50d9 100644 --- a/tracker/tracker/src/common/webworker.ts +++ b/tracker/tracker/src/common/webworker.ts @@ -1,6 +1,7 @@ export interface Options { connAttemptCount?: number connAttemptGap?: number + workerLog?: WorkerActivityLogStatus } type Start = { @@ -16,4 +17,16 @@ type Auth = { beaconSizeLimit?: number } -export type WorkerMessageData = null | "stop" | Start | Auth | Array<{ _id: number }> \ No newline at end of file +type Log = { + type: "log" + log: WorkerActivityLogStatus +} + +export enum WorkerActivityLogStatus { + Off, + Console, + Error, +} + + +export type WorkerMessageData = null | "stop" | Start | Auth | Array<{ _id: number }> | Log diff --git a/tracker/tracker/src/main/app/index.ts b/tracker/tracker/src/main/app/index.ts index 4f5487bfa..ed3a025a7 100644 --- a/tracker/tracker/src/main/app/index.ts +++ b/tracker/tracker/src/main/app/index.ts @@ -14,7 +14,7 @@ import type { Options as ObserverOptions } from "./observer/top_observer.js"; import type { Options as SanitizerOptions } from "./sanitizer.js"; import type { Options as LoggerOptions } from "./logger.js" import type { Options as WebworkerOptions, WorkerMessageData } from "../../common/webworker.js"; - +import { WorkerActivityLogStatus } from "../../common/webworker.js"; // TODO: Unify and clearly describe options logic export interface StartOptions { @@ -120,6 +120,7 @@ export default class App { __debug_report_edp: null, localStorage: window.localStorage, sessionStorage: window.sessionStorage, + workerLog: WorkerActivityLogStatus.Off, }, options, ); @@ -351,6 +352,7 @@ export default class App { timestamp: startInfo.timestamp, connAttemptCount: this.options.connAttemptCount, connAttemptGap: this.options.connAttemptGap, + workerLog: this.options.workerLog, } this.worker.postMessage(startWorkerMsg) // brings delay of 10th ms? diff --git a/tracker/tracker/src/webworker/index.ts b/tracker/tracker/src/webworker/index.ts index 3e9341a2d..5eb31320d 100644 --- a/tracker/tracker/src/webworker/index.ts +++ b/tracker/tracker/src/webworker/index.ts @@ -1,5 +1,5 @@ import type Message from "../common/messages.js"; -import type { WorkerMessageData } from "../common/webworker.js"; +import { WorkerMessageData, WorkerActivityLogStatus } from "../common/webworker.js"; import { classes, @@ -9,12 +9,19 @@ import { import QueueSender from "./QueueSender.js"; import BatchWriter from "./BatchWriter.js"; - +enum WorkerStatus { + NotActive, + Starting, + Stopping, + Active +} const AUTO_SEND_INTERVAL = 10 * 1000 let sender: QueueSender | null = null let writer: BatchWriter | null = null +let workerStatus: WorkerStatus = WorkerStatus.NotActive; +let workerLogStatus: WorkerActivityLogStatus = WorkerActivityLogStatus.Off; function send(): void { if (!writer) { @@ -25,6 +32,7 @@ function send(): void { function reset() { + workerStatus = WorkerStatus.Stopping if (sendIntervalID !== null) { clearInterval(sendIntervalID); sendIntervalID = null; @@ -33,6 +41,7 @@ function reset() { writer.clean() writer = null } + workerStatus = WorkerStatus.NotActive } function resetCleanQueue() { @@ -51,7 +60,6 @@ self.onmessage = ({ data }: MessageEvent) => { send() // TODO: sendAll? return } - if (data === "stop") { send() reset() @@ -59,8 +67,22 @@ self.onmessage = ({ data }: MessageEvent) => { } if (Array.isArray(data)) { + if (workerStatus !== WorkerStatus.Active) { + if (workerLogStatus !== WorkerActivityLogStatus.Off) { + const msg = 'WebWorker: trying to send data without writer' + switch (workerLogStatus) { + case WorkerActivityLogStatus.Console: + return console.error(msg, 'STATUS:', workerStatus, data) + case WorkerActivityLogStatus.Error: + throw new Error(`${msg} ----- STATUS: ${workerStatus} --- ${JSON.stringify(data)}`); + default: + return; + } + } + return; + } if (!writer) { - throw new Error("WebWorker: writer not initialised.") + throw new Error("WebWorker: writer not initialised. Service Should be Started.") } const w = writer // Message[] @@ -80,6 +102,8 @@ self.onmessage = ({ data }: MessageEvent) => { } if (data.type === 'start') { + workerLogStatus = data.workerLog || WorkerActivityLogStatus.Off + workerStatus = WorkerStatus.Starting sender = new QueueSender( data.ingestPoint, () => { // onUnauthorised @@ -101,7 +125,7 @@ self.onmessage = ({ data }: MessageEvent) => { if (sendIntervalID === null) { sendIntervalID = setInterval(send, AUTO_SEND_INTERVAL) } - return + return workerStatus = WorkerStatus.Active } if (data.type === "auth") { From 8d919e49cc6764f0a36c77dafd11172612bc9a96 Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 15 Jun 2022 11:06:52 +0200 Subject: [PATCH 03/14] fix(tracker): add optional data in error --- tracker/tracker/src/common/webworker.ts | 1 + tracker/tracker/src/webworker/index.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tracker/tracker/src/common/webworker.ts b/tracker/tracker/src/common/webworker.ts index 3f2cc50d9..0ecfdfd07 100644 --- a/tracker/tracker/src/common/webworker.ts +++ b/tracker/tracker/src/common/webworker.ts @@ -26,6 +26,7 @@ export enum WorkerActivityLogStatus { Off, Console, Error, + ErrorWithData, } diff --git a/tracker/tracker/src/webworker/index.ts b/tracker/tracker/src/webworker/index.ts index 5eb31320d..701b2a87f 100644 --- a/tracker/tracker/src/webworker/index.ts +++ b/tracker/tracker/src/webworker/index.ts @@ -74,7 +74,9 @@ self.onmessage = ({ data }: MessageEvent) => { case WorkerActivityLogStatus.Console: return console.error(msg, 'STATUS:', workerStatus, data) case WorkerActivityLogStatus.Error: - throw new Error(`${msg} ----- STATUS: ${workerStatus} --- ${JSON.stringify(data)}`); + throw new Error(`${msg} ----- STATUS: ${workerStatus}`); + case WorkerActivityLogStatus.ErrorWithData: + throw new Error(`${msg} ----- STATUS: ${workerStatus} --- ${JSON.stringify(data)}`) default: return; } From d6fd7b312aba1ae259fe2da7f7c682041598a328 Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 15 Jun 2022 11:08:59 +0200 Subject: [PATCH 04/14] fix(tracker): rm unused --- tracker/tracker/src/common/webworker.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tracker/tracker/src/common/webworker.ts b/tracker/tracker/src/common/webworker.ts index 0ecfdfd07..36228626c 100644 --- a/tracker/tracker/src/common/webworker.ts +++ b/tracker/tracker/src/common/webworker.ts @@ -17,11 +17,6 @@ type Auth = { beaconSizeLimit?: number } -type Log = { - type: "log" - log: WorkerActivityLogStatus -} - export enum WorkerActivityLogStatus { Off, Console, From 87504488417dbc2f6bd062a464ff803efa7f54dd Mon Sep 17 00:00:00 2001 From: sylenien Date: Thu, 16 Jun 2022 10:10:35 +0200 Subject: [PATCH 05/14] fix(tracker): typo --- tracker/tracker/src/common/webworker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracker/tracker/src/common/webworker.ts b/tracker/tracker/src/common/webworker.ts index 36228626c..bf3874960 100644 --- a/tracker/tracker/src/common/webworker.ts +++ b/tracker/tracker/src/common/webworker.ts @@ -25,4 +25,4 @@ export enum WorkerActivityLogStatus { } -export type WorkerMessageData = null | "stop" | Start | Auth | Array<{ _id: number }> | Log +export type WorkerMessageData = null | "stop" | Start | Auth | Array<{ _id: number }> From fedd89c1198d68f1dd3c62b0190b86009483ca9f Mon Sep 17 00:00:00 2001 From: sylenien Date: Thu, 16 Jun 2022 10:21:43 +0200 Subject: [PATCH 06/14] fix(tracker): wworker build fix --- tracker/tracker/src/webworker/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracker/tracker/src/webworker/index.ts b/tracker/tracker/src/webworker/index.ts index 701b2a87f..3502575ab 100644 --- a/tracker/tracker/src/webworker/index.ts +++ b/tracker/tracker/src/webworker/index.ts @@ -74,9 +74,9 @@ self.onmessage = ({ data }: MessageEvent) => { case WorkerActivityLogStatus.Console: return console.error(msg, 'STATUS:', workerStatus, data) case WorkerActivityLogStatus.Error: - throw new Error(`${msg} ----- STATUS: ${workerStatus}`); + throw new Error(msg + '----- STATUS:' + workerStatus); case WorkerActivityLogStatus.ErrorWithData: - throw new Error(`${msg} ----- STATUS: ${workerStatus} --- ${JSON.stringify(data)}`) + throw new Error(msg + '----- STATUS:' + workerStatus + JSON.stringify(data)) default: return; } From 5e7e4980885fca3e8febb7d60d0e99060f48f86a Mon Sep 17 00:00:00 2001 From: sylenien Date: Tue, 21 Jun 2022 12:46:49 +0200 Subject: [PATCH 07/14] fix(tracker): fix state updating --- .../player/MessageDistributor/MessageDistributor.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/app/player/MessageDistributor/MessageDistributor.ts b/frontend/app/player/MessageDistributor/MessageDistributor.ts index 582cd7211..15dcd765e 100644 --- a/frontend/app/player/MessageDistributor/MessageDistributor.ts +++ b/frontend/app/player/MessageDistributor/MessageDistributor.ts @@ -202,6 +202,7 @@ export default class MessageDistributor extends StatedScreen { move(t: number, index?: number): void { const stateToUpdate: Partial = {}; + let changed = false; /* == REFACTOR_ME == */ const lastLoadedLocationMsg = this.loadedLocationManager.moveGetLast(t, index); if (!!lastLoadedLocationMsg) { @@ -211,44 +212,51 @@ export default class MessageDistributor extends StatedScreen { const llEvent = this.locationEventManager.moveGetLast(t, index); if (!!llEvent) { if (llEvent.domContentLoadedTime != null) { + changed = true; stateToUpdate.domContentLoadedTime = { time: llEvent.domContentLoadedTime + this.navigationStartOffset, //TODO: predefined list of load event for the network tab (merge events & SetPageLocation: add navigationStart to db) value: llEvent.domContentLoadedTime, } } if (llEvent.loadTime != null) { + changed = true; stateToUpdate.loadTime = { time: llEvent.loadTime + this.navigationStartOffset, value: llEvent.loadTime, } } if (llEvent.domBuildingTime != null) { + changed = true; stateToUpdate.domBuildingTime = llEvent.domBuildingTime; } } /* === */ const lastLocationMsg = this.locationManager.moveGetLast(t, index); if (!!lastLocationMsg) { + changed = true; stateToUpdate.location = lastLocationMsg.url; } const lastConnectionInfoMsg = this.connectionInfoManger.moveGetLast(t, index); if (!!lastConnectionInfoMsg) { + changed = true; stateToUpdate.connType = lastConnectionInfoMsg.type; stateToUpdate.connBandwidth = lastConnectionInfoMsg.downlink; } const lastPerformanceTrackMessage = this.performanceTrackManager.moveGetLast(t, index); if (!!lastPerformanceTrackMessage) { + changed = true; stateToUpdate.performanceChartTime = lastPerformanceTrackMessage.time; } LIST_NAMES.forEach(key => { const lastMsg = this.lists[key].moveGetLast(t, key === 'exceptions' ? undefined : index); if (lastMsg != null) { + changed = true; stateToUpdate[`${key}ListNow`] = this.lists[key].listNow; } }); - update(stateToUpdate); + changed && update(stateToUpdate); /* Sequence of the managers is important here */ // Preparing the size of "screen" From 692a0505e84695c7c598a829de591a24cc1f8955 Mon Sep 17 00:00:00 2001 From: sylenien Date: Tue, 21 Jun 2022 16:59:23 +0200 Subject: [PATCH 08/14] fix(tracker): typo fix --- tracker/tracker/src/webworker/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracker/tracker/src/webworker/index.ts b/tracker/tracker/src/webworker/index.ts index 3502575ab..76fd333e7 100644 --- a/tracker/tracker/src/webworker/index.ts +++ b/tracker/tracker/src/webworker/index.ts @@ -132,10 +132,10 @@ self.onmessage = ({ data }: MessageEvent) => { if (data.type === "auth") { if (!sender) { - throw new Error("WebWorker: sender not initialised. Recieved auth.") + throw new Error("WebWorker: sender not initialised. Received auth.") } if (!writer) { - throw new Error("WebWorker: writer not initialised. Recieved auth.") + throw new Error("WebWorker: writer not initialised. Received auth.") } sender.authorise(data.token) data.beaconSizeLimit && writer.setBeaconSizeLimit(data.beaconSizeLimit) From f1998eab3ce787cc47d6d684c1fd751d47705f94 Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 22 Jun 2022 09:48:49 +0200 Subject: [PATCH 09/14] fix(tracker): move activity state under worker start --- tracker/tracker/src/main/app/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tracker/tracker/src/main/app/index.ts b/tracker/tracker/src/main/app/index.ts index ed3a025a7..98e595ea3 100644 --- a/tracker/tracker/src/main/app/index.ts +++ b/tracker/tracker/src/main/app/index.ts @@ -400,7 +400,6 @@ export default class App { ...startOpts }); - this.activityState = ActivityState.Active const startWorkerMsg: WorkerMessageData = { type: "auth", token, @@ -408,6 +407,9 @@ export default class App { } this.worker.postMessage(startWorkerMsg) + + this.activityState = ActivityState.Active + const onStartInfo = { sessionToken: token, userUUID, sessionID }; this.startCallbacks.forEach((cb) => cb(onStartInfo)); From 845cf64e44706b7642070f09a65a40af4a4a367d Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 22 Jun 2022 09:51:19 +0200 Subject: [PATCH 10/14] fix(tracker): rm console --- tracker/tracker/src/webworker/BatchWriter.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tracker/tracker/src/webworker/BatchWriter.ts b/tracker/tracker/src/webworker/BatchWriter.ts index e5b9c3674..181663300 100644 --- a/tracker/tracker/src/webworker/BatchWriter.ts +++ b/tracker/tracker/src/webworker/BatchWriter.ts @@ -21,7 +21,6 @@ export default class BatchWriter { private prepare(): void { if (!this.writer.isEmpty()) { - //console.log("") return } new BatchMeta(this.pageNo, this.nextIndex, this.timestamp).encode(this.writer) @@ -74,4 +73,4 @@ export default class BatchWriter { this.writer.reset() } -} \ No newline at end of file +} From 0a66b2361374da10be80c2e6d4b1f1463b0fb9bb Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 22 Jun 2022 12:24:07 +0200 Subject: [PATCH 11/14] fix(tracker): move worker stop to the end of stop func --- tracker/tracker/src/main/app/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tracker/tracker/src/main/app/index.ts b/tracker/tracker/src/main/app/index.ts index 98e595ea3..ea962e3bb 100644 --- a/tracker/tracker/src/main/app/index.ts +++ b/tracker/tracker/src/main/app/index.ts @@ -452,15 +452,15 @@ export default class App { stop(): void { if (this.activityState !== ActivityState.NotActive) { try { - if (this.worker) { - this.worker.postMessage("stop") - } this.sanitizer.clear() this.observer.disconnect() this.nodes.clear() this.ticker.stop() this.stopCallbacks.forEach((cb) => cb()) this.notify.log("OpenReplay tracking stopped.") + if (this.worker) { + this.worker.postMessage("stop") + } } finally { this.activityState = ActivityState.NotActive } From 22d7c4acd026b44546dff92eced27563939ead9f Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 22 Jun 2022 12:41:07 +0200 Subject: [PATCH 12/14] fix(tracker): change checks for state update --- .../player/MessageDistributor/MessageDistributor.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/frontend/app/player/MessageDistributor/MessageDistributor.ts b/frontend/app/player/MessageDistributor/MessageDistributor.ts index 15dcd765e..1abd26979 100644 --- a/frontend/app/player/MessageDistributor/MessageDistributor.ts +++ b/frontend/app/player/MessageDistributor/MessageDistributor.ts @@ -202,7 +202,6 @@ export default class MessageDistributor extends StatedScreen { move(t: number, index?: number): void { const stateToUpdate: Partial = {}; - let changed = false; /* == REFACTOR_ME == */ const lastLoadedLocationMsg = this.loadedLocationManager.moveGetLast(t, index); if (!!lastLoadedLocationMsg) { @@ -212,51 +211,44 @@ export default class MessageDistributor extends StatedScreen { const llEvent = this.locationEventManager.moveGetLast(t, index); if (!!llEvent) { if (llEvent.domContentLoadedTime != null) { - changed = true; stateToUpdate.domContentLoadedTime = { time: llEvent.domContentLoadedTime + this.navigationStartOffset, //TODO: predefined list of load event for the network tab (merge events & SetPageLocation: add navigationStart to db) value: llEvent.domContentLoadedTime, } } if (llEvent.loadTime != null) { - changed = true; stateToUpdate.loadTime = { time: llEvent.loadTime + this.navigationStartOffset, value: llEvent.loadTime, } } if (llEvent.domBuildingTime != null) { - changed = true; stateToUpdate.domBuildingTime = llEvent.domBuildingTime; } } /* === */ const lastLocationMsg = this.locationManager.moveGetLast(t, index); if (!!lastLocationMsg) { - changed = true; stateToUpdate.location = lastLocationMsg.url; } const lastConnectionInfoMsg = this.connectionInfoManger.moveGetLast(t, index); if (!!lastConnectionInfoMsg) { - changed = true; stateToUpdate.connType = lastConnectionInfoMsg.type; stateToUpdate.connBandwidth = lastConnectionInfoMsg.downlink; } const lastPerformanceTrackMessage = this.performanceTrackManager.moveGetLast(t, index); if (!!lastPerformanceTrackMessage) { - changed = true; stateToUpdate.performanceChartTime = lastPerformanceTrackMessage.time; } LIST_NAMES.forEach(key => { const lastMsg = this.lists[key].moveGetLast(t, key === 'exceptions' ? undefined : index); if (lastMsg != null) { - changed = true; stateToUpdate[`${key}ListNow`] = this.lists[key].listNow; } }); - changed && update(stateToUpdate); + Object.keys(stateToUpdate).length > 0 && update(stateToUpdate); /* Sequence of the managers is important here */ // Preparing the size of "screen" From 794c7f72d4778890b030bd406bd861d1144fb1e0 Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 22 Jun 2022 12:49:46 +0200 Subject: [PATCH 13/14] fix(tracker): remove wworker logs(unused) --- tracker/tracker/src/common/webworker.ts | 9 --------- tracker/tracker/src/main/app/index.ts | 2 -- tracker/tracker/src/webworker/index.ts | 20 +------------------- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/tracker/tracker/src/common/webworker.ts b/tracker/tracker/src/common/webworker.ts index bf3874960..3f6de9c35 100644 --- a/tracker/tracker/src/common/webworker.ts +++ b/tracker/tracker/src/common/webworker.ts @@ -1,7 +1,6 @@ export interface Options { connAttemptCount?: number connAttemptGap?: number - workerLog?: WorkerActivityLogStatus } type Start = { @@ -17,12 +16,4 @@ type Auth = { beaconSizeLimit?: number } -export enum WorkerActivityLogStatus { - Off, - Console, - Error, - ErrorWithData, -} - - export type WorkerMessageData = null | "stop" | Start | Auth | Array<{ _id: number }> diff --git a/tracker/tracker/src/main/app/index.ts b/tracker/tracker/src/main/app/index.ts index ea962e3bb..478f7d8fe 100644 --- a/tracker/tracker/src/main/app/index.ts +++ b/tracker/tracker/src/main/app/index.ts @@ -120,7 +120,6 @@ export default class App { __debug_report_edp: null, localStorage: window.localStorage, sessionStorage: window.sessionStorage, - workerLog: WorkerActivityLogStatus.Off, }, options, ); @@ -352,7 +351,6 @@ export default class App { timestamp: startInfo.timestamp, connAttemptCount: this.options.connAttemptCount, connAttemptGap: this.options.connAttemptGap, - workerLog: this.options.workerLog, } this.worker.postMessage(startWorkerMsg) // brings delay of 10th ms? diff --git a/tracker/tracker/src/webworker/index.ts b/tracker/tracker/src/webworker/index.ts index 76fd333e7..7d1cb0393 100644 --- a/tracker/tracker/src/webworker/index.ts +++ b/tracker/tracker/src/webworker/index.ts @@ -1,5 +1,5 @@ import type Message from "../common/messages.js"; -import { WorkerMessageData, WorkerActivityLogStatus } from "../common/webworker.js"; +import { WorkerMessageData } from "../common/webworker.js"; import { classes, @@ -21,7 +21,6 @@ const AUTO_SEND_INTERVAL = 10 * 1000 let sender: QueueSender | null = null let writer: BatchWriter | null = null let workerStatus: WorkerStatus = WorkerStatus.NotActive; -let workerLogStatus: WorkerActivityLogStatus = WorkerActivityLogStatus.Off; function send(): void { if (!writer) { @@ -67,22 +66,6 @@ self.onmessage = ({ data }: MessageEvent) => { } if (Array.isArray(data)) { - if (workerStatus !== WorkerStatus.Active) { - if (workerLogStatus !== WorkerActivityLogStatus.Off) { - const msg = 'WebWorker: trying to send data without writer' - switch (workerLogStatus) { - case WorkerActivityLogStatus.Console: - return console.error(msg, 'STATUS:', workerStatus, data) - case WorkerActivityLogStatus.Error: - throw new Error(msg + '----- STATUS:' + workerStatus); - case WorkerActivityLogStatus.ErrorWithData: - throw new Error(msg + '----- STATUS:' + workerStatus + JSON.stringify(data)) - default: - return; - } - } - return; - } if (!writer) { throw new Error("WebWorker: writer not initialised. Service Should be Started.") } @@ -104,7 +87,6 @@ self.onmessage = ({ data }: MessageEvent) => { } if (data.type === 'start') { - workerLogStatus = data.workerLog || WorkerActivityLogStatus.Off workerStatus = WorkerStatus.Starting sender = new QueueSender( data.ingestPoint, From 13043f6ee7efcf17c4189929bf4cfd821a30efbd Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 22 Jun 2022 14:05:35 +0200 Subject: [PATCH 14/14] fix(tracker): rm unused --- tracker/tracker/src/main/app/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tracker/tracker/src/main/app/index.ts b/tracker/tracker/src/main/app/index.ts index 478f7d8fe..e7dab811e 100644 --- a/tracker/tracker/src/main/app/index.ts +++ b/tracker/tracker/src/main/app/index.ts @@ -14,7 +14,6 @@ import type { Options as ObserverOptions } from "./observer/top_observer.js"; import type { Options as SanitizerOptions } from "./sanitizer.js"; import type { Options as LoggerOptions } from "./logger.js" import type { Options as WebworkerOptions, WorkerMessageData } from "../../common/webworker.js"; -import { WorkerActivityLogStatus } from "../../common/webworker.js"; // TODO: Unify and clearly describe options logic export interface StartOptions {