@multiplayer-app/session-recorder-browser 2.0.38 → 2.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25163,7 +25163,7 @@ const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
25163
25163
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
25164
25164
  const REMOTE_SESSION_RECORDING_START = 'remote-session-recording:start';
25165
25165
  const REMOTE_SESSION_RECORDING_STOP = 'remote-session-recording:stop';
25166
- const PACKAGE_VERSION_EXPORT = "2.0.38" || 0;
25166
+ const PACKAGE_VERSION_EXPORT = "2.0.39" || 0;
25167
25167
  // Regex patterns for OpenTelemetry ignore URLs
25168
25168
  const OTEL_IGNORE_URLS = [
25169
25169
  // Traces endpoint
@@ -26907,6 +26907,7 @@ __webpack_require__.r(__webpack_exports__);
26907
26907
 
26908
26908
  class RecorderBrowserSDK {
26909
26909
  constructor() {
26910
+ this.generation = 0;
26910
26911
  this.intervals = {
26911
26912
  restart: null,
26912
26913
  bufferSnapshot: null,
@@ -26942,12 +26943,15 @@ class RecorderBrowserSDK {
26942
26943
  throw new Error('Configuration not initialized. Call init() before start().');
26943
26944
  }
26944
26945
  this.startedAt = new Date().toISOString();
26946
+ const gen = ++this.generation;
26945
26947
  this.stopFn = (0,rrweb__WEBPACK_IMPORTED_MODULE_6__.record)({
26946
26948
  ...this._buildRecordOptions(),
26947
26949
  emit: async (event) => {
26950
+ if (gen !== this.generation)
26951
+ return;
26948
26952
  const ts = event.timestamp;
26949
26953
  if (!sessionId) {
26950
- await this._handleBufferOnlyEvent(event, ts);
26954
+ await this._handleBufferOnlyEvent(event, ts, gen);
26951
26955
  return;
26952
26956
  }
26953
26957
  this._handleLiveSessionEvent(event, ts, sessionId, sessionType);
@@ -26963,6 +26967,7 @@ class RecorderBrowserSDK {
26963
26967
  var _a;
26964
26968
  try {
26965
26969
  (_a = this.stopFn) === null || _a === void 0 ? void 0 : _a.call(this);
26970
+ this.stopFn = undefined;
26966
26971
  this.start(sessionId, sessionType);
26967
26972
  }
26968
26973
  catch (_e) {
@@ -26976,6 +26981,7 @@ class RecorderBrowserSDK {
26976
26981
  var _a, _b, _c;
26977
26982
  (_a = this.stopFn) === null || _a === void 0 ? void 0 : _a.call(this);
26978
26983
  this.stopFn = undefined;
26984
+ this.generation++;
26979
26985
  if (!((_b = this.config) === null || _b === void 0 ? void 0 : _b.useWebsocket)) {
26980
26986
  (_c = this.socketService) === null || _c === void 0 ? void 0 : _c.close();
26981
26987
  }
@@ -27015,13 +27021,15 @@ class RecorderBrowserSDK {
27015
27021
  * @param event - Event.
27016
27022
  * @param ts - Timestamp.
27017
27023
  */
27018
- async _handleBufferOnlyEvent(event, ts) {
27024
+ async _handleBufferOnlyEvent(event, ts, gen) {
27019
27025
  if (!this.crashBuffer)
27020
27026
  return;
27021
27027
  try {
27022
27028
  this._applyConsoleMasking(event);
27023
27029
  const packedEvent = (0,_rrweb_packer__WEBPACK_IMPORTED_MODULE_0__.pack)(event);
27024
27030
  this.stoppedAt = new Date(ts).toISOString();
27031
+ if (gen !== this.generation)
27032
+ return;
27025
27033
  await this.crashBuffer.appendEvent({
27026
27034
  ts,
27027
27035
  isFullSnapshot: event.type === _rrweb_types__WEBPACK_IMPORTED_MODULE_1__.EventType.FullSnapshot,
@@ -28975,7 +28983,11 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
28975
28983
  this._tracer.stop();
28976
28984
  this._recorder.stop();
28977
28985
  this._navigationRecorder.stop();
28978
- this._startBufferOnlyRecording();
28986
+ // rrweb assigns new node IDs on each record() call, so the next buffer
28987
+ // segment must not carry events from the previous generation. Await the
28988
+ // clear so its IDB tx can't race past the fresh FullSnapshot.
28989
+ const cleared = this._crashBuffer ? this._crashBuffer.clear() : Promise.resolve();
28990
+ void cleared.catch(() => undefined).then(() => this._startBufferOnlyRecording());
28979
28991
  }
28980
28992
  /**
28981
28993
  * Pause the session tracing and recording