fix(tracker): 7.0.3; prevent restarting after manual stop;
This commit is contained in:
parent
f24f8b4fbe
commit
269674c2fd
5 changed files with 30 additions and 9 deletions
|
|
@ -1,3 +1,7 @@
|
|||
# 7.0.3
|
||||
|
||||
- Prevent auto restart after manual stop
|
||||
|
||||
# 7.0.2
|
||||
|
||||
- fixed header sanitization for axios causing empty string in some cases
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker",
|
||||
"description": "The OpenReplay tracker main package",
|
||||
"version": "7.0.2",
|
||||
"version": "7.0.3",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"replay"
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ export default class BatchWriter {
|
|||
if (this.isEmpty) {
|
||||
return
|
||||
}
|
||||
this.onBatch(this.encoder.flush())
|
||||
const batch = this.encoder.flush()
|
||||
this.onBatch(batch)
|
||||
this.prepare()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ export default class QueueSender {
|
|||
private readonly queue: Array<Uint8Array> = []
|
||||
private readonly ingestURL
|
||||
private token: string | null = null
|
||||
private isCompressing = false
|
||||
// its actually on #24
|
||||
// eslint-disable-next-line
|
||||
private isCompressing
|
||||
|
||||
constructor(
|
||||
ingestBaseURL: string,
|
||||
|
|
@ -18,7 +20,11 @@ export default class QueueSender {
|
|||
private readonly onCompress?: (batch: Uint8Array) => any,
|
||||
) {
|
||||
this.ingestURL = ingestBaseURL + INGEST_PATH
|
||||
if (onCompress !== undefined) this.isCompressing = true
|
||||
if (onCompress !== undefined) {
|
||||
this.isCompressing = true
|
||||
} else {
|
||||
this.isCompressing = false
|
||||
}
|
||||
}
|
||||
|
||||
authorise(token: string): void {
|
||||
|
|
@ -124,7 +130,11 @@ export default class QueueSender {
|
|||
}
|
||||
|
||||
clean() {
|
||||
this.queue.length = 0
|
||||
this.token = null
|
||||
// sending last batch and closing the shop
|
||||
this.sendNext()
|
||||
setTimeout(() => {
|
||||
this.token = null
|
||||
this.queue.length = 0
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// https://github.com/microsoft/TypeScript/issues/14877
|
||||
// At the moment "webworker" lib conflicts with jest-environment-jsdom that uses "dom" lib
|
||||
import { Type as MType } from '../common/messages.gen.js'
|
||||
import { ToWorkerData, FromWorkerData } from '../common/interaction.js'
|
||||
import { FromWorkerData } from '../common/interaction.js'
|
||||
|
||||
import QueueSender from './QueueSender.js'
|
||||
import BatchWriter from './BatchWriter.js'
|
||||
|
|
@ -14,6 +14,7 @@ enum WorkerStatus {
|
|||
Starting,
|
||||
Stopping,
|
||||
Active,
|
||||
Stopped,
|
||||
}
|
||||
|
||||
const AUTO_SEND_INTERVAL = 10 * 1000
|
||||
|
|
@ -32,6 +33,7 @@ function finalize(): void {
|
|||
function resetWriter(): void {
|
||||
if (writer) {
|
||||
writer.clean()
|
||||
// we don't need to wait for anything here since its sync
|
||||
writer = null
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +41,10 @@ function resetWriter(): void {
|
|||
function resetSender(): void {
|
||||
if (sender) {
|
||||
sender.clean()
|
||||
sender = null
|
||||
// allowing some time to send last batch
|
||||
setTimeout(() => {
|
||||
sender = null
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +60,7 @@ function reset(): void {
|
|||
}
|
||||
|
||||
function initiateRestart(): void {
|
||||
if (workerStatus === WorkerStatus.Stopped) return
|
||||
postMessage('restart')
|
||||
reset()
|
||||
}
|
||||
|
|
@ -75,7 +81,7 @@ self.onmessage = ({ data }: any): any => {
|
|||
if (data === 'stop') {
|
||||
finalize()
|
||||
reset()
|
||||
return
|
||||
return (workerStatus = WorkerStatus.Stopped)
|
||||
}
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue