diff --git a/install/package.json b/install/package.json index 93dc683c32..aa240e8864 100644 --- a/install/package.json +++ b/install/package.json @@ -31,7 +31,7 @@ "dependencies": { "ace-builds": "^1.2.9", "archiver": "^3.0.0", - "async": "2.6.2", + "async": "3.0.0", "autoprefixer": "^9.4.6", "bcryptjs": "2.4.3", "benchpressjs": "^1.2.5", diff --git a/src/analytics.js b/src/analytics.js index b9649f85cc..e6da10b44c 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -187,9 +187,9 @@ Analytics.getDailyStatsForSet = function (set, day, numDays, callback) { day.setDate(day.getDate() + 1); // set the date to tomorrow, because getHourlyStatsForSet steps *backwards* 24 hours to sum up the values day.setHours(0, 0, 0, 0); - async.whilst(function () { + async.whilst(function (next) { numDays -= 1; - return numDays + 1; + next(null, numDays + 1); }, function (next) { Analytics.getHourlyStatsForSet(set, day.getTime() - (1000 * 60 * 60 * 24 * numDays), 24, function (err, day) { if (err) { diff --git a/src/batch.js b/src/batch.js index 5841fcc19a..9f7e8720e4 100644 --- a/src/batch.js +++ b/src/batch.js @@ -45,8 +45,8 @@ exports.processSortedSet = function (setKey, process, options, callback) { var done = false; async.whilst( - function () { - return !done; + function (next) { + next(null, !done); }, function (next) { async.waterfall([ @@ -99,8 +99,8 @@ exports.processArray = function (array, process, options, callback) { var done = false; async.whilst( - function () { - return !done; + function (next) { + next(null, !done); }, function (next) { var currentBatch = array.slice(start, start + batch); diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 699db7ba4f..9ce66d7bd6 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -156,8 +156,8 @@ helpers.redirect = function (res, url) { helpers.buildCategoryBreadcrumbs = function (cid, callback) { var breadcrumbs = []; - async.whilst(function () { - return parseInt(cid, 10); + async.whilst(function (next) { + next(null, parseInt(cid, 10)); }, function (next) { categories.getCategoryFields(cid, ['name', 'slug', 'parentCid', 'disabled', 'isSection'], function (err, data) { if (err) { diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 21a1a6e61c..5401b7f121 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -502,8 +502,8 @@ module.exports = function (db, module) { .batchSize(options.batch); async.whilst( - function () { - return !done; + function (next) { + next(null, !done); }, function (next) { async.waterfall([ diff --git a/src/database/postgres/sorted.js b/src/database/postgres/sorted.js index 4b1dfa41c6..5d97d5428d 100644 --- a/src/database/postgres/sorted.js +++ b/src/database/postgres/sorted.js @@ -707,14 +707,19 @@ SELECT z."value", z."score" WHERE o."_key" = $1::TEXT ORDER BY z."score" ASC, z."value" ASC`, [setKey])); - async.doUntil(function (next) { + var isDone = false; + + async.whilst(function (next) { + next(null, !isDone); + }, function (next) { query.read(batchSize, function (err, rows) { if (err) { return next(err); } if (!rows.length) { - return next(null, true); + isDone = true; + return next(); } rows = rows.map(function (row) { @@ -735,8 +740,6 @@ SELECT z."value", z."score" } }); }); - }, function (stop) { - return stop; }, function (err) { done(); callback(err); diff --git a/src/messaging/index.js b/src/messaging/index.js index 53416f28e9..06b47c973c 100644 --- a/src/messaging/index.js +++ b/src/messaging/index.js @@ -362,8 +362,8 @@ Messaging.hasPrivateChat = function (uid, withUid, callback) { var index = 0; var roomId = 0; - async.whilst(function () { - return index < roomIds.length && !roomId; + async.whilst(function (next) { + next(null, index < roomIds.length && !roomId); }, function (next) { Messaging.getUserCountInRoom(roomIds[index], function (err, count) { if (err) { diff --git a/src/topics/posts.js b/src/topics/posts.js index 33dd80ef44..42efd64a4f 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -243,8 +243,8 @@ module.exports = function (Topics) { }, ], next); }, - function () { - return isDeleted && !done; + function (next) { + next(null, isDeleted && !done); }, function (err) { callback(err, parseInt(latestPid, 10)); diff --git a/src/topics/teaser.js b/src/topics/teaser.js index b66507e95c..16e8b7f36e 100644 --- a/src/topics/teaser.js +++ b/src/topics/teaser.js @@ -151,8 +151,8 @@ module.exports = function (Topics) { next(); }, ], next); - }, function () { - return isBlocked && prevPost && prevPost.pid && !checkedAllReplies; + }, function (next) { + next(null, isBlocked && prevPost && prevPost.pid && !checkedAllReplies); }, function (err) { callback(err, prevPost); }); diff --git a/src/topics/unread.js b/src/topics/unread.js index 02df4bd781..8259b7b24f 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -298,8 +298,8 @@ module.exports = function (Topics) { if (!params.blockedUids.length) { return setImmediate(callback, null, hasUnblockedUnread); } - async.whilst(function () { - return !done; + async.whilst(function (next) { + next(null, !done); }, function (_next) { async.waterfall([ function (next) { diff --git a/src/upgrades/1.0.0/chat_room_hashes.js b/src/upgrades/1.0.0/chat_room_hashes.js index 27257c7c16..9c1f9679b3 100644 --- a/src/upgrades/1.0.0/chat_room_hashes.js +++ b/src/upgrades/1.0.0/chat_room_hashes.js @@ -13,8 +13,8 @@ module.exports = { return callback(err); } var currentChatRoomId = 1; - async.whilst(function () { - return currentChatRoomId <= nextChatRoomId; + async.whilst(function (next) { + next(null, currentChatRoomId <= nextChatRoomId); }, function (next) { db.getSortedSetRange('chat:room:' + currentChatRoomId + ':uids', 0, 0, function (err, uids) { if (err) { diff --git a/src/upgrades/1.0.0/chat_upgrade.js b/src/upgrades/1.0.0/chat_upgrade.js index 10bb024ae9..db7e5934cd 100644 --- a/src/upgrades/1.0.0/chat_upgrade.js +++ b/src/upgrades/1.0.0/chat_upgrade.js @@ -18,8 +18,8 @@ module.exports = { var roomId = globalData.nextChatRoomId || 1; var currentMid = 1; - async.whilst(function () { - return currentMid <= globalData.nextMid; + async.whilst(function (next) { + next(null, currentMid <= globalData.nextMid); }, function (next) { db.getObject('message:' + currentMid, function (err, message) { var msgTime; diff --git a/src/upgrades/1.12.1/clear_username_email_history.js b/src/upgrades/1.12.1/clear_username_email_history.js index 37ff83a179..9c2d9a5feb 100644 --- a/src/upgrades/1.12.1/clear_username_email_history.js +++ b/src/upgrades/1.12.1/clear_username_email_history.js @@ -15,8 +15,8 @@ module.exports = { return callback(err); } progress.total = nextUid; - async.whilst(function () { - return currentUid < nextUid; + async.whilst(function (next) { + next(null, currentUid < nextUid); }, function (next) { progress.incr(); diff --git a/src/upgrades/1.7.3/key_value_schema_change.js b/src/upgrades/1.7.3/key_value_schema_change.js index 882f8ff200..cee08a8a9f 100644 --- a/src/upgrades/1.7.3/key_value_schema_change.js +++ b/src/upgrades/1.7.3/key_value_schema_change.js @@ -39,8 +39,8 @@ module.exports = { var done = false; async.whilst( - function () { - return !done; + function (next) { + next(null, !done); }, function (next) { async.waterfall([ diff --git a/src/widgets/admin.js b/src/widgets/admin.js index 32d187cdbe..82c0681900 100644 --- a/src/widgets/admin.js +++ b/src/widgets/admin.js @@ -20,7 +20,7 @@ admin.get = function (callback) { return callback(err); } - callback(false, { + callback(null, { templates: buildTemplatesFromAreas(widgetData.areas), areas: widgetData.areas, availableWidgets: widgetData.availableWidgets,