fixes for bad start, iframes; 14.0.9

This commit is contained in:
nick-delirium 2024-10-02 15:50:36 +02:00
parent 1cf1137c7d
commit 70a337f766
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 13 additions and 7 deletions

View file

@ -2,6 +2,11 @@
- new webvitals messages source - new webvitals messages source
# 14.0.9
- more stable crossdomain iframe tracking (refactored child/parent process discovery)
- checks for bad start error
# 14.0.8 # 14.0.8
- use separate library to handle network requests ([@openreplay/network-proxy](https://www.npmjs.com/package/@openreplay/network-proxy)) - use separate library to handle network requests ([@openreplay/network-proxy](https://www.npmjs.com/package/@openreplay/network-proxy))

View file

@ -354,6 +354,7 @@ export default class App {
const thisTab = this.session.getTabId() const thisTab = this.session.getTabId()
const catchParentMessage = (event: MessageEvent) => { const catchParentMessage = (event: MessageEvent) => {
if (!this.active()) return
const { data } = event const { data } = event
if (!data) return if (!data) return
if (data.line === proto.parentAlive) { if (data.line === proto.parentAlive) {
@ -370,9 +371,6 @@ export default class App {
} }
window.addEventListener('message', catchParentMessage) window.addEventListener('message', catchParentMessage)
this.attachStopCallback(() => {
window.removeEventListener('message', catchParentMessage)
})
if (this.bc !== null) { if (this.bc !== null) {
this.bc.postMessage({ this.bc.postMessage({
@ -429,6 +427,7 @@ export default class App {
* */ * */
let crossdomainFrameCount = 0 let crossdomainFrameCount = 0
const catchIframeMessage = (event: MessageEvent) => { const catchIframeMessage = (event: MessageEvent) => {
if (!this.active()) return;
const { data } = event const { data } = event
if (!data) return if (!data) return
if (data.line === proto.iframeSignal) { if (data.line === proto.iframeSignal) {
@ -514,9 +513,6 @@ export default class App {
} }
} }
window.addEventListener('message', catchIframeMessage) window.addEventListener('message', catchIframeMessage)
this.attachStopCallback(() => {
window.removeEventListener('message', catchIframeMessage)
})
} }
} }
@ -711,7 +707,6 @@ export default class App {
requestIdleCb(() => { requestIdleCb(() => {
this.messages.unshift(TabData(this.session.getTabId())) this.messages.unshift(TabData(this.session.getTabId()))
this.messages.unshift(Timestamp(this.timestamp())) this.messages.unshift(Timestamp(this.timestamp()))
// why I need to add opt chaining?
this.worker?.postMessage(this.messages) this.worker?.postMessage(this.messages)
this.commitCallbacks.forEach((cb) => cb(this.messages)) this.commitCallbacks.forEach((cb) => cb(this.messages))
this.messages.length = 0 this.messages.length = 0
@ -1441,6 +1436,11 @@ export default class App {
} catch (reason) { } catch (reason) {
this.stop() this.stop()
this.session.reset() this.session.reset()
if (!reason) {
console.error('Unknown error during start')
this.signalError('Unknown error', [])
return UnsuccessfulStart('Unknown error')
}
if (reason === CANCELED) { if (reason === CANCELED) {
this.signalError(CANCELED, []) this.signalError(CANCELED, [])
return UnsuccessfulStart(CANCELED) return UnsuccessfulStart(CANCELED)
@ -1595,6 +1595,7 @@ export default class App {
this.worker.postMessage('stop') this.worker.postMessage('stop')
} }
this.canvasRecorder?.clear() this.canvasRecorder?.clear()
this.messages.length = 0
} finally { } finally {
this.activityState = ActivityState.NotActive this.activityState = ActivityState.NotActive
} }