Upgrade async package to 3.2.2 (#8447)

* Revert "Revert "Bump async to 3.2.2 (#7618)""

This reverts commit 75153a555211d654744c2e61e27fe21085826c22.

* [web] fix usage of async.queue.drain in script

* [clsi] fix usage of async.queue.drain

* [spelling] fix usage of async.queue.drain

* [redis-wrapper] fix usage of async.queue.drain

* [web] Test that LockManager queue is cleared

This protects against a regression found when upgrading the
async package. Here we test that the `queue.drain` callback
is really getting called, and the lock is being removed from
the LOCK_QUEUES map.

* [redis-wrapper] Upgrade async to 3.2.2

GitOrigin-RevId: df921e6d7f1d505bd467f22e58600ba1aff48869
This commit is contained in:
June Kelly
2022-06-22 08:03:35 +00:00
committed by Copybot
parent 1c78e211f6
commit a450a74351
23 changed files with 118 additions and 326 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
"@overleaf/logger": "^3.1.0",
"@overleaf/metrics": "^4.0.0",
"@overleaf/settings": "^3.0.0",
"async": "^3.2.0",
"async": "^3.2.2",
"body-parser": "^1.19.0",
"express": "4.17.1",
"mongodb": "^3.6.0"
+1 -1
View File
@@ -13,6 +13,6 @@ const queue = async.queue(
Settings.parallelSqlQueryLimit
)
queue.drain = () => logger.debug('all items have been processed')
queue.drain(() => logger.debug('all items have been processed'))
module.exports = { queue }
+1 -1
View File
@@ -20,7 +20,7 @@
"@overleaf/metrics": "^4.0.0",
"@overleaf/o-error": "^3.4.0",
"@overleaf/settings": "^3.0.0",
"async": "3.2.0",
"async": "3.2.2",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"diskusage": "^1.1.3",
+1 -1
View File
@@ -19,7 +19,7 @@
"@overleaf/logger": "^3.1.0",
"@overleaf/metrics": "^4.0.0",
"@overleaf/settings": "^3.0.0",
"async": "^2.6.3",
"async": "^3.2.2",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "^4.17.1",
+1 -1
View File
@@ -21,7 +21,7 @@
"@overleaf/o-error": "^3.4.0",
"@overleaf/object-persistor": "^1.0.1",
"@overleaf/settings": "^3.0.0",
"async": "^2.6.3",
"async": "^3.2.2",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"celebrate": "^13.0.4",
+1 -1
View File
@@ -21,7 +21,7 @@
"@overleaf/o-error": "^3.4.0",
"@overleaf/redis-wrapper": "^2.0.1",
"@overleaf/settings": "^3.0.0",
"async": "^2.5.0",
"async": "^3.2.2",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"diff-match-patch": "https://github.com/overleaf/diff-match-patch/archive/89805f9c671a77a263fc53461acd62aa7498f688.tar.gz",
+1 -1
View File
@@ -21,7 +21,7 @@
"@overleaf/logger": "^3.1.0",
"@overleaf/metrics": "^4.0.0",
"@overleaf/settings": "^3.0.0",
"async": "^2.6.3",
"async": "^3.2.2",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "4.17.1",
+1 -1
View File
@@ -22,7 +22,7 @@
"@overleaf/o-error": "^3.4.0",
"@overleaf/redis-wrapper": "^2.0.0",
"@overleaf/settings": "^3.0.0",
"async": "^0.9.0",
"async": "^3.2.2",
"base64id": "0.1.0",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
+1 -1
View File
@@ -26,7 +26,7 @@
"@overleaf/metrics": "^4.0.0",
"@overleaf/o-error": "^3.4.0",
"@overleaf/settings": "^3.0.0",
"async": "^2.6.3",
"async": "^3.2.2",
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "^4.17.1",
@@ -149,7 +149,7 @@ const q = async.queue(
3
)
q.drain = () => console.log('all items have been processed')
q.drain(() => console.log('all items have been processed'))
for (let i = 0; i <= 1000; i++) {
q.push({
@@ -591,11 +591,13 @@ module.exports = UpdatesManager = {
}
// repeatedly get updates and pass them through the summariser to get an final output with user info
return async.whilst(
() =>
cb =>
// console.log "checking iterator.done", iterator.done()
summarizedUpdates.length < options.min_count &&
!iterator.done(),
cb(
null,
summarizedUpdates.length < options.min_count &&
!iterator.done()
),
cb =>
iterator.next(function (err, partialUpdates) {
if (err != null) {
@@ -651,7 +653,7 @@ module.exports = UpdatesManager = {
const accumulatedUserIds = new Set()
async.whilst(
() => !iterator.done(),
cb => cb(null, !iterator.done()),
cb =>
iterator.next((err, updatesFromASinglePack) => {
+1 -1
View File
@@ -21,7 +21,7 @@
"@overleaf/o-error": "^3.4.0",
"@overleaf/redis-wrapper": "^2.0.0",
"@overleaf/settings": "^3.0.0",
"async": "^2.6.3",
"async": "^3.2.2",
"aws-sdk": "^2.643.0",
"body-parser": "^1.19.0",
"bson": "^1.1.5",
@@ -72,7 +72,7 @@ module.exports = ExportsHandler = {
// TODO: when we update async, signature will change from (cb, results) to (results, cb)
rootDoc: [
'project',
(cb, results) =>
(results, cb) =>
ProjectRootDocManager.ensureRootDocumentIsValid(
project_id,
function (error) {
@@ -785,7 +785,7 @@ const ProjectController = {
},
brandVariation: [
'project',
(cb, results) => {
(results, cb) => {
if (
(results.project != null
? results.project.brandVariationId
@@ -95,7 +95,7 @@ module.exports = ProjectRootDocManager = {
let doc = null
return async.until(
() => doc != null || files.length === 0,
cb => cb(null, doc != null || files.length === 0),
function (cb) {
const file = files.shift()
return fs.readFile(
@@ -64,7 +64,7 @@ function buildUsersSubscriptionViewModel(user, callback) {
},
recurlySubscription: [
'personalSubscription',
(cb, { personalSubscription }) => {
({ personalSubscription }, cb) => {
if (
personalSubscription == null ||
personalSubscription.recurlySubscription_id == null ||
@@ -81,7 +81,7 @@ function buildUsersSubscriptionViewModel(user, callback) {
],
recurlyCoupons: [
'recurlySubscription',
(cb, { recurlySubscription }) => {
({ recurlySubscription }, cb) => {
if (!recurlySubscription) {
return cb(null, null)
}
@@ -91,7 +91,7 @@ function buildUsersSubscriptionViewModel(user, callback) {
],
plan: [
'personalSubscription',
(cb, { personalSubscription }) => {
({ personalSubscription }, cb) => {
if (personalSubscription == null) {
return cb()
}
+1 -1
View File
@@ -82,7 +82,7 @@
"angular": "~1.8.0",
"angular-sanitize": "~1.8.0",
"archiver": "^5.3.0",
"async": "0.6.2",
"async": "3.2.2",
"backbone": "^1.3.3",
"basic-auth": "^2.0.1",
"bcrypt": "^5.0.0",
@@ -43,12 +43,12 @@ function scanAndPurge(cb) {
})
stream.on('end', () => {
queue.drain = () => {
queue.drain(() => {
console.log(
`All sessions have been checked, ${totalDeletedSessions} deleted`
)
cb()
}
})
})
stream.on('error', err => {
@@ -89,7 +89,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.not.exist
return done()
})
})
@@ -144,8 +144,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -181,8 +180,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -227,8 +225,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(undefined)
expect(err).to.not.exist
return done()
})
})
@@ -283,8 +280,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -320,8 +316,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -363,8 +358,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -407,8 +401,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -474,8 +467,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -497,8 +489,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -524,8 +515,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -559,8 +549,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -598,7 +587,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call((err, sessions) => {
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -635,7 +624,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call((err, sessions) => {
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -713,8 +702,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(undefined)
expect(err).to.not.exist
return done()
})
})
@@ -736,8 +724,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(undefined)
expect(err).to.not.exist
return done()
})
})
@@ -762,8 +749,7 @@ describe('UserSessionsManager', function () {
it('should not produce an error', function (done) {
return this.call(err => {
expect(err).to.not.be.instanceof(Error)
expect(err).to.equal(null)
expect(err).to.not.exist
return done()
})
})
@@ -74,6 +74,10 @@ describe('LockManager - getting the lock', function () {
it('should return the callback', function () {
return this.callback.calledWith(null).should.equal(true)
})
it('should clear the lock queue', function () {
this.LockManager._lockQueuesSize().should.equal(0)
})
})
describe('when the lock is initially set', function () {
@@ -107,6 +111,10 @@ describe('LockManager - getting the lock', function () {
it('should return the callback', function () {
return this.callback.calledWith(null).should.equal(true)
})
it('should clear the lock queue', function () {
this.LockManager._lockQueuesSize().should.equal(0)
})
})
describe('when the lock times out', function () {
@@ -178,5 +186,9 @@ describe('LockManager - getting the lock', function () {
it('should process the requests in order', function () {
return this.results.should.deep.equal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
})
it('should clear the lock queue', function () {
this.LockManager._lockQueuesSize().should.equal(0)
})
})
})