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

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.
package/dist/index.js CHANGED
@@ -24263,7 +24263,7 @@ const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
24263
24263
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
24264
24264
  const REMOTE_SESSION_RECORDING_START = 'remote-session-recording:start';
24265
24265
  const REMOTE_SESSION_RECORDING_STOP = 'remote-session-recording:stop';
24266
- const PACKAGE_VERSION_EXPORT = "2.0.39" || 0;
24266
+ const PACKAGE_VERSION_EXPORT = "2.0.40" || 0;
24267
24267
  // Regex patterns for OpenTelemetry ignore URLs
24268
24268
  const OTEL_IGNORE_URLS = [
24269
24269
  // Traces endpoint
@@ -27571,10 +27571,14 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27571
27571
  }
27572
27572
  _startBufferOnlyRecording() {
27573
27573
  var _a, _b;
27574
- if (this.sessionId ||
27575
- !this._crashBuffer ||
27576
- !((_b = (_a = this._configs) === null || _a === void 0 ? void 0 : _a.buffering) === null || _b === void 0 ? void 0 : _b.enabled) ||
27577
- this.sessionState !== _types__WEBPACK_IMPORTED_MODULE_4__.SessionState.stopped) {
27574
+ // NOTE: `this.sessionId` is intentionally NOT checked. `_stop()` runs
27575
+ // before `_clearSession()` (the stopSession API call sits between them),
27576
+ // so the clear().then() chain fires while sessionId is still set.
27577
+ // Bailing on sessionId here meant rrweb never restarted after manual
27578
+ // stop, leaving the buffer with no FullSnapshot and silently breaking
27579
+ // exception-triggered flushBuffer. `_recorder.restart(null, ...)` passes
27580
+ // null explicitly, so it's safe regardless of `this.sessionId`.
27581
+ if (!this._crashBuffer || !((_b = (_a = this._configs) === null || _a === void 0 ? void 0 : _a.buffering) === null || _b === void 0 ? void 0 : _b.enabled) || this.sessionState !== _types__WEBPACK_IMPORTED_MODULE_4__.SessionState.stopped) {
27578
27582
  return;
27579
27583
  }
27580
27584
  void this._recorder.restart(null, _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL);
@@ -27644,9 +27648,10 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27644
27648
  async stop(comment) {
27645
27649
  try {
27646
27650
  this._checkOperation('stop');
27651
+ const sid = this.sessionId;
27647
27652
  this._stop();
27648
27653
  if (this.continuousRecording) {
27649
- await this._apiService.stopContinuousDebugSession(this.sessionId);
27654
+ await this._apiService.stopContinuousDebugSession(sid);
27650
27655
  this.sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL;
27651
27656
  }
27652
27657
  else {
@@ -27654,10 +27659,9 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27654
27659
  sessionAttributes: { comment },
27655
27660
  stoppedAt: this._recorder.stoppedAt,
27656
27661
  };
27657
- const response = await this._apiService.stopSession(this.sessionId, request);
27662
+ const response = await this._apiService.stopSession(sid, request);
27658
27663
  _eventBus__WEBPACK_IMPORTED_MODULE_7__.recorderEventBus.emit(_config__WEBPACK_IMPORTED_MODULE_5__.SESSION_RESPONSE, response);
27659
27664
  }
27660
- this._clearSession();
27661
27665
  }
27662
27666
  catch (error) {
27663
27667
  this.error = error.message;
@@ -27693,15 +27697,15 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27693
27697
  async cancel() {
27694
27698
  try {
27695
27699
  this._checkOperation('cancel');
27700
+ const sid = this.sessionId;
27696
27701
  this._stop();
27697
27702
  if (this.continuousRecording) {
27698
- await this._apiService.stopContinuousDebugSession(this.sessionId);
27703
+ await this._apiService.stopContinuousDebugSession(sid);
27699
27704
  this.sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL;
27700
27705
  }
27701
27706
  else {
27702
- await this._apiService.cancelSession(this.sessionId);
27707
+ await this._apiService.cancelSession(sid);
27703
27708
  }
27704
- this._clearSession();
27705
27709
  }
27706
27710
  catch (error) {
27707
27711
  this.error = error.message;
@@ -28015,6 +28019,13 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
28015
28019
  this._tracer.stop();
28016
28020
  this._recorder.stop();
28017
28021
  this._navigationRecorder.stop();
28022
+ // Clear session identity synchronously. The buffer-restart chain and the
28023
+ // error-span-appended listener both gate on `this.sessionId === null`;
28024
+ // deferring this to `_clearSession()` (after the network stopSession
28025
+ // call) left them seeing a stale id and silently no-oping. Callers that
28026
+ // need the id for the stop/cancel API must capture it before _stop().
28027
+ this.session = null;
28028
+ this.sessionId = null;
28018
28029
  // rrweb assigns new node IDs on each record() call, so the next buffer
28019
28030
  // segment must not carry events from the previous generation. Await the
28020
28031
  // clear so its IDB tx can't race past the fresh FullSnapshot.