Skip to content

Commit eb46080

Browse files
committed
avoid idle timeout loop
1 parent 19b5e6b commit eb46080

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/recorder/session-recording.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
187187
this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
188188
this.idleExpires = new Date().getTime() + idleTimeoutMs;
189189
}.bind(this);
190+
resetIdleTimeout();
190191

191192
var blockSelector = this.getConfig('record_block_selector');
192193
if (blockSelector === '' || blockSelector === null) {
@@ -196,7 +197,7 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
196197
try {
197198
this._stopRecording = this._rrwebRecord({
198199
'emit': function (ev) {
199-
if (this.idleExpires < ev.timestamp) {
200+
if (this.idleExpires && this.idleExpires < ev.timestamp) {
200201
this._onIdleTimeout();
201202
return;
202203
}
@@ -236,8 +237,6 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
236237
return;
237238
}
238239

239-
resetIdleTimeout();
240-
241240
var maxTimeoutMs = this.maxExpires - new Date().getTime();
242241
this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
243242
};

tests/unit/session-recording.js

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ describe(`SessionRecording`, function() {
101101

102102
expect(flushSpy.calledOnce).to.be.false;
103103
expect(sessionRecording.batcher.stopped).to.be.true;
104-
expect(sessionRecording.idleTimeoutId).to.be.null;
105104
expect(sessionRecording.maxTimeoutId).to.be.null;
106105
});
107106

0 commit comments

Comments
 (0)