Skip to content

Cocoa SDK does not discard replayId after session duration limit, causing extremely long replays #5756

@philprime

Description

@philprime

Description

When a replay session exceeds the maximumDuration limit (60 minutes), the Cocoa SDK pauses capturing but does not reset or discard the replayId. As a result, any subsequent calls to captureReplay() or getReplayId() return the same replayId, leading to session replays that span multiple hours or even days.

This behavior causes events far beyond the original session to be stitched together under the same replay on the backend, violating the expected session boundaries.

Expected Behavior:

After reaching the 60-minute limit, the SDK should:

  • Stop the replay session.
  • Discard the current replayId.

See getsentry/sentry-docs#14493

Actual Behavior:

  • SDK pauses but retains the original replayId.
  • getReplayId() continues to return the same value.
  • Replays can reach excessive lengths (e.g., 336 hours), incorrectly associating unrelated events under a single session.

Suggested Fix:

Ensure that once maximumDuration is reached:

  • The replayId is removed from scope.
  • A new session and replayId are generated on next start/capture.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions