Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/Pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ class Pool extends EventEmitter {

_applyDestroyTimeout(promise) {
const timeoutPromise = new this._Promise((resolve, reject) => {
setTimeout(() => {
const timer = setTimeout(() => {
reject(new Error("destroy timed out"));
}, this._config.destroyTimeoutMillis).unref();
}, this._config.destroyTimeoutMillis);

// Only relevant in Node.js and for process quitting
if (typeof timer.unref === 'function') {
timer.unref();
}
});
return this._Promise.race([timeoutPromise, promise]);
}
Expand Down Expand Up @@ -402,8 +407,12 @@ class Pool extends EventEmitter {
this._scheduledEviction = setTimeout(() => {
this._evict();
this._scheduleEvictorRun();
}, this._config.evictionRunIntervalMillis).unref();
}
}, this._config.evictionRunIntervalMillis);

// Only relevant in Node.js and for process quitting
if (typeof this._scheduledEviction.unref === 'function') {
this._scheduledEviction.unref();
}
}

_descheduleEvictorRun() {
Expand Down