diff --git a/packages/rrweb/src/replay/machine.ts b/packages/rrweb/src/replay/machine.ts index 1d7896c9d5..00f452d2b2 100644 --- a/packages/rrweb/src/replay/machine.ts +++ b/packages/rrweb/src/replay/machine.ts @@ -11,6 +11,7 @@ import { EventType, type Emitter, IncrementalSource, + type metaEvent, } from '@rrweb/types'; import { Timer, addDelay } from './timer'; @@ -59,6 +60,17 @@ export type PlayerState = context: PlayerContext; }; + + +type metaEventWithTime = metaEvent & { + timestamp: number; + delay?: number; +}; + +function isMetaEvent(e: eventWithTime): e is metaEventWithTime { + return e.type === EventType.Meta; +} + /** * If the array have multiple meta and fullsnapshot events, * return the events from last meta to the end. @@ -311,9 +323,8 @@ export function createPlayerService( event.data.capturedAssetStatuses ) { awaitAssetsHref = ''; - const earlierMetas = events.filter( - (e) => - e.type === EventType.Meta && e.timestamp <= event.timestamp, + const earlierMetas: metaEvent[] = events.filter(isMetaEvent).filter( + (e) => e.timestamp <= event.timestamp, ); if (earlierMetas.length) { awaitAssetsHref =