@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.umd.js CHANGED
@@ -24436,7 +24436,7 @@ const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
24436
24436
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
24437
24437
  const REMOTE_SESSION_RECORDING_START = 'remote-session-recording:start';
24438
24438
  const REMOTE_SESSION_RECORDING_STOP = 'remote-session-recording:stop';
24439
- const PACKAGE_VERSION_EXPORT = "2.0.39" || 0;
24439
+ const PACKAGE_VERSION_EXPORT = "2.0.40" || 0;
24440
24440
  // Regex patterns for OpenTelemetry ignore URLs
24441
24441
  const OTEL_IGNORE_URLS = [
24442
24442
  // Traces endpoint
@@ -27770,10 +27770,14 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27770
27770
  }
27771
27771
  _startBufferOnlyRecording() {
27772
27772
  var _a, _b;
27773
- if (this.sessionId ||
27774
- !this._crashBuffer ||
27775
- !((_b = (_a = this._configs) === null || _a === void 0 ? void 0 : _a.buffering) === null || _b === void 0 ? void 0 : _b.enabled) ||
27776
- this.sessionState !== _types__WEBPACK_IMPORTED_MODULE_4__.SessionState.stopped) {
27773
+ // NOTE: `this.sessionId` is intentionally NOT checked. `_stop()` runs
27774
+ // before `_clearSession()` (the stopSession API call sits between them),
27775
+ // so the clear().then() chain fires while sessionId is still set.
27776
+ // Bailing on sessionId here meant rrweb never restarted after manual
27777
+ // stop, leaving the buffer with no FullSnapshot and silently breaking
27778
+ // exception-triggered flushBuffer. `_recorder.restart(null, ...)` passes
27779
+ // null explicitly, so it's safe regardless of `this.sessionId`.
27780
+ 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) {
27777
27781
  return;
27778
27782
  }
27779
27783
  void this._recorder.restart(null, _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL);
@@ -27843,9 +27847,10 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27843
27847
  async stop(comment) {
27844
27848
  try {
27845
27849
  this._checkOperation('stop');
27850
+ const sid = this.sessionId;
27846
27851
  this._stop();
27847
27852
  if (this.continuousRecording) {
27848
- await this._apiService.stopContinuousDebugSession(this.sessionId);
27853
+ await this._apiService.stopContinuousDebugSession(sid);
27849
27854
  this.sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL;
27850
27855
  }
27851
27856
  else {
@@ -27853,10 +27858,9 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27853
27858
  sessionAttributes: { comment },
27854
27859
  stoppedAt: this._recorder.stoppedAt,
27855
27860
  };
27856
- const response = await this._apiService.stopSession(this.sessionId, request);
27861
+ const response = await this._apiService.stopSession(sid, request);
27857
27862
  _eventBus__WEBPACK_IMPORTED_MODULE_7__.recorderEventBus.emit(_config__WEBPACK_IMPORTED_MODULE_5__.SESSION_RESPONSE, response);
27858
27863
  }
27859
- this._clearSession();
27860
27864
  }
27861
27865
  catch (error) {
27862
27866
  this.error = error.message;
@@ -27892,15 +27896,15 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
27892
27896
  async cancel() {
27893
27897
  try {
27894
27898
  this._checkOperation('cancel');
27899
+ const sid = this.sessionId;
27895
27900
  this._stop();
27896
27901
  if (this.continuousRecording) {
27897
- await this._apiService.stopContinuousDebugSession(this.sessionId);
27902
+ await this._apiService.stopContinuousDebugSession(sid);
27898
27903
  this.sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.SessionType.MANUAL;
27899
27904
  }
27900
27905
  else {
27901
- await this._apiService.cancelSession(this.sessionId);
27906
+ await this._apiService.cancelSession(sid);
27902
27907
  }
27903
- this._clearSession();
27904
27908
  }
27905
27909
  catch (error) {
27906
27910
  this.error = error.message;
@@ -28214,6 +28218,13 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
28214
28218
  this._tracer.stop();
28215
28219
  this._recorder.stop();
28216
28220
  this._navigationRecorder.stop();
28221
+ // Clear session identity synchronously. The buffer-restart chain and the
28222
+ // error-span-appended listener both gate on `this.sessionId === null`;
28223
+ // deferring this to `_clearSession()` (after the network stopSession
28224
+ // call) left them seeing a stale id and silently no-oping. Callers that
28225
+ // need the id for the stop/cancel API must capture it before _stop().
28226
+ this.session = null;
28227
+ this.sessionId = null;
28217
28228
  // rrweb assigns new node IDs on each record() call, so the next buffer
28218
28229
  // segment must not carry events from the previous generation. Await the
28219
28230
  // clear so its IDB tx can't race past the fresh FullSnapshot.