From 4b6031d6c4f0def75d29ec1f629326f305b87188 Mon Sep 17 00:00:00 2001 From: lake-toya <35307071+lake-toya@users.noreply.github.com> Date: Sat, 21 Mar 2020 11:07:30 +0100 Subject: [PATCH] fix: prevent exceeding the maximum stack call size when emptying large queues (#1660) --- lib/queue.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/queue.js b/lib/queue.js index d9a8d3a5d..ae888f216 100755 --- a/lib/queue.js +++ b/lib/queue.js @@ -750,7 +750,9 @@ Queue.prototype.empty = function() { if (jobKeys.length) { multi = this.multi(); - multi.del.apply(multi, jobKeys); + for (let i = 0; i < jobKeys.length; i += 10000) { + multi.del.apply(multi, jobKeys.slice(i, i + 10000)); + } return multi.exec(); } });