Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay): skip malformed network entries instead of crashing (#83780)

Christian Rafferty9e21dc621b70
diff --git a/frontend/src/scenes/session-recordings/apm/performance-event-utils.test.ts b/frontend/src/scenes/session-recordings/apm/performance-event-utils.test.ts
index d1ec761e25ff..586c9b7a109b 100644
--- a/frontend/src/scenes/session-recordings/apm/performance-event-utils.test.ts
+++ b/frontend/src/scenes/session-recordings/apm/performance-event-utils.test.ts
@@ -300,4 +300,28 @@ describe('performance-event-utils', () => {
})
expect(result).toEqual([])
})
+
+ it('skips malformed entries in rrweb/network@1 requests instead of crashing', () => {
+ const snapshot = {
+ windowId: '018d5247-079c-7126-8e43-464605576a62',
+ type: 6,
+ data: {
+ plugin: 'rrweb/network@1',
+ payload: {
+ requests: [
+ null,
+ 'not-a-request',
+ 42,
+ { entryType: 'resource', name: 'https://example.com/a.js', timestamp: 1700000000000 },
+ ],
+ },
+ },
+ timestamp: 1700000000000,
+ } as any
+
+ const result = getPerformanceEvents({
+ '018d5247-079c-7126-8e43-464605576a62': [snapshot],
+ })
+ expect(result.map((r) => r.name)).toEqual(['https://example.com/a.js'])
+ })
})
diff --git a/frontend/src/scenes/session-recordings/apm/performance-event-utils.ts b/frontend/src/scenes/session-recordings/apm/performance-event-utils.ts
index 7cce204368dd..5e59846be254 100644
--- a/frontend/src/scenes/session-recordings/apm/performance-event-utils.ts
+++ b/frontend/src/scenes/session-recordings/apm/performance-event-utils.ts
@@ -270,9 +270,11 @@ export function getPerformanceEvents(snapshotsByWindowId: Record<string, eventWi
const serverTimings: Record<string, PerformanceEvent[]> = {}
- const perfEvents = payload.requests.map((capturedRequest: CapturedNetworkRequest) => {
- return mapRRWebNetworkRequest(capturedRequest, windowId, snapshot.timestamp)
- })
+ const perfEvents = payload.requests
+ .filter((capturedRequest: unknown) => !!capturedRequest && typeof capturedRequest === 'object')
+ .map((capturedRequest: CapturedNetworkRequest) => {
+ return mapRRWebNetworkRequest(capturedRequest, windowId, snapshot.timestamp)
+ })
// first find all server timings and store them by timestamp
perfEvents.forEach((perfEvent: PerformanceEvent) => {