Skip to content

fix(recorder): do not start a recording stopped while it loads - #660

Open
pkuczynski wants to merge 1 commit into
mixpanel:masterfrom
pkuczynski:fix/recording-stop-during-load
Open

pkuczynski wants to merge 1 commit into
mixpanel:masterfrom
pkuczynski:fix/recording-stop-during-load

Conversation

@pkuczynski

Copy link
Copy Markdown
Contributor

Fixes #659.

A stop_session_recording() call, or an opt_out_tracking() call, which stops the recording through _set_persistence_disabled(true), no longer loses to a start that is still pending. Before this change, the recording started once the pending start finished, in two cases:

  • RecorderManager: the stop arrived while the recorder bundle loaded. _recorder was still null, so there was nothing to stop. handleLoadedRecorder then called resumeRecording(true).
  • MixpanelRecorder: the stop arrived while resumeRecording() awaited the registry read. stopRecording() found no activeRecording, and the startNewIfInactive branch started one after the read finished.

Each class now counts stops. A pending start records the count when it is requested and skips the start if the count has changed. A start requested after the stop is not affected.

Unit tests cover both windows, and the case where a second start follows the stop. I also checked the fix in Chrome with a delayed recorder_src and the reproduction from the issue: no replay id appears after either call, and a plain start_session_recording() still records.

A stop_session_recording() or opt_out_tracking() call made while the
recorder bundle loads, or while the recorder reads the recording
registry, did not cancel the pending start. The recording started
once the load or the read finished. Count stops in RecorderManager
and MixpanelRecorder, and skip a pending start when a stop came in
after it was requested.
@pkuczynski
pkuczynski requested review from a team and rahul-mixpanel November 18, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session recording starts after stop_session_recording() or opt_out_tracking() when the call lands while the recorder is still loading

1 participant