fix: update collector options.time and options.idle in resetTimer (#11534)

* fix(Collector): update options.time and options.idle in resetTimer

* fix: apply suggestions from code review

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

---------

Co-authored-by: Almeida <github@almeidx.dev>
Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
Ali
2026-08-31 21:25:15 +00:00
committed by GitHub
co-authored by Qjuh Almeida
parent 5608023103
commit d634694c3f
@@ -272,14 +272,22 @@ class Collector extends AsyncEventEmitter {
* @param {CollectorResetTimerOptions} [options] Options for resetting
*/
resetTimer({ time, idle } = {}) {
if (time) {
this.options.time = time;
}
if (idle) {
this.options.idle = idle;
}
if (this._timeout) {
clearTimeout(this._timeout);
this._timeout = setTimeout(() => this.stop('time'), time ?? this.options.time).unref();
this._timeout = setTimeout(() => this.stop('time'), this.options.time).unref();
}
if (this._idletimeout) {
clearTimeout(this._idletimeout);
this._idletimeout = setTimeout(() => this.stop('idle'), idle ?? this.options.idle).unref();
this._idletimeout = setTimeout(() => this.stop('idle'), this.options.idle).unref();
}
}