@fpjs-incubator/broyster
Version:
31 lines (30 loc) • 1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaptureTimeout = void 0;
class CaptureTimeout {
constructor(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_launcher, _config, _log) {
this._launcher = _launcher;
this._config = _config;
this._log = _log;
this._pendingTimeoutId = null;
}
onStart() {
setTimeout(() => {
this._pendingTimeoutId = null;
if (this._launcher.state !== this._launcher.STATE_BEING_CAPTURED) {
return;
}
this._log.warn(`${this._launcher.name} has not captured in ${this._config.captureTimeout} ms, killing.`);
this._launcher.error = 'timeout';
this._launcher.kill();
}, this._config.captureTimeout);
}
onDone() {
if (this._pendingTimeoutId) {
clearTimeout(this._pendingTimeoutId);
}
}
}
exports.CaptureTimeout = CaptureTimeout;
;