change(tracker): 7.0.0. set max amount on restarts for compression error
This commit is contained in:
parent
7b1e86bbc3
commit
836e046c7c
2 changed files with 12 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@openreplay/tracker",
|
"name": "@openreplay/tracker",
|
||||||
"description": "The OpenReplay tracker main package",
|
"description": "The OpenReplay tracker main package",
|
||||||
"version": "6.0.2",
|
"version": "7.0.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"logging",
|
"logging",
|
||||||
"replay"
|
"replay"
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ export default class App {
|
||||||
private readonly version = 'TRACKER_VERSION' // TODO: version compatability check inside each plugin.
|
private readonly version = 'TRACKER_VERSION' // TODO: version compatability check inside each plugin.
|
||||||
private readonly worker?: TypedWorker
|
private readonly worker?: TypedWorker
|
||||||
private compressionThreshold = 24 * 1000
|
private compressionThreshold = 24 * 1000
|
||||||
|
private restartAttempts = 0
|
||||||
|
|
||||||
constructor(projectKey: string, sessionToken: string | undefined, options: Partial<Options>) {
|
constructor(projectKey: string, sessionToken: string | undefined, options: Partial<Options>) {
|
||||||
// if (options.onStart !== undefined) {
|
// if (options.onStart !== undefined) {
|
||||||
|
|
@ -180,9 +181,16 @@ export default class App {
|
||||||
} else if (data.type === 'compress') {
|
} else if (data.type === 'compress') {
|
||||||
const batch = data.batch
|
const batch = data.batch
|
||||||
const batchSize = batch.byteLength
|
const batchSize = batch.byteLength
|
||||||
if (batchSize > 10) {
|
if (batchSize > this.compressionThreshold) {
|
||||||
gzip(data.batch, { mtime: 0 }, (err, result) => {
|
gzip(data.batch, { mtime: 0 }, (err, result) => {
|
||||||
if (err) console.error(err)
|
if (err) {
|
||||||
|
console.error('Openreplay compression error:', err)
|
||||||
|
this.stop(false)
|
||||||
|
if (this.restartAttempts < 3) {
|
||||||
|
this.restartAttempts += 1
|
||||||
|
void this.start({}, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.worker?.postMessage({ type: 'compressed', batch: result })
|
this.worker?.postMessage({ type: 'compressed', batch: result })
|
||||||
})
|
})
|
||||||
|
|
@ -542,6 +550,7 @@ export default class App {
|
||||||
if (typeof this.options.onStart === 'function') {
|
if (typeof this.options.onStart === 'function') {
|
||||||
this.options.onStart(onStartInfo)
|
this.options.onStart(onStartInfo)
|
||||||
}
|
}
|
||||||
|
this.restartAttempts = 0
|
||||||
return SuccessfulStart(onStartInfo)
|
return SuccessfulStart(onStartInfo)
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue