fix(tracker): some guards around sender

This commit is contained in:
nick-delirium 2024-01-03 18:00:11 +01:00
parent 9e1add4ad9
commit b75754ef4e
2 changed files with 11 additions and 10 deletions

View file

@ -261,9 +261,9 @@ export default class App {
this.restartAttempts += 1
void this.start({}, true)
}
} else {
this.worker?.postMessage({ type: 'compressed', batch: result })
}
// @ts-ignore
this.worker?.postMessage({ type: 'compressed', batch: result })
})
} else {
this.worker?.postMessage({ type: 'uncompressed', batch: batch })
@ -690,6 +690,13 @@ export default class App {
timestamp: startTimestamp || timestamp,
projectID,
})
this.worker.postMessage({
type: 'auth',
token,
beaconSizeLimit,
})
if (!isNewSession && token === sessionToken) {
this.debug.log('continuing session on new tab', this.session.getTabId())
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@ -701,12 +708,6 @@ export default class App {
)
this.localStorage.setItem(this.options.local_uuid_key, userUUID)
this.worker.postMessage({
type: 'auth',
token,
beaconSizeLimit,
})
this.compressionThreshold = compressionThreshold
const onStartInfo = { sessionToken: token, userUUID, sessionID }

View file

@ -119,7 +119,7 @@ self.onmessage = ({ data }: { data: ToWorkerData }): any => {
initiateRestart()
return
}
sender.sendCompressed(data.batch)
data.batch && sender.sendCompressed(data.batch)
}
if (data.type === 'uncompressed') {
if (!sender) {
@ -127,7 +127,7 @@ self.onmessage = ({ data }: { data: ToWorkerData }): any => {
initiateRestart()
return
}
sender.sendUncompressed(data.batch)
data.batch && sender.sendUncompressed(data.batch)
}
if (data.type === 'start') {