diff --git a/services/chat/.eslintrc b/services/chat/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/chat/.eslintrc +++ b/services/chat/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/chat/app/js/Features/Messages/MessageManager.js b/services/chat/app/js/Features/Messages/MessageManager.js index 7b73674af2..14cf51430c 100644 --- a/services/chat/app/js/Features/Messages/MessageManager.js +++ b/services/chat/app/js/Features/Messages/MessageManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, max-len, no-unused-vars, */ @@ -20,7 +19,7 @@ const logger = require('logger-sharelatex') module.exports = MessageManager = { createMessage(room_id, user_id, content, timestamp, callback) { if (callback == null) { - callback = function (error, message) {} + callback = function () {} } let newMessageOpts = { content, @@ -40,7 +39,7 @@ module.exports = MessageManager = { getMessages(room_id, limit, before, callback) { if (callback == null) { - callback = function (error, messages) {} + callback = function () {} } let query = { room_id } if (before != null) { @@ -56,7 +55,7 @@ module.exports = MessageManager = { findAllMessagesInRooms(room_ids, callback) { if (callback == null) { - callback = function (error, messages) {} + callback = function () {} } db.messages .find({ @@ -67,7 +66,7 @@ module.exports = MessageManager = { deleteAllMessagesInRoom(room_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } db.messages.deleteMany( { @@ -79,7 +78,7 @@ module.exports = MessageManager = { updateMessage(room_id, message_id, content, timestamp, callback) { if (callback == null) { - callback = function (error, message) {} + callback = function () {} } const query = this._ensureIdsAreObjectIds({ _id: message_id, @@ -99,7 +98,7 @@ module.exports = MessageManager = { deleteMessage(room_id, message_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const query = this._ensureIdsAreObjectIds({ _id: message_id, diff --git a/services/chat/app/js/Features/Threads/ThreadManager.js b/services/chat/app/js/Features/Threads/ThreadManager.js index 885ecb84c5..4a62f4836d 100644 --- a/services/chat/app/js/Features/Threads/ThreadManager.js +++ b/services/chat/app/js/Features/Threads/ThreadManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, max-len, */ // TODO: This file was created by bulk-decaffeinate. @@ -22,7 +21,7 @@ module.exports = ThreadManager = { findOrCreateThread(project_id, thread_id, callback) { let query, update if (callback == null) { - callback = function (error, thread) {} + callback = function () {} } project_id = ObjectId(project_id.toString()) if (thread_id !== ThreadManager.GLOBAL_THREAD) { @@ -63,7 +62,7 @@ module.exports = ThreadManager = { findAllThreadRooms(project_id, callback) { if (callback == null) { - callback = function (error, rooms) {} + callback = function () {} } db.rooms .find( @@ -81,7 +80,7 @@ module.exports = ThreadManager = { resolveThread(project_id, thread_id, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } db.rooms.updateOne( { @@ -102,7 +101,7 @@ module.exports = ThreadManager = { reopenThread(project_id, thread_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } db.rooms.updateOne( { @@ -120,7 +119,7 @@ module.exports = ThreadManager = { deleteThread(project_id, thread_id, callback) { if (callback == null) { - callback = function (error, room_id) {} + callback = function () {} } return this.findOrCreateThread( project_id, diff --git a/services/chat/test/acceptance/js/GettingMessagesTests.js b/services/chat/test/acceptance/js/GettingMessagesTests.js index 1640852ca8..b1e6cf9540 100644 --- a/services/chat/test/acceptance/js/GettingMessagesTests.js +++ b/services/chat/test/acceptance/js/GettingMessagesTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, max-len, no-unused-vars, */ @@ -55,6 +54,7 @@ describe('Getting messages', function () { return ChatClient.getGlobalMessages( this.project_id, (error, response, messages) => { + if (error) return done(error) expect(messages.length).to.equal(2) messages.reverse() expect(messages[0].content).to.equal(this.content1) @@ -115,6 +115,7 @@ describe('Getting messages', function () { return ChatClient.getThreads( this.project_id, (error, response, threads) => { + if (error) return done(error) expect(Object.keys(threads).length).to.equal(2) const thread1 = threads[this.thread_id1] expect(thread1.messages.length).to.equal(2) diff --git a/services/chat/test/acceptance/js/SendingAMessageTests.js b/services/chat/test/acceptance/js/SendingAMessageTests.js index 2496d24acb..65c44b026e 100644 --- a/services/chat/test/acceptance/js/SendingAMessageTests.js +++ b/services/chat/test/acceptance/js/SendingAMessageTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, max-len, no-return-assign, node/no-deprecated-api, @@ -121,6 +120,7 @@ describe('Sending a message', function () { 'malformed-user', 'content', (error, response, body) => { + if (error) return done(error) expect(response.statusCode).to.equal(400) expect(body).to.equal('Invalid user_id') return done() @@ -137,6 +137,7 @@ describe('Sending a message', function () { this.user_id, 'content', (error, response, body) => { + if (error) return done(error) expect(response.statusCode).to.equal(400) expect(body).to.equal('Invalid project_id') return done() @@ -153,6 +154,7 @@ describe('Sending a message', function () { this.user_id, 'content', (error, response, body) => { + if (error) return done(error) expect(response.statusCode).to.equal(400) expect(body).to.equal('Invalid thread_id') return done() @@ -169,6 +171,7 @@ describe('Sending a message', function () { this.user_id, null, (error, response, body) => { + if (error) return done(error) expect(response.statusCode).to.equal(400) expect(body).to.equal('No content provided') return done() @@ -186,6 +189,7 @@ describe('Sending a message', function () { this.user_id, content, (error, response, body) => { + if (error) return done(error) expect(response.statusCode).to.equal(400) expect(body).to.equal('Content too long (> 10240 bytes)') return done() diff --git a/services/chat/test/acceptance/js/helpers/ChatApp.js b/services/chat/test/acceptance/js/helpers/ChatApp.js index 9b4f8f8a0e..4081b4cf6f 100644 --- a/services/chat/test/acceptance/js/helpers/ChatApp.js +++ b/services/chat/test/acceptance/js/helpers/ChatApp.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -20,7 +17,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/clsi/.eslintrc b/services/clsi/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/clsi/.eslintrc +++ b/services/clsi/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/clsi/app/js/CompileController.js b/services/clsi/app/js/CompileController.js index 488d818157..8b480a7fe2 100644 --- a/services/clsi/app/js/CompileController.js +++ b/services/clsi/app/js/CompileController.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -30,7 +29,7 @@ function isImageNameAllowed(imageName) { module.exports = CompileController = { compile(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const timer = new Metrics.Timer('compile-request') return RequestParser.parse(req.body, function (error, request) { @@ -152,7 +151,7 @@ module.exports = CompileController = { clearCache(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } return ProjectPersistenceManager.clearProject( req.params.project_id, @@ -168,7 +167,7 @@ module.exports = CompileController = { syncFromCode(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { file } = req.query const line = parseInt(req.query.line, 10) @@ -201,7 +200,7 @@ module.exports = CompileController = { syncFromPdf(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const page = parseInt(req.query.page, 10) const h = parseFloat(req.query.h) @@ -233,7 +232,7 @@ module.exports = CompileController = { wordcount(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const file = req.query.file || 'main.tex' const { project_id } = req.params @@ -262,7 +261,7 @@ module.exports = CompileController = { status(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } return res.send('OK') }, diff --git a/services/clsi/app/js/DockerLockManager.js b/services/clsi/app/js/DockerLockManager.js index d785ee46cb..76208e3ef1 100644 --- a/services/clsi/app/js/DockerLockManager.js +++ b/services/clsi/app/js/DockerLockManager.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -23,7 +20,7 @@ module.exports = LockManager = { tryLock(key, callback) { let lockValue if (callback == null) { - callback = function (err, gotLock) {} + callback = function () {} } const existingLock = LockState[key] if (existingLock != null) { @@ -46,7 +43,7 @@ module.exports = LockManager = { getLock(key, callback) { let attempt if (callback == null) { - callback = function (error, lockValue) {} + callback = function () {} } const startTime = Date.now() return (attempt = () => @@ -68,7 +65,7 @@ module.exports = LockManager = { releaseLock(key, lockValue, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const existingLock = LockState[key] if (existingLock === lockValue) { @@ -93,7 +90,7 @@ module.exports = LockManager = { runWithLock(key, runner, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return LockManager.getLock(key, function (error, lockValue) { if (error != null) { diff --git a/services/clsi/app/js/DraftModeManager.js b/services/clsi/app/js/DraftModeManager.js index 9be65e7afd..f5bc679155 100644 --- a/services/clsi/app/js/DraftModeManager.js +++ b/services/clsi/app/js/DraftModeManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-useless-escape, */ // TODO: This file was created by bulk-decaffeinate. @@ -18,7 +17,7 @@ const logger = require('logger-sharelatex') module.exports = DraftModeManager = { injectDraftMode(filename, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return fs.readFile(filename, 'utf8', function (error, content) { if (error != null) { diff --git a/services/clsi/app/js/LatexRunner.js b/services/clsi/app/js/LatexRunner.js index 7c288cef08..760ffe2ce6 100644 --- a/services/clsi/app/js/LatexRunner.js +++ b/services/clsi/app/js/LatexRunner.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -33,7 +32,7 @@ module.exports = LatexRunner = { runLatex(project_id, options, callback) { let command if (callback == null) { - callback = function (error) {} + callback = function () {} } let { directory, @@ -167,7 +166,7 @@ module.exports = LatexRunner = { killLatex(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const id = `${project_id}` logger.log({ id }, 'killing running compile') diff --git a/services/clsi/app/js/LocalCommandRunner.js b/services/clsi/app/js/LocalCommandRunner.js index 1e4236a579..84208d1987 100644 --- a/services/clsi/app/js/LocalCommandRunner.js +++ b/services/clsi/app/js/LocalCommandRunner.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -32,11 +31,7 @@ module.exports = CommandRunner = { callback ) { let key, value - if (callback == null) { - callback = function (error) {} - } else { - callback = _.once(callback) - } + callback = _.once(callback) command = Array.from(command).map(arg => arg.toString().replace('$COMPILE_DIR', directory) ) @@ -91,7 +86,7 @@ module.exports = CommandRunner = { kill(pid, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } try { process.kill(-pid) // kill all processes in group diff --git a/services/clsi/app/js/LockManager.js b/services/clsi/app/js/LockManager.js index 2dc09b336c..e4061380ce 100644 --- a/services/clsi/app/js/LockManager.js +++ b/services/clsi/app/js/LockManager.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -25,7 +24,7 @@ module.exports = LockManager = { runWithLock(path, runner, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const lockOpts = { wait: this.MAX_LOCK_WAIT_TIME, diff --git a/services/clsi/app/js/OutputCacheManager.js b/services/clsi/app/js/OutputCacheManager.js index c9d346fa44..ca5f36b813 100644 --- a/services/clsi/app/js/OutputCacheManager.js +++ b/services/clsi/app/js/OutputCacheManager.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -52,7 +49,7 @@ module.exports = OutputCacheManager = { generateBuildId(callback) { // generate a secure build id from Date.now() and 8 random bytes in hex if (callback == null) { - callback = function (error, buildId) {} + callback = function () {} } return crypto.randomBytes(8, function (err, buf) { if (err != null) { @@ -72,7 +69,7 @@ module.exports = OutputCacheManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return OutputCacheManager.generateBuildId(function (err, buildId) { if (err != null) { @@ -122,7 +119,7 @@ module.exports = OutputCacheManager = { // make a compileDir/CACHE_SUBDIR/build_id directory and // copy all the output files into it if (callback == null) { - callback = function (error) {} + callback = function () {} } const cacheRoot = Path.join(outputDir, OutputCacheManager.CACHE_SUBDIR) // Put the files into a new cache subdirectory @@ -339,6 +336,7 @@ module.exports = OutputCacheManager = { return callback(err) } fs.readdir(contentRoot, function (err, results) { + if (err) return callback(err) const dirs = results.sort() const contentId = dirs.find(dir => OutputCacheManager.BUILD_REGEX.test(dir) @@ -366,7 +364,7 @@ module.exports = OutputCacheManager = { archiveLogs(outputFiles, compileDir, outputDir, buildId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const archiveDir = Path.join( outputDir, @@ -417,7 +415,7 @@ module.exports = OutputCacheManager = { expireOutputFiles(cacheRoot, options, callback) { // look in compileDir for build dirs and delete if > N or age of mod time > T if (callback == null) { - callback = function (error) {} + callback = function () {} } return fs.readdir(cacheRoot, function (err, results) { if (err != null) { @@ -481,7 +479,7 @@ module.exports = OutputCacheManager = { _checkFileIsSafe(src, callback) { // check if we have a valid file to copy into the cache if (callback == null) { - callback = function (error, isSafe) {} + callback = function () {} } return fs.stat(src, function (err, stats) { if ((err != null ? err.code : undefined) === 'ENOENT') { @@ -537,7 +535,7 @@ module.exports = OutputCacheManager = { _checkIfShouldCopy(src, callback) { if (callback == null) { - callback = function (err, shouldCopy) {} + callback = function () {} } return callback(null, !Path.basename(src).match(/^strace/)) }, @@ -545,7 +543,7 @@ module.exports = OutputCacheManager = { _checkIfShouldArchive(src, callback) { let needle if (callback == null) { - callback = function (err, shouldCopy) {} + callback = function () {} } if (Path.basename(src).match(/^strace/)) { return callback(null, true) diff --git a/services/clsi/app/js/OutputFileOptimiser.js b/services/clsi/app/js/OutputFileOptimiser.js index 979697b07c..b7722166d9 100644 --- a/services/clsi/app/js/OutputFileOptimiser.js +++ b/services/clsi/app/js/OutputFileOptimiser.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, no-undef, no-unused-vars, @@ -26,7 +25,7 @@ module.exports = OutputFileOptimiser = { // check output file (src) and see if we can optimise it, storing // the result in the build directory (dst) if (callback == null) { - callback = function (error) {} + callback = function () {} } if (src.match(/\/output\.pdf$/)) { return OutputFileOptimiser.checkIfPDFIsOptimised( @@ -68,7 +67,7 @@ module.exports = OutputFileOptimiser = { optimisePDF(src, dst, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const tmpOutput = dst + '.opt' const args = ['--linearize', '--newline-before-endstream', src, tmpOutput] diff --git a/services/clsi/app/js/ProjectPersistenceManager.js b/services/clsi/app/js/ProjectPersistenceManager.js index d79688fd1f..ddb9c1daa7 100644 --- a/services/clsi/app/js/ProjectPersistenceManager.js +++ b/services/clsi/app/js/ProjectPersistenceManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -94,7 +93,11 @@ module.exports = ProjectPersistenceManager = { () => { setInterval(() => { ProjectPersistenceManager.refreshExpiryTimeout(() => { - ProjectPersistenceManager.clearExpiredProjects() + ProjectPersistenceManager.clearExpiredProjects(err => { + if (err) { + logger.error({ err }, 'clearing expired projects failed') + } + }) }) }, 10 * 60 * 1000) } @@ -109,7 +112,7 @@ module.exports = ProjectPersistenceManager = { clearExpiredProjects(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ProjectPersistenceManager._findExpiredProjectIds(function ( error, @@ -139,7 +142,7 @@ module.exports = ProjectPersistenceManager = { } return CompileManager.clearExpiredProjects( ProjectPersistenceManager.EXPIRY_TIMEOUT, - error => callback() + error => callback(error) ) }) }) @@ -147,7 +150,7 @@ module.exports = ProjectPersistenceManager = { clearProject(project_id, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } logger.log({ project_id, user_id }, 'clearing project for user') return CompileManager.clearProject(project_id, user_id, function (error) { @@ -168,7 +171,7 @@ module.exports = ProjectPersistenceManager = { clearProjectFromCache(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } logger.log({ project_id }, 'clearing project from cache') return UrlCache.clearProject(project_id, function (error) { diff --git a/services/clsi/app/js/RequestParser.js b/services/clsi/app/js/RequestParser.js index 04502e422c..e916f2a20a 100644 --- a/services/clsi/app/js/RequestParser.js +++ b/services/clsi/app/js/RequestParser.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-control-regex, no-throw-literal, no-unused-vars, @@ -26,7 +25,7 @@ module.exports = RequestParser = { parse(body, callback) { let resource if (callback == null) { - callback = function (error, data) {} + callback = function () {} } const response = {} diff --git a/services/clsi/app/js/ResourceWriter.js b/services/clsi/app/js/ResourceWriter.js index d79db021cc..69b5021189 100644 --- a/services/clsi/app/js/ResourceWriter.js +++ b/services/clsi/app/js/ResourceWriter.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, no-useless-escape, @@ -30,7 +29,7 @@ const parallelFileDownloads = settings.parallelFileDownloads || 1 module.exports = ResourceWriter = { syncResourcesToDisk(request, basePath, callback) { if (callback == null) { - callback = function (error, resourceList) {} + callback = function () {} } if (request.syncType === 'incremental') { logger.log( @@ -111,7 +110,7 @@ module.exports = ResourceWriter = { saveIncrementalResourcesToDisk(project_id, resources, basePath, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return this._createDirectory(basePath, error => { if (error != null) { @@ -129,7 +128,7 @@ module.exports = ResourceWriter = { saveAllResourcesToDisk(project_id, resources, basePath, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return this._createDirectory(basePath, error => { if (error != null) { @@ -157,7 +156,7 @@ module.exports = ResourceWriter = { _createDirectory(basePath, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return fs.mkdir(basePath, function (err) { if (err != null) { @@ -175,7 +174,7 @@ module.exports = ResourceWriter = { _removeExtraneousFiles(resources, basePath, _callback) { if (_callback == null) { - _callback = function (error, outputFiles, allFiles) {} + _callback = function () {} } const timer = new Metrics.Timer('unlink-output-files') const callback = function (error, ...result) { @@ -267,7 +266,7 @@ module.exports = ResourceWriter = { _deleteFileIfNotDirectory(path, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return fs.stat(path, function (error, stat) { if (error != null && error.code === 'ENOENT') { @@ -298,7 +297,7 @@ module.exports = ResourceWriter = { _writeResourceToDisk(project_id, resource, basePath, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ResourceWriter.checkPath( basePath, diff --git a/services/clsi/app/js/SafeReader.js b/services/clsi/app/js/SafeReader.js index 760a7725b9..15c4498559 100644 --- a/services/clsi/app/js/SafeReader.js +++ b/services/clsi/app/js/SafeReader.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, node/no-deprecated-api, */ @@ -22,7 +21,7 @@ module.exports = SafeReader = { readFile(file, size, encoding, callback) { if (callback == null) { - callback = function (error, result) {} + callback = function () {} } return fs.open(file, 'r', function (err, fd) { if (err != null && err.code === 'ENOENT') { diff --git a/services/clsi/app/js/TikzManager.js b/services/clsi/app/js/TikzManager.js index ac62ddac5a..090302e8b4 100644 --- a/services/clsi/app/js/TikzManager.js +++ b/services/clsi/app/js/TikzManager.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -26,7 +25,7 @@ module.exports = TikzManager = { checkMainFile(compileDir, mainFile, resources, callback) { // if there's already an output.tex file, we don't want to touch it if (callback == null) { - callback = function (error, needsMainFile) {} + callback = function () {} } for (const resource of Array.from(resources)) { if (resource.path === 'output.tex') { @@ -70,7 +69,7 @@ module.exports = TikzManager = { injectOutputFile(compileDir, mainFile, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ResourceWriter.checkPath( compileDir, diff --git a/services/clsi/app/js/UrlCache.js b/services/clsi/app/js/UrlCache.js index c1776477df..bc7d4a99b2 100644 --- a/services/clsi/app/js/UrlCache.js +++ b/services/clsi/app/js/UrlCache.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. diff --git a/services/clsi/app/js/UrlFetcher.js b/services/clsi/app/js/UrlFetcher.js index 3a13ad7a57..360d747a22 100644 --- a/services/clsi/app/js/UrlFetcher.js +++ b/services/clsi/app/js/UrlFetcher.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, no-unused-vars, node/no-deprecated-api, @@ -33,7 +32,7 @@ module.exports = UrlFetcher = { pipeUrlToFile(url, filePath, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const callbackOnce = function (error) { if (timeoutHandler != null) { diff --git a/services/clsi/test/acceptance/js/ExampleDocumentTests.js b/services/clsi/test/acceptance/js/ExampleDocumentTests.js index 5b0d518a65..efe0f63c44 100644 --- a/services/clsi/test/acceptance/js/ExampleDocumentTests.js +++ b/services/clsi/test/acceptance/js/ExampleDocumentTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-path-concat, no-return-assign, no-unused-vars, @@ -42,7 +41,7 @@ const MOCHA_LATEX_TIMEOUT = 60 * 1000 const convertToPng = function (pdfPath, pngPath, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const command = `convert ${fixturePath(pdfPath)} ${fixturePath(pngPath)}` console.log('COMMAND') @@ -56,7 +55,7 @@ const convertToPng = function (pdfPath, pngPath, callback) { const compare = function (originalPath, generatedPath, callback) { if (callback == null) { - callback = function (error, same) {} + callback = function () {} } const diff_file = `${fixturePath(generatedPath)}-diff.png` const proc = ChildProcess.exec( @@ -84,7 +83,7 @@ const compare = function (originalPath, generatedPath, callback) { const checkPdfInfo = function (pdfPath, callback) { if (callback == null) { - callback = function (error, output) {} + callback = function () {} } const proc = ChildProcess.exec(`pdfinfo ${fixturePath(pdfPath)}`) let stdout = '' @@ -101,7 +100,7 @@ const checkPdfInfo = function (pdfPath, callback) { const compareMultiplePages = function (project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } function compareNext(page_no, callback) { const path = `tmp/${project_id}-source-${page_no}.png` @@ -128,7 +127,7 @@ const compareMultiplePages = function (project_id, callback) { const comparePdf = function (project_id, example_dir, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } console.log('CONVERT') console.log(`tmp/${project_id}.pdf`, `tmp/${project_id}-generated.png`) @@ -184,7 +183,7 @@ const downloadAndComparePdf = function ( callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const writeStream = fs.createWriteStream(fixturePath(`tmp/${project_id}.pdf`)) request.get(url).pipe(writeStream) diff --git a/services/clsi/test/acceptance/js/SimpleLatexFileTests.js b/services/clsi/test/acceptance/js/SimpleLatexFileTests.js index b2152f39ed..e66a7dd960 100644 --- a/services/clsi/test/acceptance/js/SimpleLatexFileTests.js +++ b/services/clsi/test/acceptance/js/SimpleLatexFileTests.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -55,6 +52,7 @@ Hello world it('should provide the pdf for download', function (done) { const pdf = Client.getOutputFile(this.body, 'pdf') return request.get(pdf.url, (error, res, body) => { + if (error) return done(error) res.statusCode.should.equal(200) return done() }) @@ -63,6 +61,7 @@ Hello world return it('should provide the log for download', function (done) { const log = Client.getOutputFile(this.body, 'pdf') return request.get(log.url, (error, res, body) => { + if (error) return done(error) res.statusCode.should.equal(200) return done() }) diff --git a/services/clsi/test/acceptance/js/helpers/Client.js b/services/clsi/test/acceptance/js/helpers/Client.js index d68d9a34a0..0bc8b46210 100644 --- a/services/clsi/test/acceptance/js/helpers/Client.js +++ b/services/clsi/test/acceptance/js/helpers/Client.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -28,7 +27,7 @@ module.exports = Client = { compile(project_id, data, callback) { if (callback == null) { - callback = function (error, res, body) {} + callback = function () {} } if (data) { // Enable pdf caching unless disabled explicitly. @@ -47,7 +46,7 @@ module.exports = Client = { clearCache(project_id, callback) { if (callback == null) { - callback = function (error, res, body) {} + callback = function () {} } return request.del(`${this.host}/project/${project_id}`, callback) }, @@ -78,7 +77,7 @@ module.exports = Client = { syncFromCodeWithImage(project_id, file, line, column, imageName, callback) { if (callback == null) { - callback = function (error, pdfPositions) {} + callback = function () {} } return request.get( { @@ -109,7 +108,7 @@ module.exports = Client = { syncFromPdfWithImage(project_id, page, h, v, imageName, callback) { if (callback == null) { - callback = function (error, pdfPositions) {} + callback = function () {} } return request.get( { @@ -136,7 +135,7 @@ module.exports = Client = { compileDirectory(project_id, baseDirectory, directory, serverPort, callback) { if (callback == null) { - callback = function (error, res, body) {} + callback = function () {} } const resources = [] let entities = fs.readdirSync(`${baseDirectory}/${directory}`) @@ -213,7 +212,7 @@ module.exports = Client = { wordcountWithImage(project_id, file, image, callback) { if (callback == null) { - callback = function (error, pdfPositions) {} + callback = function () {} } return request.get( { diff --git a/services/clsi/test/acceptance/js/helpers/ClsiApp.js b/services/clsi/test/acceptance/js/helpers/ClsiApp.js index 8dc946ff04..370f198b87 100644 --- a/services/clsi/test/acceptance/js/helpers/ClsiApp.js +++ b/services/clsi/test/acceptance/js/helpers/ClsiApp.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -23,7 +20,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/clsi/test/unit/js/DockerRunnerTests.js b/services/clsi/test/unit/js/DockerRunnerTests.js index dee351ec2f..caa5d87529 100644 --- a/services/clsi/test/unit/js/DockerRunnerTests.js +++ b/services/clsi/test/unit/js/DockerRunnerTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -195,7 +194,7 @@ describe('DockerRunner', function () { callback ) => { if (callback == null) { - callback = function (error, output) {} + callback = function () {} } if (firstTime) { firstTime = false @@ -615,6 +614,7 @@ describe('DockerRunner', function () { return this.DockerRunner.startContainer( this.options, this.volumes, + () => {}, this.callback ) }) @@ -676,7 +676,7 @@ describe('DockerRunner', function () { beforeEach(function (done) { this.container.wait = function (callback) { if (callback == null) { - callback = function (error, exitCode) {} + callback = function () {} } return setTimeout(() => callback(null, { StatusCode: 42 }), 100) } @@ -779,6 +779,7 @@ describe('DockerRunner', function () { this.containerId, false, err => { + if (err) return done(err) this.Docker.prototype.getContainer.callCount.should.equal(1) this.Docker.prototype.getContainer .calledWith(this.containerId) @@ -793,6 +794,7 @@ describe('DockerRunner', function () { this.containerId, true, err => { + if (err) return done(err) this.fakeContainer.remove.callCount.should.equal(1) this.fakeContainer.remove .calledWith({ force: true, v: true }) @@ -807,6 +809,7 @@ describe('DockerRunner', function () { this.containerId, false, err => { + if (err) return done(err) this.fakeContainer.remove.callCount.should.equal(1) this.fakeContainer.remove .calledWith({ force: false, v: true }) @@ -888,6 +891,7 @@ describe('DockerRunner', function () { it('should get the container', function (done) { return this.DockerRunner.kill(this.containerId, err => { + if (err) return done(err) this.Docker.prototype.getContainer.callCount.should.equal(1) this.Docker.prototype.getContainer .calledWith(this.containerId) @@ -898,6 +902,7 @@ describe('DockerRunner', function () { it('should try to force-destroy the container', function (done) { return this.DockerRunner.kill(this.containerId, err => { + if (err) return done(err) this.fakeContainer.kill.callCount.should.equal(1) return done() }) diff --git a/services/clsi/test/unit/js/OutputFileFinderTests.js b/services/clsi/test/unit/js/OutputFileFinderTests.js index 9d1eb4388c..848e2c2e8b 100644 --- a/services/clsi/test/unit/js/OutputFileFinderTests.js +++ b/services/clsi/test/unit/js/OutputFileFinderTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -36,7 +35,7 @@ describe('OutputFileFinder', function () { }) describe('findOutputFiles', function () { - beforeEach(function () { + beforeEach(function (done) { this.resource_path = 'resource/path.tex' this.output_paths = ['output.pdf', 'extra/file.tex'] this.all_paths = this.output_paths.concat([this.resource_path]) @@ -48,7 +47,9 @@ describe('OutputFileFinder', function () { this.resources, this.directory, (error, outputFiles) => { + if (error) return done(error) this.outputFiles = outputFiles + done() } ) }) diff --git a/services/clsi/test/unit/js/RequestParserTests.js b/services/clsi/test/unit/js/RequestParserTests.js index 48364990b4..8128b58e5a 100644 --- a/services/clsi/test/unit/js/RequestParserTests.js +++ b/services/clsi/test/unit/js/RequestParserTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -89,10 +88,12 @@ describe('RequestParser', function () { }) describe('without a compiler specified', function () { - beforeEach(function () { + beforeEach(function (done) { delete this.validRequest.compile.options.compiler return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) @@ -102,9 +103,11 @@ describe('RequestParser', function () { }) describe('with imageName set', function () { - beforeEach(function () { + beforeEach(function (done) { return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) @@ -156,10 +159,12 @@ describe('RequestParser', function () { }) describe('with flags set', function () { - beforeEach(function () { + beforeEach(function (done) { this.validRequest.compile.options.flags = ['-file-line-error'] return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) @@ -169,9 +174,11 @@ describe('RequestParser', function () { }) describe('with flags not specified', function () { - beforeEach(function () { + beforeEach(function (done) { return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) @@ -181,10 +188,12 @@ describe('RequestParser', function () { }) describe('without a timeout specified', function () { - beforeEach(function () { + beforeEach(function (done) { delete this.validRequest.compile.options.timeout return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) @@ -196,11 +205,13 @@ describe('RequestParser', function () { }) describe('with a timeout larger than the maximum', function () { - beforeEach(function () { + beforeEach(function (done) { this.validRequest.compile.options.timeout = this.RequestParser.MAX_TIMEOUT + 1 return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) @@ -212,9 +223,11 @@ describe('RequestParser', function () { }) describe('with a timeout', function () { - beforeEach(function () { + beforeEach(function (done) { return this.RequestParser.parse(this.validRequest, (error, data) => { + if (error) return done(error) this.data = data + done() }) }) diff --git a/services/contacts/.eslintrc b/services/contacts/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/contacts/.eslintrc +++ b/services/contacts/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/contacts/app/js/ContactManager.js b/services/contacts/app/js/ContactManager.js index 5025befa21..11caeed6d3 100644 --- a/services/contacts/app/js/ContactManager.js +++ b/services/contacts/app/js/ContactManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -18,7 +17,7 @@ const metrics = require('@overleaf/metrics') module.exports = ContactManager = { touchContact(user_id, contact_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } try { user_id = ObjectId(user_id.toString()) @@ -45,7 +44,7 @@ module.exports = ContactManager = { getContacts(user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } try { user_id = ObjectId(user_id.toString()) diff --git a/services/contacts/test/acceptance/js/ContactsApp.js b/services/contacts/test/acceptance/js/ContactsApp.js index d2d28085e4..b854524bdf 100644 --- a/services/contacts/test/acceptance/js/ContactsApp.js +++ b/services/contacts/test/acceptance/js/ContactsApp.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -21,7 +18,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/contacts/test/acceptance/js/GettingContactsTests.js b/services/contacts/test/acceptance/js/GettingContactsTests.js index 4ba97e8e41..566acb0579 100644 --- a/services/contacts/test/acceptance/js/GettingContactsTests.js +++ b/services/contacts/test/acceptance/js/GettingContactsTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-undef, no-unused-vars, */ @@ -36,6 +35,7 @@ describe('Getting Contacts', function () { json: true, }, (error, response, body) => { + if (error) return done(error) response.statusCode.should.equal(200) body.contact_ids.should.deep.equal([]) return done() @@ -84,6 +84,7 @@ describe('Getting Contacts', function () { json: true, }, (error, response, body) => { + if (error) return done(error) response.statusCode.should.equal(200) body.contact_ids.should.deep.equal([ this.contact_id_2, @@ -103,6 +104,7 @@ describe('Getting Contacts', function () { json: true, }, (error, response, body) => { + if (error) return done(error) response.statusCode.should.equal(200) body.contact_ids.should.deep.equal([ this.contact_id_2, diff --git a/services/docstore/.eslintrc b/services/docstore/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/docstore/.eslintrc +++ b/services/docstore/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/docstore/app/js/DocManager.js b/services/docstore/app/js/DocManager.js index 51e3beaf27..360840886c 100644 --- a/services/docstore/app/js/DocManager.js +++ b/services/docstore/app/js/DocManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-dupe-keys, no-undef, */ @@ -31,7 +30,7 @@ module.exports = DocManager = { filter = {} } if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } if (filter.inS3 !== true) { return callback('must include inS3 when getting doc') @@ -102,7 +101,7 @@ module.exports = DocManager = { getFullDoc(project_id, doc_id, callback) { if (callback == null) { - callback = function (err, doc) {} + callback = function () {} } return DocManager._getDoc( project_id, @@ -190,7 +189,7 @@ module.exports = DocManager = { getDocLines(project_id, doc_id, callback) { if (callback == null) { - callback = function (err, doc) {} + callback = function () {} } return DocManager._getDoc( project_id, @@ -211,7 +210,7 @@ module.exports = DocManager = { getAllNonDeletedDocs(project_id, filter, callback) { if (callback == null) { - callback = function (error, docs) {} + callback = function () {} } return DocArchive.unArchiveAllDocs(project_id, function (error) { if (error != null) { @@ -238,7 +237,7 @@ module.exports = DocManager = { updateDoc(project_id, doc_id, lines, version, ranges, callback) { if (callback == null) { - callback = function (error, modified, rev) {} + callback = function () {} } if (lines == null || version == null || ranges == null) { return callback(new Error('no lines, version or ranges provided')) diff --git a/services/docstore/app/js/HttpController.js b/services/docstore/app/js/HttpController.js index dea285873e..2276aaa19b 100644 --- a/services/docstore/app/js/HttpController.js +++ b/services/docstore/app/js/HttpController.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, valid-typeof, */ // TODO: This file was created by bulk-decaffeinate. @@ -22,7 +21,7 @@ const Settings = require('@overleaf/settings') module.exports = HttpController = { getDoc(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params const { doc_id } = req.params @@ -73,7 +72,7 @@ module.exports = HttpController = { getRawDoc(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params const { doc_id } = req.params @@ -93,7 +92,7 @@ module.exports = HttpController = { getAllDocs(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params logger.log({ project_id }, 'getting all docs') @@ -137,7 +136,7 @@ module.exports = HttpController = { getAllRanges(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params logger.log({ project_id }, 'getting all ranges') @@ -158,7 +157,7 @@ module.exports = HttpController = { updateDoc(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params const { doc_id } = req.params @@ -266,7 +265,7 @@ module.exports = HttpController = { archiveAllDocs(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params logger.log({ project_id }, 'archiving all docs') @@ -291,7 +290,7 @@ module.exports = HttpController = { unArchiveAllDocs(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params logger.log({ project_id }, 'unarchiving all docs') @@ -305,7 +304,7 @@ module.exports = HttpController = { destroyAllDocs(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params logger.log({ project_id }, 'destroying all docs') diff --git a/services/docstore/app/js/MongoManager.js b/services/docstore/app/js/MongoManager.js index 263a162516..c8ec93cb9b 100644 --- a/services/docstore/app/js/MongoManager.js +++ b/services/docstore/app/js/MongoManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -21,7 +20,7 @@ const { promisify } = require('util') module.exports = MongoManager = { findDoc(project_id, doc_id, filter, callback) { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } db.docs.findOne( { @@ -141,7 +140,7 @@ module.exports = MongoManager = { getDocVersion(doc_id, callback) { if (callback == null) { - callback = function (error, version) {} + callback = function () {} } db.docOps.findOne( { @@ -163,7 +162,7 @@ module.exports = MongoManager = { setDocVersion(doc_id, version, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } db.docOps.updateOne( { diff --git a/services/docstore/test/acceptance/js/ArchiveDocsTests.js b/services/docstore/test/acceptance/js/ArchiveDocsTests.js index 381e90fabd..fe4a85e6f6 100644 --- a/services/docstore/test/acceptance/js/ArchiveDocsTests.js +++ b/services/docstore/test/acceptance/js/ArchiveDocsTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -78,6 +77,7 @@ describe('Archiving', function () { throw error } return DocstoreClient.archiveAllDoc(this.project_id, (error, res) => { + if (error) return done(error) this.res = res return done() }) @@ -94,6 +94,7 @@ describe('Archiving', function () { (doc => { return callback => { return db.docs.findOne({ _id: doc._id }, (error, doc) => { + if (error) return callback(error) expect(doc.lines).not.to.exist expect(doc.ranges).not.to.exist doc.inS3.should.equal(true) @@ -113,6 +114,7 @@ describe('Archiving', function () { this.project_id, doc._id, (error, s3_doc) => { + if (error) return callback(error) s3_doc.lines.should.deep.equal(doc.lines) s3_doc.ranges.should.deep.equal(doc.ranges) callback() @@ -151,6 +153,7 @@ describe('Archiving', function () { ((doc, i) => { return callback => { return db.docs.findOne({ _id: doc._id }, (error, doc) => { + if (error) return callback(error) doc.lines.should.deep.equal(this.docs[i].lines) doc.ranges.should.deep.equal(this.docs[i].ranges) expect(doc.inS3).not.to.exist diff --git a/services/docstore/test/acceptance/js/DeletingDocsTests.js b/services/docstore/test/acceptance/js/DeletingDocsTests.js index 9aee6828da..46d02ebcba 100644 --- a/services/docstore/test/acceptance/js/DeletingDocsTests.js +++ b/services/docstore/test/acceptance/js/DeletingDocsTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -59,6 +58,7 @@ function deleteTestSuite(deleteDoc) { describe('when the doc exists', function () { beforeEach(function (done) { deleteDoc(this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) this.res = res return done() }) @@ -83,6 +83,7 @@ function deleteTestSuite(deleteDoc) { it('should insert a deleted doc into the docs collection', function (done) { return db.docs.find({ _id: this.doc_id }).toArray((error, docs) => { + if (error) return done(error) docs[0]._id.should.deep.equal(this.doc_id) docs[0].lines.should.deep.equal(this.lines) docs[0].deleted.should.equal(true) @@ -112,6 +113,7 @@ function deleteTestSuite(deleteDoc) { beforeEach('delete Doc', function (done) { deleteDoc(this.project_id, this.doc_id, (error, res) => { + if (error) return done(error) this.res = res done() }) @@ -196,6 +198,7 @@ function deleteTestSuite(deleteDoc) { return it('should return a 404', function (done) { const missing_doc_id = ObjectId() deleteDoc(this.project_id, missing_doc_id, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(404) return done() }) diff --git a/services/docstore/test/acceptance/js/GettingAllDocsTests.js b/services/docstore/test/acceptance/js/GettingAllDocsTests.js index 76b3d70b78..8b668ad6bf 100644 --- a/services/docstore/test/acceptance/js/GettingAllDocsTests.js +++ b/services/docstore/test/acceptance/js/GettingAllDocsTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -70,6 +69,7 @@ describe('Getting all docs', function () { version, this.deleted_doc.ranges, err => { + if (err) return done(err) return DocstoreClient.deleteDoc( this.project_id, this.deleted_doc._id, diff --git a/services/docstore/test/acceptance/js/GettingDocsFromArchiveTest.js b/services/docstore/test/acceptance/js/GettingDocsFromArchiveTest.js index 4dddbb862d..791ebbe096 100644 --- a/services/docstore/test/acceptance/js/GettingDocsFromArchiveTest.js +++ b/services/docstore/test/acceptance/js/GettingDocsFromArchiveTest.js @@ -61,6 +61,7 @@ describe('Getting A Doc from Archive', function () { this.doc._id, {}, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(200) res.headers['x-doc-status'].should.equal('archived') doc.lines.should.deep.equal(this.doc.lines) @@ -77,6 +78,7 @@ describe('Getting A Doc from Archive', function () { this.doc._id, {}, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(200) res.headers['x-doc-status'].should.equal('archived') doc.lines.should.deep.equal(this.doc.lines) @@ -113,6 +115,7 @@ describe('Getting A Doc from Archive', function () { this.doc._id, {}, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(200) res.headers['x-doc-status'].should.equal('active') doc.lines.should.deep.equal(this.doc.lines) diff --git a/services/docstore/test/acceptance/js/GettingDocsTests.js b/services/docstore/test/acceptance/js/GettingDocsTests.js index 857e0cb3ae..4f44b6ce06 100644 --- a/services/docstore/test/acceptance/js/GettingDocsTests.js +++ b/services/docstore/test/acceptance/js/GettingDocsTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -59,6 +58,7 @@ describe('Getting a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.lines) doc.version.should.equal(this.version) doc.ranges.should.deep.equal(this.ranges) @@ -76,6 +76,7 @@ describe('Getting a doc', function () { missing_doc_id, {}, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(404) return done() } @@ -111,6 +112,7 @@ describe('Getting a doc', function () { this.deleted_doc_id, { include_deleted: true }, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.lines) doc.version.should.equal(this.version) doc.ranges.should.deep.equal(this.ranges) @@ -126,6 +128,7 @@ describe('Getting a doc', function () { this.deleted_doc_id, {}, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(404) return done() } diff --git a/services/docstore/test/acceptance/js/UpdatingDocsTests.js b/services/docstore/test/acceptance/js/UpdatingDocsTests.js index eda60ae1aa..91846c7a68 100644 --- a/services/docstore/test/acceptance/js/UpdatingDocsTests.js +++ b/services/docstore/test/acceptance/js/UpdatingDocsTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -73,6 +72,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.body = body return done() } @@ -89,6 +89,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) doc.version.should.equal(this.version) doc.ranges.should.deep.equal(this.originalRanges) @@ -107,6 +108,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.body = body return done() } @@ -127,6 +129,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.newLines) doc.version.should.equal(this.version) doc.ranges.should.deep.equal(this.originalRanges) @@ -145,6 +148,7 @@ describe('Applying updates to a doc', function () { this.version + 1, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.body = body return done() } @@ -165,6 +169,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) doc.version.should.equal(this.version + 1) doc.ranges.should.deep.equal(this.originalRanges) @@ -183,6 +188,7 @@ describe('Applying updates to a doc', function () { this.version, this.newRanges, (error, res, body) => { + if (error) return done(error) this.body = body return done() } @@ -203,6 +209,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) doc.version.should.equal(this.version) doc.ranges.should.deep.equal(this.newRanges) @@ -222,6 +229,7 @@ describe('Applying updates to a doc', function () { 0, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -239,6 +247,7 @@ describe('Applying updates to a doc', function () { this.missing_doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) doc.version.should.equal(0) doc.ranges.should.deep.equal(this.originalRanges) @@ -258,6 +267,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -275,6 +285,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) return done() } @@ -291,6 +302,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -308,6 +320,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) return done() } @@ -325,6 +338,7 @@ describe('Applying updates to a doc', function () { null, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -342,6 +356,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) doc.version.should.equal(this.version) return done() @@ -361,6 +376,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.body = body return done() } @@ -377,6 +393,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.largeLines) return done() } @@ -398,6 +415,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -415,6 +433,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.largeLines) return done() } @@ -433,6 +452,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -454,6 +474,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) return done() } @@ -475,6 +496,7 @@ describe('Applying updates to a doc', function () { this.version, this.originalRanges, (error, res, body) => { + if (error) return done(error) this.res = res this.body = body return done() @@ -488,6 +510,7 @@ describe('Applying updates to a doc', function () { this.doc_id, {}, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.originalLines) return done() } diff --git a/services/docstore/test/acceptance/js/helpers/DocstoreApp.js b/services/docstore/test/acceptance/js/helpers/DocstoreApp.js index dd63eeb211..db15e6dff1 100644 --- a/services/docstore/test/acceptance/js/helpers/DocstoreApp.js +++ b/services/docstore/test/acceptance/js/helpers/DocstoreApp.js @@ -9,7 +9,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/docstore/test/unit/js/DocManagerTests.js b/services/docstore/test/unit/js/DocManagerTests.js index f81cc6a241..e36289a951 100644 --- a/services/docstore/test/unit/js/DocManagerTests.js +++ b/services/docstore/test/unit/js/DocManagerTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-dupe-keys, no-return-assign, no-unused-vars, @@ -57,6 +56,7 @@ describe('DocManager', function () { this.project_id, this.doc_id, (err, doc) => { + if (err) return done(err) doc.should.equal(this.doc) this.DocManager._getDoc .calledWith(this.project_id, this.doc_id, { @@ -98,6 +98,7 @@ describe('DocManager', function () { this.project_id, this.doc_id, (err, doc) => { + if (err) return done(err) doc.should.equal(this.doc) this.DocManager._getDoc .calledWith(this.project_id, this.doc_id, { diff --git a/services/docstore/test/unit/js/MongoManagerTests.js b/services/docstore/test/unit/js/MongoManagerTests.js index 5bfcb3c179..871bdf53e4 100644 --- a/services/docstore/test/unit/js/MongoManagerTests.js +++ b/services/docstore/test/unit/js/MongoManagerTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -228,6 +227,7 @@ describe('MongoManager', function () { this.doc_id, { lines: this.lines }, err => { + assert.equal(err, this.stubbedErr) const args = this.db.docs.updateOne.args[0] assert.deepEqual(args[0], { _id: ObjectId(this.doc_id) }) assert.equal(args[1].$set.lines, this.lines) diff --git a/services/document-updater/.eslintrc b/services/document-updater/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/document-updater/.eslintrc +++ b/services/document-updater/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/document-updater/app/js/DeleteQueueManager.js b/services/document-updater/app/js/DeleteQueueManager.js index cddc2ca56c..2aa4db32b8 100644 --- a/services/document-updater/app/js/DeleteQueueManager.js +++ b/services/document-updater/app/js/DeleteQueueManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -99,7 +98,7 @@ module.exports = DeleteQueueManager = { cutoffTime, function (err, project_id, flushTimestamp, queueLength) { if (err != null) { - return callback(err) + return callback(err, count) } if (project_id == null) { return callback(null, count) @@ -110,6 +109,11 @@ module.exports = DeleteQueueManager = { project_id, flushTimestamp, function (err, flushed) { + if (err) { + // Do not stop processing the queue in case the flush fails. + // Slowing down the processing can fill up redis. + metrics.inc('queued-delete-error') + } if (flushed) { count++ } @@ -137,7 +141,7 @@ module.exports = DeleteQueueManager = { min_delete_age: 3 * 60 * 1000, limit: 1000, // high value, to ensure we always flush enough projects }, - (err, flushed) => + (_err, flushed) => setTimeout(doFlush, flushed > 10 ? SHORT_DELAY : LONG_DELAY) ) } diff --git a/services/document-updater/app/js/DispatchManager.js b/services/document-updater/app/js/DispatchManager.js index b029d8f0ae..9a0aa56df7 100644 --- a/services/document-updater/app/js/DispatchManager.js +++ b/services/document-updater/app/js/DispatchManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -40,7 +39,7 @@ module.exports = DispatchManager = { client, _waitForUpdateThenDispatchWorker(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const timer = new Metrics.Timer('worker.waiting') return worker.client.blpop(pendingListKey, 0, function (error, result) { diff --git a/services/document-updater/app/js/DocumentManager.js b/services/document-updater/app/js/DocumentManager.js index d7108e6f44..cbedeea2a2 100644 --- a/services/document-updater/app/js/DocumentManager.js +++ b/services/document-updater/app/js/DocumentManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -30,16 +29,7 @@ const MAX_UNFLUSHED_AGE = 300 * 1000 // 5 mins, document should be flushed to mo module.exports = DocumentManager = { getDoc(project_id, doc_id, _callback) { if (_callback == null) { - _callback = function ( - error, - lines, - version, - ranges, - pathname, - projectHistoryId, - unflushedTime, - alreadyLoaded - ) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.getDoc') const callback = function (...args) { @@ -147,15 +137,7 @@ module.exports = DocumentManager = { getDocAndRecentOps(project_id, doc_id, fromVersion, _callback) { if (_callback == null) { - _callback = function ( - error, - lines, - version, - ops, - ranges, - pathname, - projectHistoryId - ) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.getDocAndRecentOps') const callback = function (...args) { @@ -207,7 +189,7 @@ module.exports = DocumentManager = { setDoc(project_id, doc_id, newLines, source, user_id, undoing, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.setDoc') const callback = function (...args) { @@ -325,7 +307,7 @@ module.exports = DocumentManager = { flushDocIfLoaded(project_id, doc_id, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.flushDocIfLoaded') const callback = function (...args) { @@ -421,7 +403,7 @@ module.exports = DocumentManager = { change_ids = [] } if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.acceptChanges') const callback = function (...args) { @@ -471,7 +453,7 @@ module.exports = DocumentManager = { deleteComment(project_id, doc_id, comment_id, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.deleteComment') const callback = function (...args) { @@ -521,7 +503,7 @@ module.exports = DocumentManager = { renameDoc(project_id, doc_id, user_id, update, projectHistoryId, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const timer = new Metrics.Timer('docManager.updateProject') const callback = function (...args) { @@ -541,7 +523,7 @@ module.exports = DocumentManager = { getDocAndFlushIfOld(project_id, doc_id, callback) { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } return DocumentManager.getDoc( project_id, @@ -648,7 +630,7 @@ module.exports = DocumentManager = { getDocWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error, lines, version) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -661,15 +643,7 @@ module.exports = DocumentManager = { getDocAndRecentOpsWithLock(project_id, doc_id, fromVersion, callback) { if (callback == null) { - callback = function ( - error, - lines, - version, - ops, - ranges, - pathname, - projectHistoryId - ) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -683,7 +657,7 @@ module.exports = DocumentManager = { getDocAndFlushIfOldWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -704,7 +678,7 @@ module.exports = DocumentManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -721,7 +695,7 @@ module.exports = DocumentManager = { flushDocIfLoadedWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -745,7 +719,7 @@ module.exports = DocumentManager = { acceptChangesWithLock(project_id, doc_id, change_ids, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -759,7 +733,7 @@ module.exports = DocumentManager = { deleteCommentWithLock(project_id, doc_id, thread_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -780,7 +754,7 @@ module.exports = DocumentManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( @@ -796,7 +770,7 @@ module.exports = DocumentManager = { resyncDocContentsWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const UpdateManager = require('./UpdateManager') return UpdateManager.lockUpdatesAndDo( diff --git a/services/document-updater/app/js/HistoryManager.js b/services/document-updater/app/js/HistoryManager.js index 176a503389..a3e8f306d2 100644 --- a/services/document-updater/app/js/HistoryManager.js +++ b/services/document-updater/app/js/HistoryManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -92,7 +91,7 @@ module.exports = HistoryManager = { // flush changes and callback (for when we need to know the queue is flushed) flushProjectChanges(project_id, options, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if ( !__guard__( @@ -147,7 +146,7 @@ module.exports = HistoryManager = { ops = [] } if (callback == null) { - callback = function (error) {} + callback = function () {} } if (ops.length === 0) { return callback() diff --git a/services/document-updater/app/js/HistoryRedisManager.js b/services/document-updater/app/js/HistoryRedisManager.js index 921df483bd..1a6bc25d3f 100644 --- a/services/document-updater/app/js/HistoryRedisManager.js +++ b/services/document-updater/app/js/HistoryRedisManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -25,7 +24,7 @@ module.exports = HistoryRedisManager = { ops = [] } if (callback == null) { - callback = function (error) {} + callback = function () {} } if (ops.length === 0) { return callback(new Error('cannot push no ops')) // This should never be called with no ops, but protect against a redis error if we sent an empty array to rpush diff --git a/services/document-updater/app/js/LockManager.js b/services/document-updater/app/js/LockManager.js index 9230a507e7..759cfa48a7 100644 --- a/services/document-updater/app/js/LockManager.js +++ b/services/document-updater/app/js/LockManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -49,7 +48,7 @@ module.exports = LockManager = { tryLock(doc_id, callback) { if (callback == null) { - callback = function (err, isFree) {} + callback = function () {} } const lockValue = LockManager.randomLock() const key = keys.blockingKey({ doc_id }) @@ -94,7 +93,7 @@ module.exports = LockManager = { getLock(doc_id, callback) { let attempt if (callback == null) { - callback = function (error, lockValue) {} + callback = function () {} } const startTime = Date.now() let testInterval = LockManager.LOCK_TEST_INTERVAL @@ -129,7 +128,7 @@ module.exports = LockManager = { checkLock(doc_id, callback) { if (callback == null) { - callback = function (err, isFree) {} + callback = function () {} } const key = keys.blockingKey({ doc_id }) return rclient.exists(key, function (err, exists) { diff --git a/services/document-updater/app/js/ProjectHistoryRedisManager.js b/services/document-updater/app/js/ProjectHistoryRedisManager.js index 5e35184cff..0497527d54 100644 --- a/services/document-updater/app/js/ProjectHistoryRedisManager.js +++ b/services/document-updater/app/js/ProjectHistoryRedisManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -28,10 +27,8 @@ const metrics = require('./Metrics') module.exports = ProjectHistoryRedisManager = { queueOps(project_id, ...rest) { // Record metric for ops pushed onto queue - const adjustedLength = Math.max(rest.length, 1) - const ops = rest.slice(0, adjustedLength - 1) - const val = rest[adjustedLength - 1] - const callback = val != null ? val : function (error, projectUpdateCount) {} + const callback = rest.pop() + const ops = rest for (const op of Array.from(ops)) { metrics.summary('redis.projectHistoryOps', op.length, { status: 'push' }) } @@ -96,7 +93,7 @@ module.exports = ProjectHistoryRedisManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } projectUpdate = { pathname: projectUpdate.pathname, diff --git a/services/document-updater/app/js/RangesManager.js b/services/document-updater/app/js/RangesManager.js index 67ca816ceb..25b44859c7 100644 --- a/services/document-updater/app/js/RangesManager.js +++ b/services/document-updater/app/js/RangesManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -29,7 +28,7 @@ module.exports = RangesManager = { updates = [] } if (callback == null) { - callback = function (error, new_entries, ranges_were_collapsed) {} + callback = function () {} } const { changes, comments } = _.cloneDeep(entries) const rangesTracker = new RangesTracker(changes, comments) @@ -95,7 +94,7 @@ module.exports = RangesManager = { acceptChanges(change_ids, ranges, callback) { if (callback == null) { - callback = function (error, ranges) {} + callback = function () {} } const { changes, comments } = ranges logger.debug(`accepting ${change_ids.length} changes in ranges`) @@ -107,7 +106,7 @@ module.exports = RangesManager = { deleteComment(comment_id, ranges, callback) { if (callback == null) { - callback = function (error, ranges) {} + callback = function () {} } const { changes, comments } = ranges logger.debug({ comment_id }, 'deleting comment in ranges') diff --git a/services/document-updater/app/js/RateLimitManager.js b/services/document-updater/app/js/RateLimitManager.js index e77d545c29..6e10f26924 100644 --- a/services/document-updater/app/js/RateLimitManager.js +++ b/services/document-updater/app/js/RateLimitManager.js @@ -56,7 +56,12 @@ module.exports = RateLimiter = class RateLimiter { run(task, callback) { if (this.ActiveWorkerCount < this.CurrentWorkerLimit) { - this._trackAndRun(task) // below the limit, just put the task in the background + // below the limit, just put the task in the background + this._trackAndRun(task, err => { + if (err) { + logger.error({ err }, 'error in background task') + } + }) callback() // return immediately if (this.CurrentWorkerLimit > this.BaseWorkerCount) { return this._adjustLimitDown() diff --git a/services/document-updater/app/js/RedisManager.js b/services/document-updater/app/js/RedisManager.js index 36ac4cdd2c..0cf700d8d4 100644 --- a/services/document-updater/app/js/RedisManager.js +++ b/services/document-updater/app/js/RedisManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -160,7 +159,7 @@ module.exports = RedisManager = { checkOrSetProjectState(project_id, newState, callback) { if (callback == null) { - callback = function (error, stateChanged) {} + callback = function () {} } const multi = rclient.multi() multi.getset(keys.projectState({ project_id }), newState) @@ -179,22 +178,14 @@ module.exports = RedisManager = { clearProjectState(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return rclient.del(keys.projectState({ project_id }), callback) }, getDoc(project_id, doc_id, callback) { if (callback == null) { - callback = function ( - error, - lines, - version, - ranges, - pathname, - projectHistoryId, - unflushedTime - ) {} + callback = function () {} } const timer = new metrics.Timer('redis.get-doc') const collectKeys = [ @@ -292,7 +283,7 @@ module.exports = RedisManager = { getDocVersion(doc_id, callback) { if (callback == null) { - callback = function (error, version, projectHistoryType) {} + callback = function () {} } return rclient.mget( keys.docVersion({ doc_id }), @@ -310,7 +301,7 @@ module.exports = RedisManager = { getDocLines(doc_id, callback) { if (callback == null) { - callback = function (error, version) {} + callback = function () {} } return rclient.get(keys.docLines({ doc_id }), function (error, docLines) { if (error != null) { @@ -322,7 +313,7 @@ module.exports = RedisManager = { getPreviousDocOps(doc_id, start, end, callback) { if (callback == null) { - callback = function (error, jsonOps) {} + callback = function () {} } const timer = new metrics.Timer('redis.get-prev-docops') return rclient.llen(keys.docOps({ doc_id }), function (error, length) { @@ -392,7 +383,7 @@ module.exports = RedisManager = { getHistoryType(doc_id, callback) { if (callback == null) { - callback = function (error, projectHistoryType) {} + callback = function () {} } return rclient.get( keys.projectHistoryType({ doc_id }), @@ -407,7 +398,7 @@ module.exports = RedisManager = { setHistoryType(doc_id, projectHistoryType, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return rclient.set( keys.projectHistoryType({ doc_id }), @@ -432,7 +423,7 @@ module.exports = RedisManager = { appliedOps = [] } if (callback == null) { - callback = function (error) {} + callback = function () {} } return RedisManager.getDocVersion( doc_id, @@ -572,8 +563,15 @@ module.exports = RedisManager = { return ProjectHistoryRedisManager.queueOps( project_id, ...Array.from(jsonOps), - (error, projectUpdateCount) => + (error, projectUpdateCount) => { + if (error) { + // The full project history can re-sync a project in case + // updates went missing. + // Just record the error here and acknowledge the write-op. + metrics.inc('history-queue-error') + } callback(null, docUpdateCount, projectUpdateCount) + } ) } else { return callback(null, docUpdateCount) @@ -586,7 +584,7 @@ module.exports = RedisManager = { renameDoc(project_id, doc_id, user_id, update, projectHistoryId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return RedisManager.getDoc( project_id, @@ -632,14 +630,14 @@ module.exports = RedisManager = { clearUnflushedTime(doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return rclient.del(keys.unflushedTime({ doc_id }), callback) }, getDocIdsInProject(project_id, callback) { if (callback == null) { - callback = function (error, doc_ids) {} + callback = function () {} } return rclient.smembers(keys.docsInProject({ project_id }), callback) }, @@ -647,7 +645,7 @@ module.exports = RedisManager = { getDocTimestamps(doc_ids, callback) { // get lastupdatedat timestamps for an array of doc_ids if (callback == null) { - callback = function (error, result) {} + callback = function () {} } return async.mapSeries( doc_ids, @@ -673,7 +671,7 @@ module.exports = RedisManager = { getNextProjectToFlushAndDelete(cutoffTime, callback) { // find the oldest queued flush that is before the cutoff time if (callback == null) { - callback = function (error, key, timestamp) {} + callback = function () {} } return rclient.zrangebyscore( keys.flushAndDeleteQueue(), @@ -713,7 +711,7 @@ module.exports = RedisManager = { _serializeRanges(ranges, callback) { if (callback == null) { - callback = function (error, serializedRanges) {} + callback = function () {} } let jsonRanges = JSON.stringify(ranges) if (jsonRanges != null && jsonRanges.length > MAX_RANGES_SIZE) { diff --git a/services/document-updater/app/js/ShareJsUpdateManager.js b/services/document-updater/app/js/ShareJsUpdateManager.js index dcccd4e339..cd68a41f2e 100644 --- a/services/document-updater/app/js/ShareJsUpdateManager.js +++ b/services/document-updater/app/js/ShareJsUpdateManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -43,7 +42,7 @@ module.exports = ShareJsUpdateManager = { applyUpdate(project_id, doc_id, update, lines, version, callback) { if (callback == null) { - callback = function (error, updatedDocLines) {} + callback = function () {} } logger.debug({ project_id, doc_id, update }, 'applying sharejs updates') const jobs = [] diff --git a/services/document-updater/app/js/UpdateManager.js b/services/document-updater/app/js/UpdateManager.js index 96c4e3fb2b..1d8dff2d8d 100644 --- a/services/document-updater/app/js/UpdateManager.js +++ b/services/document-updater/app/js/UpdateManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -34,7 +33,7 @@ const Profiler = require('./Profiler') module.exports = UpdateManager = { processOutstandingUpdates(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const timer = new Metrics.Timer('updateManager.processOutstandingUpdates') return UpdateManager.fetchAndApplyUpdates( @@ -52,7 +51,7 @@ module.exports = UpdateManager = { processOutstandingUpdatesWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const profile = new Profiler('processOutstandingUpdatesWithLock', { project_id, @@ -97,7 +96,7 @@ module.exports = UpdateManager = { continueProcessingUpdatesWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return RealTimeRedisManager.getUpdatesLength(doc_id, (error, length) => { if (error != null) { @@ -117,7 +116,7 @@ module.exports = UpdateManager = { fetchAndApplyUpdates(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const profile = new Profiler('fetchAndApplyUpdates', { project_id, doc_id }) return RealTimeRedisManager.getPendingUpdatesForDoc( @@ -150,7 +149,7 @@ module.exports = UpdateManager = { applyUpdate(project_id, doc_id, update, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const callback = function (error) { if (error != null) { @@ -343,7 +342,19 @@ module.exports = UpdateManager = { // We held the lock for a while so updates might have queued up return UpdateManager.continueProcessingUpdatesWithLock( project_id, - doc_id + doc_id, + err => { + if (err) { + // The processing may fail for invalid user updates. + // This can be very noisy, put them on level DEBUG + // and record a metric. + Metrics.inc('background-processing-updates-error') + logger.debug( + { err, project_id, doc_id }, + 'error processing updates in background' + ) + } + } ) } ) @@ -356,7 +367,7 @@ module.exports = UpdateManager = { _handleErrorInsideLock(doc_id, lockValue, original_error, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return LockManager.releaseLock(doc_id, lockValue, lock_error => callback(original_error) diff --git a/services/document-updater/expire_docops.js b/services/document-updater/expire_docops.js index c3b2b80706..42a7f40024 100644 --- a/services/document-updater/expire_docops.js +++ b/services/document-updater/expire_docops.js @@ -40,8 +40,8 @@ const getKeys = function (pattern, callback) { } const expireDocOps = callback => - // eslint-disable-next-line handle-callback-err - getKeys(keys.docOps({ doc_id: '*' }), (error, keys) => + getKeys(keys.docOps({ doc_id: '*' }), (error, keys) => { + if (error) return callback(error) async.mapSeries( keys, function (key, cb) { @@ -50,7 +50,7 @@ const expireDocOps = callback => }, callback ) - ) + }) setTimeout( () => diff --git a/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js b/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js index 5ae6f4eabd..1835b7cc22 100644 --- a/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js +++ b/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -92,6 +91,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.result) return done() } @@ -241,6 +241,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.result) return done() } @@ -254,11 +255,13 @@ describe('Applying updates to a doc', function () { 0, -1, (error, updates) => { + if (error) return done(error) JSON.parse(updates[0]).op.should.deep.equal(this.update.op) return rclient_history.sismember( HistoryKeys.docsWithHistoryOps({ project_id: this.project_id }), this.doc_id, (error, result) => { + if (error) return done(error) result.should.equal(1) return done() } @@ -274,6 +277,7 @@ describe('Applying updates to a doc', function () { 0, -1, (error, updates) => { + if (error) return done(error) JSON.parse(updates[0]).op.should.deep.equal(this.update.op) return done() } @@ -323,6 +327,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.result) return done() } @@ -336,6 +341,7 @@ describe('Applying updates to a doc', function () { 0, -1, (error, updates) => { + if (error) return done(error) updates.length.should.equal(0) return done() } @@ -349,6 +355,7 @@ describe('Applying updates to a doc', function () { 0, -1, (error, updates) => { + if (error) return done(error) JSON.parse(updates[0]).op.should.deep.equal(this.update.op) return done() } @@ -425,6 +432,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.my_result) return done() } @@ -439,6 +447,7 @@ describe('Applying updates to a doc', function () { 0, -1, (error, updates) => { + if (error) return done(error) updates = Array.from(updates).map(u => JSON.parse(u)) for (let i = 0; i < this.updates.length; i++) { const appliedUpdate = this.updates[i] @@ -449,6 +458,7 @@ describe('Applying updates to a doc', function () { HistoryKeys.docsWithHistoryOps({ project_id: this.project_id }), this.doc_id, (error, result) => { + if (error) return done(error) result.should.equal(1) return done() } @@ -464,6 +474,7 @@ describe('Applying updates to a doc', function () { 0, -1, (error, updates) => { + if (error) return done(error) updates = Array.from(updates).map(u => JSON.parse(u)) for (let i = 0; i < this.updates.length; i++) { const appliedUpdate = this.updates[i] @@ -538,6 +549,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.my_result) return done() } @@ -587,6 +599,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.lines) return done() } @@ -695,6 +708,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.result) return done() } @@ -775,6 +789,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) doc.lines.should.deep.equal(this.result) return done() } @@ -828,6 +843,7 @@ describe('Applying updates to a doc', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(404) return done() } diff --git a/services/document-updater/test/acceptance/js/DeletingADocumentTests.js b/services/document-updater/test/acceptance/js/DeletingADocumentTests.js index 9fa53d8052..9142e923e6 100644 --- a/services/document-updater/test/acceptance/js/DeletingADocumentTests.js +++ b/services/document-updater/test/acceptance/js/DeletingADocumentTests.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -76,6 +73,7 @@ describe('Deleting a document', function () { this.project_id, this.doc_id, (error, res, body) => { + if (error) return done(error) this.statusCode = res.statusCode return setTimeout(done, 200) } @@ -109,6 +107,7 @@ describe('Deleting a document', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) MockWebApi.getDocument .calledWith(this.project_id, this.doc_id) .should.equal(true) @@ -145,6 +144,7 @@ describe('Deleting a document', function () { this.project_id, this.doc_id, (error, res, body) => { + if (error) return done(error) this.statusCode = res.statusCode return setTimeout(done, 200) } @@ -170,6 +170,7 @@ describe('Deleting a document', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) MockWebApi.getDocument .calledWith(this.project_id, this.doc_id) .should.equal(true) diff --git a/services/document-updater/test/acceptance/js/DeletingAProjectTests.js b/services/document-updater/test/acceptance/js/DeletingAProjectTests.js index e9ffeb8806..0ca9700544 100644 --- a/services/document-updater/test/acceptance/js/DeletingAProjectTests.js +++ b/services/document-updater/test/acceptance/js/DeletingAProjectTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -102,6 +101,7 @@ describe('Deleting a project', function () { return DocUpdaterClient.deleteProject( this.project_id, (error, res, body) => { + if (error) return done(error) this.statusCode = res.statusCode return done() } @@ -141,6 +141,7 @@ describe('Deleting a project', function () { this.project_id, doc.id, (error, res, returnedDoc) => { + if (error) return done(error) MockWebApi.getDocument .calledWith(this.project_id, doc.id) .should.equal(true) @@ -193,6 +194,7 @@ describe('Deleting a project', function () { return DocUpdaterClient.deleteProjectOnShutdown( this.project_id, (error, res, body) => { + if (error) return done(error) this.statusCode = res.statusCode return done() } @@ -249,6 +251,7 @@ describe('Deleting a project', function () { return DocUpdaterClient.deleteProjectOnShutdown( this.project_id, (error, res, body) => { + if (error) return done(error) this.statusCode = res.statusCode // after deleting the project and putting it in the queue, flush the queue return setTimeout( diff --git a/services/document-updater/test/acceptance/js/FlushingAProjectTests.js b/services/document-updater/test/acceptance/js/FlushingAProjectTests.js index 0d7a46a990..ed6f25e805 100644 --- a/services/document-updater/test/acceptance/js/FlushingAProjectTests.js +++ b/services/document-updater/test/acceptance/js/FlushingAProjectTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -97,6 +96,7 @@ describe('Flushing a project', function () { return DocUpdaterClient.flushProject( this.project_id, (error, res, body) => { + if (error) return done(error) this.statusCode = res.statusCode return done() } @@ -130,6 +130,7 @@ describe('Flushing a project', function () { this.project_id, doc.id, (error, res, returnedDoc) => { + if (error) return done(error) returnedDoc.lines.should.deep.equal(doc.updatedLines) return callback() } diff --git a/services/document-updater/test/acceptance/js/FlushingDocsTests.js b/services/document-updater/test/acceptance/js/FlushingDocsTests.js index fdb82dc40d..128de957ec 100644 --- a/services/document-updater/test/acceptance/js/FlushingDocsTests.js +++ b/services/document-updater/test/acceptance/js/FlushingDocsTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -133,7 +132,7 @@ describe('Flushing a doc to Mongo', function () { callback ) => { if (callback == null) { - callback = function (error) {} + callback = function () {} } setTimeout(callback, t) return (t = 0) @@ -152,6 +151,7 @@ describe('Flushing a doc to Mongo', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(204) const delta = Date.now() - start expect(delta).to.be.below(20000) diff --git a/services/document-updater/test/acceptance/js/GettingADocumentTests.js b/services/document-updater/test/acceptance/js/GettingADocumentTests.js index b6acd9ebfb..4d8a231b39 100644 --- a/services/document-updater/test/acceptance/js/GettingADocumentTests.js +++ b/services/document-updater/test/acceptance/js/GettingADocumentTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -42,6 +41,7 @@ describe('Getting a document', function () { this.project_id, this.doc_id, (error, res, returnedDoc) => { + if (error) return done(error) this.returnedDoc = returnedDoc return done() } @@ -90,6 +90,7 @@ describe('Getting a document', function () { this.project_id, this.doc_id, (error, res, returnedDoc) => { + if (error) return done(error) this.returnedDoc = returnedDoc return done() } @@ -152,6 +153,7 @@ describe('Getting a document', function () { this.doc_id, 190, (error, res, returnedDoc) => { + if (error) return done(error) this.returnedDoc = returnedDoc return done() } @@ -174,6 +176,7 @@ describe('Getting a document', function () { this.doc_id, 10, (error, res, returnedDoc) => { + if (error) return done(error) this.res = res this.returnedDoc = returnedDoc return done() @@ -197,6 +200,7 @@ describe('Getting a document', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) this.statusCode = res.statusCode return done() } @@ -218,7 +222,7 @@ describe('Getting a document', function () { .stub(MockWebApi, 'getDocument') .callsFake((project_id, doc_id, callback) => { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } return callback(new Error('oops')) }) @@ -226,6 +230,7 @@ describe('Getting a document', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) this.statusCode = res.statusCode return done() } @@ -252,7 +257,7 @@ describe('Getting a document', function () { .stub(MockWebApi, 'getDocument') .callsFake((project_id, doc_id, callback) => { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } return setTimeout(callback, 30000) }) @@ -269,6 +274,7 @@ describe('Getting a document', function () { this.project_id, this.doc_id, (error, res, doc) => { + if (error) return done(error) res.statusCode.should.equal(500) const delta = Date.now() - start expect(delta).to.be.below(20000) diff --git a/services/document-updater/test/acceptance/js/GettingProjectDocsTests.js b/services/document-updater/test/acceptance/js/GettingProjectDocsTests.js index 7d72d8161c..07bdd85a37 100644 --- a/services/document-updater/test/acceptance/js/GettingProjectDocsTests.js +++ b/services/document-updater/test/acceptance/js/GettingProjectDocsTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -48,6 +47,7 @@ describe('Getting documents for project', function () { this.project_id, this.projectStateHash, (error, res, returnedDocs) => { + if (error) return done(error) this.res = res this.returnedDocs = returnedDocs return done() @@ -85,6 +85,7 @@ describe('Getting documents for project', function () { this.project_id, this.projectStateHash, (error, res0, returnedDocs0) => { + if (error) return done(error) // set the hash this.res0 = res0 this.returnedDocs0 = returnedDocs0 @@ -92,6 +93,7 @@ describe('Getting documents for project', function () { this.project_id, this.projectStateHash, (error, res, returnedDocs) => { + if (error) return done(error) // the hash should now match this.res = res this.returnedDocs = returnedDocs @@ -138,6 +140,7 @@ describe('Getting documents for project', function () { this.project_id, this.projectStateHash, (error, res0, returnedDocs0) => { + if (error) return done(error) // set the hash this.res0 = res0 this.returnedDocs0 = returnedDocs0 @@ -145,11 +148,13 @@ describe('Getting documents for project', function () { this.project_id, this.doc_id, (error, res, body) => { + if (error) return done(error) // delete the doc return DocUpdaterClient.getProjectDocs( this.project_id, this.projectStateHash, (error, res1, returnedDocs) => { + if (error) return done(error) // the hash would match, but the doc has been deleted this.res = res1 this.returnedDocs = returnedDocs diff --git a/services/document-updater/test/acceptance/js/PeekingADoc.js b/services/document-updater/test/acceptance/js/PeekingADoc.js index 43e463ca51..94ce16eb54 100644 --- a/services/document-updater/test/acceptance/js/PeekingADoc.js +++ b/services/document-updater/test/acceptance/js/PeekingADoc.js @@ -67,6 +67,7 @@ describe('Peeking a document', function () { this.project_id, this.doc_id, (error, res, returnedDoc) => { + if (error) return done(error) this.res = res this.returnedDoc = returnedDoc return done() diff --git a/services/document-updater/test/acceptance/js/RangesTests.js b/services/document-updater/test/acceptance/js/RangesTests.js index 0275bab1fb..97be0be20b 100644 --- a/services/document-updater/test/acceptance/js/RangesTests.js +++ b/services/document-updater/test/acceptance/js/RangesTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -335,6 +334,7 @@ describe('Ranges', function () { this.project_id, this.doc.id, (error, doc) => { + if (error) return done(error) const { changes } = doc.ranges changes[0].op.should.deep.equal({ i: '123', p: 1 }) changes[1].op.should.deep.equal({ i: '456', p: 5 }) diff --git a/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js b/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js index f4e249f7b6..62b7f763a1 100644 --- a/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js +++ b/services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -21,7 +18,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/document-updater/test/acceptance/js/helpers/MockProjectHistoryApi.js b/services/document-updater/test/acceptance/js/helpers/MockProjectHistoryApi.js index 513475da3d..6f75192f4f 100644 --- a/services/document-updater/test/acceptance/js/helpers/MockProjectHistoryApi.js +++ b/services/document-updater/test/acceptance/js/helpers/MockProjectHistoryApi.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -17,7 +16,7 @@ const app = express() module.exports = MockProjectHistoryApi = { flushProject(doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return callback() }, diff --git a/services/document-updater/test/acceptance/js/helpers/MockTrackChangesApi.js b/services/document-updater/test/acceptance/js/helpers/MockTrackChangesApi.js index eb66b2b3b5..baa8f10d60 100644 --- a/services/document-updater/test/acceptance/js/helpers/MockTrackChangesApi.js +++ b/services/document-updater/test/acceptance/js/helpers/MockTrackChangesApi.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -17,7 +16,7 @@ const app = express() module.exports = MockTrackChangesApi = { flushDoc(doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return callback() }, diff --git a/services/document-updater/test/acceptance/js/helpers/MockWebApi.js b/services/document-updater/test/acceptance/js/helpers/MockWebApi.js index 818895fcba..7744b30b9e 100644 --- a/services/document-updater/test/acceptance/js/helpers/MockWebApi.js +++ b/services/document-updater/test/acceptance/js/helpers/MockWebApi.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -46,7 +45,7 @@ module.exports = MockWebApi = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const doc = this.docs[`${project_id}:${doc_id}`] || @@ -62,7 +61,7 @@ module.exports = MockWebApi = { getDocument(project_id, doc_id, callback) { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } return callback(null, this.docs[`${project_id}:${doc_id}`]) }, diff --git a/services/document-updater/test/stress/js/run.js b/services/document-updater/test/stress/js/run.js index 8b0a9f353b..da0306943e 100644 --- a/services/document-updater/test/stress/js/run.js +++ b/services/document-updater/test/stress/js/run.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-undef, no-unused-vars, @@ -176,7 +175,7 @@ class StressTestClient { runForNUpdates(n, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } this.updateCallback = callback this.updateCount = n @@ -185,7 +184,7 @@ class StressTestClient { check(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return DocUpdaterClient.getDoc( this.project_id, @@ -275,7 +274,7 @@ class StressTestClient { const checkDocument = function (project_id, doc_id, clients, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const jobs = clients.map(client => cb => client.check(cb)) return async.parallel(jobs, callback) diff --git a/services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js b/services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js index 4f8b188c15..227e8b05ed 100644 --- a/services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js +++ b/services/document-updater/test/unit/js/DiffCodec/DiffCodecTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -29,6 +28,7 @@ describe('DiffCodec', function () { this.before, this.after, (error, ops) => { + if (error) return done(error) expect(ops).to.deep.equal([ { i: 'beautiful ', @@ -47,6 +47,7 @@ describe('DiffCodec', function () { this.before, this.after, (error, ops) => { + if (error) return done(error) expect(ops).to.deep.equal([ { i: 'tall ', p: 4 }, { i: 'red ', p: 29 }, @@ -63,6 +64,7 @@ describe('DiffCodec', function () { this.before, this.after, (error, ops) => { + if (error) return done(error) expect(ops).to.deep.equal([ { d: 'beautiful ', @@ -81,6 +83,7 @@ describe('DiffCodec', function () { this.before, this.after, (error, ops) => { + if (error) return done(error) expect(ops).to.deep.equal([ { d: 'tall ', p: 4 }, { d: 'red ', p: 24 }, diff --git a/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js b/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js index 91823dfa0e..55b2f057fb 100644 --- a/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js +++ b/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -168,7 +167,7 @@ describe('DispatchManager', function () { let callCount = 0 this.worker._waitForUpdateThenDispatchWorker = callback => { if (callback == null) { - callback = function (error) {} + callback = function () {} } callCount++ if (callCount === 3) { diff --git a/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js b/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js index 988333c9b8..c040d51300 100644 --- a/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js +++ b/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js @@ -126,13 +126,17 @@ describe('HistoryManager', function () { describe('flushProjectChanges', function () { describe('in the normal case', function () { - beforeEach(function () { + beforeEach(function (done) { this.request.post = sinon .stub() .callsArgWith(1, null, { statusCode: 204 }) - return this.HistoryManager.flushProjectChanges(this.project_id, { - background: true, - }) + return this.HistoryManager.flushProjectChanges( + this.project_id, + { + background: true, + }, + done + ) }) return it('should send a request to the project history api', function () { @@ -146,11 +150,15 @@ describe('HistoryManager', function () { }) return describe('with the skip_history_flush option', function () { - beforeEach(function () { + beforeEach(function (done) { this.request.post = sinon.stub() - return this.HistoryManager.flushProjectChanges(this.project_id, { - skip_history_flush: true, - }) + return this.HistoryManager.flushProjectChanges( + this.project_id, + { + skip_history_flush: true, + }, + done + ) }) return it('should not send a request to the project history api', function () { diff --git a/services/document-updater/test/unit/js/LockManager/CheckingTheLock.js b/services/document-updater/test/unit/js/LockManager/CheckingTheLock.js index 034974f805..c21a2a1b4e 100644 --- a/services/document-updater/test/unit/js/LockManager/CheckingTheLock.js +++ b/services/document-updater/test/unit/js/LockManager/CheckingTheLock.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -50,6 +49,7 @@ describe('LockManager - checking the lock', function () { it('should return true if the key does not exists', function (done) { existsStub.yields(null, '0') return LockManager.checkLock(doc_id, (err, free) => { + if (err) return done(err) free.should.equal(true) return done() }) @@ -58,6 +58,7 @@ describe('LockManager - checking the lock', function () { return it('should return false if the key does exists', function (done) { existsStub.yields(null, '1') return LockManager.checkLock(doc_id, (err, free) => { + if (err) return done(err) free.should.equal(false) return done() }) diff --git a/services/document-updater/test/unit/js/LockManager/getLockTests.js b/services/document-updater/test/unit/js/LockManager/getLockTests.js index d1ba5cf728..60537dddfe 100644 --- a/services/document-updater/test/unit/js/LockManager/getLockTests.js +++ b/services/document-updater/test/unit/js/LockManager/getLockTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -78,7 +77,7 @@ describe('LockManager - getting the lock', function () { this.LockManager.LOCK_TEST_INTERVAL = 5 this.LockManager.tryLock = (doc_id, callback) => { if (callback == null) { - callback = function (error, isFree) {} + callback = function () {} } if (Date.now() - startTime < 20 || tries < 2) { tries = tries + 1 diff --git a/services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js b/services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js index d607840494..e01f5a0679 100644 --- a/services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js +++ b/services/document-updater/test/unit/js/ProjectManager/flushProjectTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -92,7 +91,7 @@ describe('ProjectManager - flushProject', function () { this.DocumentManager.flushDocIfLoadedWithLock = sinon.spy( (project_id, doc_id, callback) => { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (doc_id === 'doc-id-1') { return callback( diff --git a/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js b/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js index c0cd994672..56bb0cd03b 100644 --- a/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js +++ b/services/document-updater/test/unit/js/RangesManager/RangesManagerTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -417,6 +416,7 @@ describe('RangesManager', function () { this.change_ids, this.ranges, (err, ranges) => { + if (err) return done(err) this.rangesResponse = ranges return done() } @@ -471,6 +471,7 @@ describe('RangesManager', function () { this.change_ids, this.ranges, (err, ranges) => { + if (err) return done(err) this.rangesResponse = ranges return done() } diff --git a/services/filestore/.eslintrc b/services/filestore/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/filestore/.eslintrc +++ b/services/filestore/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/notifications/.eslintrc b/services/notifications/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/notifications/.eslintrc +++ b/services/notifications/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/notifications/app/js/Notifications.js b/services/notifications/app/js/Notifications.js index a804a3de12..ed523235f3 100644 --- a/services/notifications/app/js/Notifications.js +++ b/services/notifications/app/js/Notifications.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -19,7 +18,7 @@ const metrics = require('@overleaf/metrics') module.exports = Notifications = { getUserNotifications(user_id, callback) { if (callback == null) { - callback = function (err, notifications) {} + callback = function () {} } const query = { user_id: ObjectId(user_id), @@ -30,7 +29,7 @@ module.exports = Notifications = { _countExistingNotifications(user_id, notification, callback) { if (callback == null) { - callback = function (err, count) {} + callback = function () {} } const query = { user_id: ObjectId(user_id), diff --git a/services/notifications/app/js/NotificationsController.js b/services/notifications/app/js/NotificationsController.js index 934676a96f..b5c32cde20 100644 --- a/services/notifications/app/js/NotificationsController.js +++ b/services/notifications/app/js/NotificationsController.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -15,7 +14,7 @@ const logger = require('logger-sharelatex') const metrics = require('@overleaf/metrics') module.exports = { - getUserNotifications(req, res) { + getUserNotifications(req, res, next) { logger.log( { user_id: req.params.user_id }, 'getting user unread notifications' @@ -23,7 +22,10 @@ module.exports = { metrics.inc('getUserNotifications') return Notifications.getUserNotifications( req.params.user_id, - (err, notifications) => res.json(notifications) + (err, notifications) => { + if (err) return next(err) + res.json(notifications) + } ) }, @@ -46,7 +48,7 @@ module.exports = { ) }, - removeNotificationId(req, res) { + removeNotificationId(req, res, next) { logger.log( { user_id: req.params.user_id, @@ -58,11 +60,14 @@ module.exports = { return Notifications.removeNotificationId( req.params.user_id, req.params.notification_id, - (err, notifications) => res.sendStatus(200) + err => { + if (err) return next(err) + res.sendStatus(200) + } ) }, - removeNotificationKey(req, res) { + removeNotificationKey(req, res, next) { logger.log( { user_id: req.params.user_id, notification_key: req.body.key }, 'mark key notification as read' @@ -71,18 +76,21 @@ module.exports = { return Notifications.removeNotificationKey( req.params.user_id, req.body.key, - (err, notifications) => res.sendStatus(200) + (err, notifications) => { + if (err) return next(err) + res.sendStatus(200) + } ) }, - removeNotificationByKeyOnly(req, res) { + removeNotificationByKeyOnly(req, res, next) { const notification_key = req.params.key logger.log({ notification_key }, 'mark notification as read by key only') metrics.inc('removeNotificationKey') - return Notifications.removeNotificationByKeyOnly( - notification_key, - (err, notifications) => res.sendStatus(200) - ) + return Notifications.removeNotificationByKeyOnly(notification_key, err => { + if (err) return next(err) + res.sendStatus(200) + }) }, countNotificationsByKeyOnly(req, res) { diff --git a/services/notifications/test/unit/js/NotificationsTests.js b/services/notifications/test/unit/js/NotificationsTests.js index 63179b4d7f..e8f46c8710 100644 --- a/services/notifications/test/unit/js/NotificationsTests.js +++ b/services/notifications/test/unit/js/NotificationsTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-dupe-keys, no-return-assign, no-unused-vars, @@ -62,6 +61,7 @@ describe('Notifications Tests', function () { return this.notifications.getUserNotifications( user_id, (err, notifications) => { + if (err) return done(err) notifications.should.equal(this.stubbedNotificationArray) assert.deepEqual(this.findStub.args[0][0], { user_id: ObjectId(user_id), @@ -228,6 +228,7 @@ describe('Notifications Tests', function () { user_id, notification_id, err => { + if (err) return done(err) const searchOps = { user_id: ObjectId(user_id), _id: ObjectId(notification_id), @@ -251,6 +252,7 @@ describe('Notifications Tests', function () { user_id, notification_key, err => { + if (err) return done(err) const searchOps = { user_id: ObjectId(user_id), key: notification_key, @@ -273,6 +275,7 @@ describe('Notifications Tests', function () { return this.notifications.removeNotificationByKeyOnly( notification_key, err => { + if (err) return done(err) const searchOps = { key: notification_key } const updateOperation = { $unset: { templateKey: true } } assert.deepEqual(this.updateOneStub.args[0][0], searchOps) @@ -290,6 +293,7 @@ describe('Notifications Tests', function () { return this.notifications.deleteNotificationByKeyOnly( notification_key, err => { + if (err) return done(err) const searchOps = { key: notification_key } assert.deepEqual(this.deleteOneStub.args[0][0], searchOps) return done() diff --git a/services/real-time/.eslintrc b/services/real-time/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/real-time/.eslintrc +++ b/services/real-time/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/real-time/app/js/Router.js b/services/real-time/app/js/Router.js index 251ee4100c..b959c7dc44 100644 --- a/services/real-time/app/js/Router.js +++ b/services/real-time/app/js/Router.js @@ -402,7 +402,10 @@ module.exports = Router = { 'clientTracking.updatePosition', function (cursorData, callback) { if (!callback) { - callback = function () {} + callback = function () { + // NOTE: The frontend does not pass any callback to socket.io. + // Any error is already logged via Router._handleError. + } } if (typeof callback !== 'function') { return Router._handleInvalidArguments( diff --git a/services/real-time/test/acceptance/js/ApplyUpdateTests.js b/services/real-time/test/acceptance/js/ApplyUpdateTests.js index ea52d1bd0f..9dd4233179 100644 --- a/services/real-time/test/acceptance/js/ApplyUpdateTests.js +++ b/services/real-time/test/acceptance/js/ApplyUpdateTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -120,6 +119,7 @@ describe('applyOtUpdate', function () { it('should push the doc into the pending updates list', function (done) { getPendingUpdatesList((error, ...rest) => { + if (error) return done(error) const [doc_id] = Array.from(rest[0]) doc_id.should.equal(`${this.project_id}:${this.doc_id}`) return done() @@ -135,6 +135,7 @@ describe('applyOtUpdate', function () { 0, -1, (error, ...rest) => { + if (error) return done(error) let [update] = Array.from(rest[0]) update = JSON.parse(update) update.op.should.deep.equal(this.update.op) @@ -265,6 +266,7 @@ describe('applyOtUpdate', function () { doc_id: this.doc_id, }), (error, len) => { + if (error) return done(error) len.should.equal(0) return done() } @@ -351,6 +353,7 @@ describe('applyOtUpdate', function () { doc_id: this.doc_id, }), (error, len) => { + if (error) return done(error) len.should.equal(0) return done() } @@ -422,6 +425,7 @@ describe('applyOtUpdate', function () { it('should push the doc into the pending updates list', function (done) { getPendingUpdatesList((error, ...rest) => { + if (error) return done(error) const [doc_id] = Array.from(rest[0]) doc_id.should.equal(`${this.project_id}:${this.doc_id}`) return done() @@ -437,6 +441,7 @@ describe('applyOtUpdate', function () { 0, -1, (error, ...rest) => { + if (error) return done(error) let [update] = Array.from(rest[0]) update = JSON.parse(update) update.op.should.deep.equal(this.comment_update.op) @@ -551,6 +556,7 @@ describe('applyOtUpdate', function () { doc_id: this.doc_id, }), (error, len) => { + if (error) return done(error) len.should.equal(0) return done() } @@ -637,6 +643,7 @@ describe('applyOtUpdate', function () { doc_id: this.doc_id, }), (error, len) => { + if (error) return done(error) len.should.equal(0) return done() } diff --git a/services/real-time/test/acceptance/js/ClientTrackingTests.js b/services/real-time/test/acceptance/js/ClientTrackingTests.js index 0fc6c6cd5b..231d2e5b77 100644 --- a/services/real-time/test/acceptance/js/ClientTrackingTests.js +++ b/services/real-time/test/acceptance/js/ClientTrackingTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -32,6 +31,7 @@ describe('clientTracking', function () { project: { name: 'Test Project' }, }, (error, { user_id, project_id }) => { + if (error) return done(error) this.user_id = user_id this.project_id = project_id return cb() @@ -127,6 +127,7 @@ describe('clientTracking', function () { return this.clientB.emit( 'clientTracking.getConnectedUsers', (error, users) => { + if (error) return done(error) for (const user of Array.from(users)) { if (user.client_id === this.clientA.publicId) { expect(user.cursorData).to.deep.equal({ @@ -155,6 +156,7 @@ describe('clientTracking', function () { publicAccess: 'readAndWrite', }, (error, { user_id, project_id }) => { + if (error) return done(error) this.user_id = user_id this.project_id = project_id return cb() diff --git a/services/real-time/test/acceptance/js/JoinDocTests.js b/services/real-time/test/acceptance/js/JoinDocTests.js index 28d80464ae..c1c728d059 100644 --- a/services/real-time/test/acceptance/js/JoinDocTests.js +++ b/services/real-time/test/acceptance/js/JoinDocTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -107,6 +106,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true) return done() } @@ -194,6 +194,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true) return done() } @@ -281,6 +282,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true) return done() } @@ -367,6 +369,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes('invalid-doc-id')).to.equal( false ) @@ -458,6 +461,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true) return done() } @@ -547,6 +551,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true) return done() } @@ -638,6 +643,7 @@ describe('joinDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true) return done() } diff --git a/services/real-time/test/acceptance/js/JoinProjectTests.js b/services/real-time/test/acceptance/js/JoinProjectTests.js index 693b4ec4b4..2f91c9cfee 100644 --- a/services/real-time/test/acceptance/js/JoinProjectTests.js +++ b/services/real-time/test/acceptance/js/JoinProjectTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -85,6 +84,7 @@ describe('joinProject', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.project_id)).to.equal( true ) @@ -97,6 +97,7 @@ describe('joinProject', function () { return this.client.emit( 'clientTracking.getConnectedUsers', (error, users) => { + if (error) return done(error) let connected = false for (const user of Array.from(users)) { if ( @@ -165,6 +166,7 @@ describe('joinProject', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.project_id)).to.equal( false ) @@ -226,6 +228,7 @@ describe('joinProject', function () { RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.project_id)).to.equal( false ) @@ -287,6 +290,7 @@ describe('joinProject', function () { RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.project_id)).to.equal( false ) diff --git a/services/real-time/test/acceptance/js/LeaveDocTests.js b/services/real-time/test/acceptance/js/LeaveDocTests.js index a9e44102a7..2749c023dc 100644 --- a/services/real-time/test/acceptance/js/LeaveDocTests.js +++ b/services/real-time/test/acceptance/js/LeaveDocTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -110,6 +109,7 @@ describe('leaveDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal( false ) @@ -156,6 +156,7 @@ describe('leaveDoc', function () { return RealTimeClient.getConnectedClient( this.client.socket.sessionid, (error, client) => { + if (error) return done(error) expect(Array.from(client.rooms).includes(this.doc_id)).to.equal( false ) diff --git a/services/real-time/test/acceptance/js/LeaveProjectTests.js b/services/real-time/test/acceptance/js/LeaveProjectTests.js index 9c71678087..ac547aa9bb 100644 --- a/services/real-time/test/acceptance/js/LeaveProjectTests.js +++ b/services/real-time/test/acceptance/js/LeaveProjectTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-throw-literal, */ // TODO: This file was created by bulk-decaffeinate. @@ -133,6 +132,7 @@ describe('leaveProject', function () { return this.clientB.emit( 'clientTracking.getConnectedUsers', (error, users) => { + if (error) return done(error) for (const user of Array.from(users)) { if (user.client_id === this.clientA.publicId) { throw 'Expected clientA to not be listed in connected users' diff --git a/services/real-time/test/acceptance/js/ReceiveUpdateTests.js b/services/real-time/test/acceptance/js/ReceiveUpdateTests.js index b8cd9858b6..003e3e858e 100644 --- a/services/real-time/test/acceptance/js/ReceiveUpdateTests.js +++ b/services/real-time/test/acceptance/js/ReceiveUpdateTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -38,6 +37,7 @@ describe('receiveUpdate', function () { project: { name: 'Test Project' }, }, (error, { user_id, project_id }) => { + if (error) return done(error) this.user_id = user_id this.project_id = project_id return cb() @@ -104,6 +104,7 @@ describe('receiveUpdate', function () { error, { user_id: user_id_second, project_id: project_id_second } ) => { + if (error) return done(error) this.user_id_second = user_id_second this.project_id_second = project_id_second return cb() diff --git a/services/real-time/test/acceptance/js/SessionTests.js b/services/real-time/test/acceptance/js/SessionTests.js index 21d691bea3..eb5c9f07a7 100644 --- a/services/real-time/test/acceptance/js/SessionTests.js +++ b/services/real-time/test/acceptance/js/SessionTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -45,6 +44,7 @@ describe('Session', function () { return it('should appear in the list of connected clients', function (done) { return RealTimeClient.getConnectedClients((error, clients) => { + if (error) return done(error) let included = false for (const client of Array.from(clients)) { if (client.client_id === this.client.socket.sessionid) { diff --git a/services/real-time/test/acceptance/js/helpers/FixturesManager.js b/services/real-time/test/acceptance/js/helpers/FixturesManager.js index 48fdc16ada..147daee240 100644 --- a/services/real-time/test/acceptance/js/helpers/FixturesManager.js +++ b/services/real-time/test/acceptance/js/helpers/FixturesManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -21,7 +20,7 @@ module.exports = FixturesManager = { options = {} } if (callback == null) { - callback = function (error, data) {} + callback = function () {} } if (!options.user_id) { options.user_id = FixturesManager.getRandomId() @@ -74,7 +73,7 @@ module.exports = FixturesManager = { options = {} } if (callback == null) { - callback = function (error, data) {} + callback = function () {} } if (!options.doc_id) { options.doc_id = FixturesManager.getRandomId() diff --git a/services/real-time/test/acceptance/js/helpers/MockDocUpdaterServer.js b/services/real-time/test/acceptance/js/helpers/MockDocUpdaterServer.js index 519da94745..694a0da605 100644 --- a/services/real-time/test/acceptance/js/helpers/MockDocUpdaterServer.js +++ b/services/real-time/test/acceptance/js/helpers/MockDocUpdaterServer.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -24,7 +23,7 @@ module.exports = MockDocUpdaterServer = { getDocument(project_id, doc_id, fromVersion, callback) { if (callback == null) { - callback = function (error, data) {} + callback = function () {} } return callback(null, MockDocUpdaterServer.docs[`${project_id}:${doc_id}`]) }, @@ -64,7 +63,7 @@ module.exports = MockDocUpdaterServer = { running: false, run(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (MockDocUpdaterServer.running) { return callback() diff --git a/services/real-time/test/acceptance/js/helpers/MockWebServer.js b/services/real-time/test/acceptance/js/helpers/MockWebServer.js index fee25e4eca..6227ee8c32 100644 --- a/services/real-time/test/acceptance/js/helpers/MockWebServer.js +++ b/services/real-time/test/acceptance/js/helpers/MockWebServer.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -26,7 +25,7 @@ module.exports = MockWebServer = { joinProject(project_id, user_id, callback) { if (callback == null) { - callback = function (error, project, privilegeLevel) {} + callback = function () {} } return callback( null, @@ -70,7 +69,7 @@ module.exports = MockWebServer = { running: false, run(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (MockWebServer.running) { return callback() diff --git a/services/real-time/test/acceptance/js/helpers/RealTimeClient.js b/services/real-time/test/acceptance/js/helpers/RealTimeClient.js index 00f00b5ee9..0e1a2b61fa 100644 --- a/services/real-time/test/acceptance/js/helpers/RealTimeClient.js +++ b/services/real-time/test/acceptance/js/helpers/RealTimeClient.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -41,7 +40,7 @@ module.exports = Client = { setSession(session, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const sessionId = uid(24) session.cookie = {} @@ -58,7 +57,7 @@ module.exports = Client = { unsetSession(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } Client.cookie = null return callback() @@ -77,7 +76,7 @@ module.exports = Client = { getConnectedClients(callback) { if (callback == null) { - callback = function (error, clients) {} + callback = function () {} } return request.get( { @@ -90,7 +89,7 @@ module.exports = Client = { getConnectedClient(client_id, callback) { if (callback == null) { - callback = function (error, clients) {} + callback = function () {} } return request.get( { @@ -116,12 +115,13 @@ module.exports = Client = { }, disconnectAllClients(callback) { - return Client.getConnectedClients((error, clients) => + return Client.getConnectedClients((error, clients) => { + if (error) return callback(error) async.each( clients, (clientView, cb) => Client.disconnectClient(clientView.client_id, cb), callback ) - ) + }) }, } diff --git a/services/real-time/test/acceptance/js/helpers/RealtimeServer.js b/services/real-time/test/acceptance/js/helpers/RealtimeServer.js index 860835ead8..6a9cdd904d 100644 --- a/services/real-time/test/acceptance/js/helpers/RealtimeServer.js +++ b/services/real-time/test/acceptance/js/helpers/RealtimeServer.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -22,7 +19,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/real-time/test/unit/js/ConnectedUsersManagerTests.js b/services/real-time/test/unit/js/ConnectedUsersManagerTests.js index 51abee1bc7..44d6ebe222 100644 --- a/services/real-time/test/unit/js/ConnectedUsersManagerTests.js +++ b/services/real-time/test/unit/js/ConnectedUsersManagerTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -95,6 +94,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.hset .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -114,6 +114,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.hset .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -133,6 +134,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.hset .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -152,6 +154,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.hset .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -171,6 +174,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.hset .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -190,6 +194,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.sadd .calledWith(`clients_in_project:${this.project_id}`, this.client_id) .should.equal(true) @@ -205,6 +210,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.expire .calledWith( `clients_in_project:${this.project_id}`, @@ -223,6 +229,7 @@ describe('ConnectedUsersManager', function () { this.user, null, err => { + if (err) return done(err) this.rClient.expire .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -241,6 +248,7 @@ describe('ConnectedUsersManager', function () { this.user, this.cursorData, err => { + if (err) return done(err) this.rClient.hset .calledWith( `connected_user:${this.project_id}:${this.client_id}`, @@ -264,6 +272,7 @@ describe('ConnectedUsersManager', function () { this.project_id, this.client_id, err => { + if (err) return done(err) this.rClient.srem .calledWith(`clients_in_project:${this.project_id}`, this.client_id) .should.equal(true) @@ -277,6 +286,7 @@ describe('ConnectedUsersManager', function () { this.project_id, this.client_id, err => { + if (err) return done(err) this.rClient.del .calledWith(`connected_user:${this.project_id}:${this.client_id}`) .should.equal(true) @@ -290,6 +300,7 @@ describe('ConnectedUsersManager', function () { this.project_id, this.client_id, err => { + if (err) return done(err) this.rClient.expire .calledWith( `clients_in_project:${this.project_id}`, @@ -315,6 +326,7 @@ describe('ConnectedUsersManager', function () { this.project_id, this.client_id, (err, result) => { + if (err) return done(err) result.connected.should.equal(true) result.client_id.should.equal(this.client_id) return done() @@ -328,6 +340,7 @@ describe('ConnectedUsersManager', function () { this.project_id, this.client_id, (err, result) => { + if (err) return done(err) result.connected.should.equal(false) result.client_id.should.equal(this.client_id) return done() @@ -341,6 +354,7 @@ describe('ConnectedUsersManager', function () { this.project_id, this.client_id, (err, result) => { + if (err) return done(err) result.connected.should.equal(false) result.client_id.should.equal(this.client_id) return done() @@ -388,6 +402,7 @@ describe('ConnectedUsersManager', function () { return this.ConnectedUsersManager.getConnectedUsers( this.project_id, (err, users) => { + if (err) return done(err) users.length.should.equal(2) users[0].should.deep.equal({ client_id: this.users[0], diff --git a/services/real-time/test/unit/js/SafeJsonParseTest.js b/services/real-time/test/unit/js/SafeJsonParseTest.js index dbdb4a41d2..afa7bbef9e 100644 --- a/services/real-time/test/unit/js/SafeJsonParseTest.js +++ b/services/real-time/test/unit/js/SafeJsonParseTest.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-useless-escape, */ @@ -29,6 +28,7 @@ describe('SafeJsonParse', function () { return describe('parse', function () { it('should parse documents correctly', function (done) { return this.SafeJsonParse.parse('{"foo": "bar"}', (error, parsed) => { + if (error) return done(error) expect(parsed).to.deep.equal({ foo: 'bar' }) return done() }) diff --git a/services/real-time/test/unit/js/SessionSocketsTests.js b/services/real-time/test/unit/js/SessionSocketsTests.js index b6f6c87fb9..3a3eb604ef 100644 --- a/services/real-time/test/unit/js/SessionSocketsTests.js +++ b/services/real-time/test/unit/js/SessionSocketsTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -160,6 +159,7 @@ describe('SessionSockets', function () { return it('should return the session', function (done) { return this.checkSocket(this.socket, (error, s, session) => { + if (error) return done(error) expect(session).to.deep.equal({ user: { _id: '123' } }) return done() }) @@ -189,6 +189,7 @@ describe('SessionSockets', function () { return it('should return the other session', function (done) { return this.checkSocket(this.socket, (error, s, session) => { + if (error) return done(error) expect(session).to.deep.equal({ user: { _id: 'abc' } }) return done() }) diff --git a/services/spelling/.eslintrc b/services/spelling/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/spelling/.eslintrc +++ b/services/spelling/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/spelling/test/unit/js/ASpellTests.js b/services/spelling/test/unit/js/ASpellTests.js index a3e2dbd9c7..b8bbb3940e 100644 --- a/services/spelling/test/unit/js/ASpellTests.js +++ b/services/spelling/test/unit/js/ASpellTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-undef */ // TODO: This file was created by bulk-decaffeinate. @@ -30,6 +29,7 @@ describe('ASpell', function () { describe('a correctly spelled word', function () { beforeEach(function (done) { return this.ASpell.checkWords('en', ['word'], (error, result) => { + if (error) return done(error) this.result = result return done() }) @@ -43,6 +43,7 @@ describe('ASpell', function () { describe('a misspelled word', function () { beforeEach(function (done) { return this.ASpell.checkWords('en', ['bussines'], (error, result) => { + if (error) return done(error) this.result = result return done() }) @@ -60,6 +61,7 @@ describe('ASpell', function () { 'en', ['bussines', 'word', 'neccesary'], (error, result) => { + if (error) return done(error) this.result = result return done() } @@ -115,6 +117,7 @@ describe('ASpell', function () { this.ASpell.ASPELL_TIMEOUT = 1 this.start = Date.now() return this.ASpell.checkWords('en', words, (error, result) => { + expect(error).to.exist this.result = result return done() }) diff --git a/services/spelling/test/unit/js/ASpellWorkerTests.js b/services/spelling/test/unit/js/ASpellWorkerTests.js index 0d8fb9d5eb..561f343c32 100644 --- a/services/spelling/test/unit/js/ASpellWorkerTests.js +++ b/services/spelling/test/unit/js/ASpellWorkerTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-undef */ const sinon = require('sinon') diff --git a/services/spelling/test/unit/js/SpellingAPIManagerTests.js b/services/spelling/test/unit/js/SpellingAPIManagerTests.js index cdf1b6b0b0..bf168bfdb5 100644 --- a/services/spelling/test/unit/js/SpellingAPIManagerTests.js +++ b/services/spelling/test/unit/js/SpellingAPIManagerTests.js @@ -69,6 +69,7 @@ describe('SpellingAPIManager', function () { this.token, { words: this.allWords }, (error, result) => { + if (error) return done(error) this.result = result done() } @@ -122,6 +123,7 @@ describe('SpellingAPIManager', function () { this.token, { words: this.allWords }, (error, result) => { + if (error) return done(error) this.result = result done() } @@ -143,6 +145,7 @@ describe('SpellingAPIManager', function () { language: this.language, }, (error, result) => { + if (error) return done(error) this.result = result done() } @@ -164,6 +167,7 @@ describe('SpellingAPIManager', function () { this.token, { words: this.words }, (error, result) => { + if (error) return done(error) this.result = result done() } diff --git a/services/track-changes/.eslintrc b/services/track-changes/.eslintrc index 68f10a66c3..3e8d7fbcff 100644 --- a/services/track-changes/.eslintrc +++ b/services/track-changes/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/handle-callback-err": "off", "no-loss-of-precision": "off", "node/no-callback-literal": "off", "node/no-path-concat": "off", diff --git a/services/track-changes/app/js/DiffManager.js b/services/track-changes/app/js/DiffManager.js index 7c8a9d4ceb..8b3fee259f 100644 --- a/services/track-changes/app/js/DiffManager.js +++ b/services/track-changes/app/js/DiffManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -22,7 +21,7 @@ module.exports = DiffManager = { // Get updates last, since then they must be ahead and it // might be possible to rewind to the same version as the doc. if (callback == null) { - callback = function (error, content, version, updates) {} + callback = function () {} } return DocumentUpdaterManager.getDocument( project_id, @@ -52,7 +51,7 @@ module.exports = DiffManager = { getDiff(project_id, doc_id, fromVersion, toVersion, callback) { if (callback == null) { - callback = function (error, diff) {} + callback = function () {} } return DiffManager.getDocumentBeforeVersion( project_id, @@ -94,7 +93,7 @@ module.exports = DiffManager = { // versions. let retry if (_callback == null) { - _callback = function (error, document, rewoundUpdates) {} + _callback = function () {} } let retries = 3 const callback = function (error, ...args) { @@ -126,7 +125,7 @@ module.exports = DiffManager = { _tryGetDocumentBeforeVersion(project_id, doc_id, version, callback) { if (callback == null) { - callback = function (error, document, rewoundUpdates) {} + callback = function () {} } logger.log( { project_id, doc_id, version }, diff --git a/services/track-changes/app/js/DocumentUpdaterManager.js b/services/track-changes/app/js/DocumentUpdaterManager.js index 4173ba328c..585e64ad0f 100644 --- a/services/track-changes/app/js/DocumentUpdaterManager.js +++ b/services/track-changes/app/js/DocumentUpdaterManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -19,7 +18,7 @@ const Settings = require('@overleaf/settings') module.exports = DocumentUpdaterManager = { _requestDocument(project_id, doc_id, url, callback) { if (callback == null) { - callback = function (error, content, version) {} + callback = function () {} } logger.log({ project_id, doc_id }, 'getting doc from document updater') @@ -64,7 +63,7 @@ module.exports = DocumentUpdaterManager = { setDocument(project_id, doc_id, content, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const url = `${Settings.apis.documentupdater.url}/project/${project_id}/doc/${doc_id}` logger.log({ project_id, doc_id }, 'setting doc in document updater') diff --git a/services/track-changes/app/js/HttpController.js b/services/track-changes/app/js/HttpController.js index 171907689c..1c916b9ef6 100644 --- a/services/track-changes/app/js/HttpController.js +++ b/services/track-changes/app/js/HttpController.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -27,7 +26,7 @@ const { pipeline } = require('stream') module.exports = HttpController = { flushDoc(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { doc_id } = req.params const { project_id } = req.params @@ -46,7 +45,7 @@ module.exports = HttpController = { flushProject(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params logger.log({ project_id }, 'compressing project history') @@ -64,7 +63,7 @@ module.exports = HttpController = { flushAll(req, res, next) { // limit on projects to flush or -1 for all (default) if (next == null) { - next = function (error) {} + next = function () {} } const limit = req.query.limit != null ? parseInt(req.query.limit, 10) : -1 logger.log({ limit }, 'flushing all projects') @@ -95,7 +94,7 @@ module.exports = HttpController = { checkDanglingUpdates(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } logger.log('checking dangling updates') return UpdatesManager.getDanglingUpdates(function (error, result) { @@ -113,7 +112,7 @@ module.exports = HttpController = { checkDoc(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { doc_id } = req.params const { project_id } = req.params @@ -146,7 +145,7 @@ module.exports = HttpController = { getDiff(req, res, next) { let from, to if (next == null) { - next = function (error) {} + next = function () {} } const { doc_id } = req.params const { project_id } = req.params @@ -180,7 +179,7 @@ module.exports = HttpController = { getUpdates(req, res, next) { let before, min_count if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params @@ -293,7 +292,7 @@ module.exports = HttpController = { restore(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } let { doc_id, project_id, version } = req.params const user_id = req.headers['x-user-id'] @@ -314,7 +313,7 @@ module.exports = HttpController = { pushDocHistory(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params const { doc_id } = req.params @@ -329,7 +328,7 @@ module.exports = HttpController = { pullDocHistory(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { project_id } = req.params const { doc_id } = req.params diff --git a/services/track-changes/app/js/LockManager.js b/services/track-changes/app/js/LockManager.js index 8be04dbaae..56c098848a 100644 --- a/services/track-changes/app/js/LockManager.js +++ b/services/track-changes/app/js/LockManager.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -40,7 +37,7 @@ module.exports = LockManager = { tryLock(key, callback) { if (callback == null) { - callback = function (err, gotLock) {} + callback = function () {} } const lockValue = LockManager.randomLock() return rclient.set( @@ -65,7 +62,7 @@ module.exports = LockManager = { getLock(key, callback) { let attempt if (callback == null) { - callback = function (error) {} + callback = function () {} } const startTime = Date.now() return (attempt = function () { @@ -90,7 +87,7 @@ module.exports = LockManager = { checkLock(key, callback) { if (callback == null) { - callback = function (err, isFree) {} + callback = function () {} } return rclient.exists(key, function (err, exists) { if (err != null) { @@ -130,7 +127,7 @@ module.exports = LockManager = { runWithLock(key, runner, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return LockManager.getLock(key, function (error, lockValue) { if (error != null) { diff --git a/services/track-changes/app/js/MongoAWS.js b/services/track-changes/app/js/MongoAWS.js index f9e69b12c2..dde6934a9a 100644 --- a/services/track-changes/app/js/MongoAWS.js +++ b/services/track-changes/app/js/MongoAWS.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -43,7 +42,7 @@ const createStream = function (streamConstructor, project_id, doc_id, pack_id) { module.exports = MongoAWS = { archivePack(project_id, doc_id, pack_id, _callback) { if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const callback = function (...args) { _callback(...Array.from(args || [])) @@ -113,7 +112,7 @@ module.exports = MongoAWS = { readArchivedPack(project_id, doc_id, pack_id, _callback) { if (_callback == null) { - _callback = function (error, result) {} + _callback = function () {} } const callback = function (...args) { _callback(...Array.from(args || [])) @@ -174,7 +173,7 @@ module.exports = MongoAWS = { unArchivePack(project_id, doc_id, pack_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return MongoAWS.readArchivedPack( project_id, diff --git a/services/track-changes/app/js/MongoManager.js b/services/track-changes/app/js/MongoManager.js index 6dfdd46ce3..c4aa28ea93 100644 --- a/services/track-changes/app/js/MongoManager.js +++ b/services/track-changes/app/js/MongoManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -22,7 +21,7 @@ const logger = require('logger-sharelatex') module.exports = MongoManager = { getLastCompressedUpdate(doc_id, callback) { if (callback == null) { - callback = function (error, update) {} + callback = function () {} } return db.docHistory .find( @@ -48,7 +47,7 @@ module.exports = MongoManager = { // to start, we pass it back as callback(null,null,version), just // giving the version so we can check consistency. if (callback == null) { - callback = function (error, update, version) {} + callback = function () {} } return MongoManager.getLastCompressedUpdate( doc_id, @@ -101,7 +100,7 @@ module.exports = MongoManager = { backportProjectId(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return db.docHistory.updateMany( { @@ -117,7 +116,7 @@ module.exports = MongoManager = { getProjectMetaData(project_id, callback) { if (callback == null) { - callback = function (error, metadata) {} + callback = function () {} } return db.projectHistoryMetaData.findOne( { @@ -129,7 +128,7 @@ module.exports = MongoManager = { setProjectMetaData(project_id, metadata, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return db.projectHistoryMetaData.updateOne( { @@ -148,7 +147,7 @@ module.exports = MongoManager = { upgradeHistory(project_id, callback) { // preserve the project's existing history if (callback == null) { - callback = function (error) {} + callback = function () {} } return db.docHistory.updateMany( { diff --git a/services/track-changes/app/js/PackManager.js b/services/track-changes/app/js/PackManager.js index fbb363ba4b..a34849f7bf 100644 --- a/services/track-changes/app/js/PackManager.js +++ b/services/track-changes/app/js/PackManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -78,7 +77,7 @@ module.exports = PackManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (newUpdates.length === 0) { return callback() @@ -144,7 +143,7 @@ module.exports = PackManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (newUpdates.length === 0) { return callback() @@ -194,7 +193,7 @@ module.exports = PackManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const first = newUpdates[0] const last = newUpdates[newUpdates.length - 1] @@ -244,7 +243,7 @@ module.exports = PackManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const first = newUpdates[0] const last = newUpdates[newUpdates.length - 1] @@ -284,7 +283,7 @@ module.exports = PackManager = { getOpsByVersionRange(project_id, doc_id, fromVersion, toVersion, callback) { if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } return PackManager.loadPacksByVersionRange( project_id, @@ -292,6 +291,7 @@ module.exports = PackManager = { fromVersion, toVersion, function (error) { + if (error) return callback(error) const query = { doc_id: ObjectId(doc_id.toString()) } if (toVersion != null) { query.v = { $lte: toVersion } @@ -436,6 +436,7 @@ module.exports = PackManager = { { projection: { pack: false } } ) .toArray((err, packs) => { + if (err) return callback(err) packs.forEach(pack => { docIdSet.add(pack.doc_id.toString()) }) @@ -446,6 +447,7 @@ module.exports = PackManager = { db.docHistoryIndex .find({ project_id: ObjectId(project_id) }) .toArray((err, indexes) => { + if (err) return callback(err) indexes.forEach(index => { docIdSet.add(index._id.toString()) }) @@ -879,6 +881,7 @@ module.exports = PackManager = { doc_id, pack_id, function (err, result) { + if (err) return callback(err) delete result.last_checked delete pack.last_checked // need to compare ids as ObjectIds with .equals() diff --git a/services/track-changes/app/js/RedisManager.js b/services/track-changes/app/js/RedisManager.js index 78822da0cd..dc2f3db2a8 100644 --- a/services/track-changes/app/js/RedisManager.js +++ b/services/track-changes/app/js/RedisManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -22,7 +21,7 @@ const async = require('async') module.exports = RedisManager = { getOldestDocUpdates(doc_id, batchSize, callback) { if (callback == null) { - callback = function (error, jsonUpdates) {} + callback = function () {} } const key = Keys.uncompressedHistoryOps({ doc_id }) return rclient.lrange(key, 0, batchSize - 1, callback) @@ -31,7 +30,7 @@ module.exports = RedisManager = { expandDocUpdates(jsonUpdates, callback) { let rawUpdates if (callback == null) { - callback = function (error, rawUpdates) {} + callback = function () {} } try { rawUpdates = Array.from(jsonUpdates || []).map(update => @@ -45,7 +44,7 @@ module.exports = RedisManager = { deleteAppliedDocUpdates(project_id, doc_id, docUpdates, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const multi = rclient.multi() // Delete all the updates which have been applied (exact match) @@ -73,7 +72,7 @@ module.exports = RedisManager = { getDocIdsWithHistoryOps(project_id, callback) { if (callback == null) { - callback = function (error, doc_ids) {} + callback = function () {} } return rclient.smembers(Keys.docsWithHistoryOps({ project_id }), callback) }, @@ -136,7 +135,7 @@ module.exports = RedisManager = { getProjectIdsWithHistoryOps(callback) { if (callback == null) { - callback = function (error, project_ids) {} + callback = function () {} } return RedisManager._getKeys( Keys.docsWithHistoryOps({ project_id: '*' }), @@ -154,7 +153,7 @@ module.exports = RedisManager = { // return all the docids, to find dangling history entries after // everything is flushed. if (callback == null) { - callback = function (error, doc_ids) {} + callback = function () {} } return RedisManager._getKeys( Keys.uncompressedHistoryOps({ doc_id: '*' }), diff --git a/services/track-changes/app/js/RestoreManager.js b/services/track-changes/app/js/RestoreManager.js index 84ddaf5236..4516afca81 100644 --- a/services/track-changes/app/js/RestoreManager.js +++ b/services/track-changes/app/js/RestoreManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -19,7 +18,7 @@ const logger = require('logger-sharelatex') module.exports = RestoreManager = { restoreToBeforeVersion(project_id, doc_id, version, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } logger.log({ project_id, doc_id, version, user_id }, 'restoring document') return DiffManager.getDocumentBeforeVersion( diff --git a/services/track-changes/app/js/UpdateCompressor.js b/services/track-changes/app/js/UpdateCompressor.js index 8e447f95c0..343fa81f95 100644 --- a/services/track-changes/app/js/UpdateCompressor.js +++ b/services/track-changes/app/js/UpdateCompressor.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, new-cap, no-throw-literal, no-unused-vars, @@ -302,7 +301,7 @@ module.exports = UpdateCompressor = { UNCHANGED: 0, diffAsShareJsOps(before, after, callback) { if (callback == null) { - callback = function (error, ops) {} + callback = function () {} } const diffs = dmp.diff_main(before, after) dmp.diff_cleanupSemantic(diffs) diff --git a/services/track-changes/app/js/UpdateTrimmer.js b/services/track-changes/app/js/UpdateTrimmer.js index b37bf545f2..4f5e228eba 100644 --- a/services/track-changes/app/js/UpdateTrimmer.js +++ b/services/track-changes/app/js/UpdateTrimmer.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -20,7 +19,7 @@ const logger = require('logger-sharelatex') module.exports = UpdateTrimmer = { shouldTrimUpdates(project_id, callback) { if (callback == null) { - callback = function (error, shouldTrim) {} + callback = function () {} } return MongoManager.getProjectMetaData( project_id, diff --git a/services/track-changes/app/js/UpdatesManager.js b/services/track-changes/app/js/UpdatesManager.js index c07ed839e0..07cd7ffc3e 100644 --- a/services/track-changes/app/js/UpdatesManager.js +++ b/services/track-changes/app/js/UpdatesManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -39,7 +38,7 @@ module.exports = UpdatesManager = { ) { let i if (callback == null) { - callback = function (error) {} + callback = function () {} } const { length } = rawUpdates if (length === 0) { @@ -206,7 +205,7 @@ module.exports = UpdatesManager = { // Check whether the updates are temporary (per-project property) _prepareProjectForUpdates(project_id, callback) { if (callback == null) { - callback = function (error, temporary) {} + callback = function () {} } return UpdateTrimmer.shouldTrimUpdates( project_id, @@ -222,7 +221,7 @@ module.exports = UpdatesManager = { // Check for project id on document history (per-document property) _prepareDocForUpdates(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return MongoManager.backportProjectId(project_id, doc_id, function (error) { if (error != null) { @@ -237,7 +236,7 @@ module.exports = UpdatesManager = { processUncompressedUpdates(project_id, doc_id, temporary, callback) { // get the updates as strings from redis (so we can delete them after they are applied) if (callback == null) { - callback = function (error) {} + callback = function () {} } return RedisManager.getOldestDocUpdates( doc_id, @@ -320,7 +319,7 @@ module.exports = UpdatesManager = { // Process updates for a doc when we flush it individually processUncompressedUpdatesWithLock(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return UpdatesManager._prepareProjectForUpdates( project_id, @@ -346,7 +345,7 @@ module.exports = UpdatesManager = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return UpdatesManager._prepareDocForUpdates( project_id, @@ -373,7 +372,7 @@ module.exports = UpdatesManager = { // Process all updates for a project, only check project-level information once processUncompressedUpdatesForProject(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return RedisManager.getDocIdsWithHistoryOps( project_id, @@ -384,6 +383,7 @@ module.exports = UpdatesManager = { return UpdatesManager._prepareProjectForUpdates( project_id, function (error, temporary) { + if (error) return callback(error) const jobs = [] for (const doc_id of Array.from(doc_ids)) { ;(doc_id => @@ -406,7 +406,7 @@ module.exports = UpdatesManager = { // flush all outstanding changes flushAll(limit, callback) { if (callback == null) { - callback = function (error, result) {} + callback = function () {} } return RedisManager.getProjectIdsWithHistoryOps(function ( error, @@ -470,7 +470,7 @@ module.exports = UpdatesManager = { getDanglingUpdates(callback) { if (callback == null) { - callback = function (error, doc_ids) {} + callback = function () {} } return RedisManager.getAllDocIdsWithHistoryOps(function ( error, @@ -495,6 +495,7 @@ module.exports = UpdatesManager = { ) // find the dangling doc ids return task(function (error, project_doc_ids) { + if (error) return callback(error) const dangling_doc_ids = _.difference(all_doc_ids, project_doc_ids) logger.log( { all_doc_ids, all_project_ids, project_doc_ids, dangling_doc_ids }, @@ -511,7 +512,7 @@ module.exports = UpdatesManager = { options = {} } if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } return UpdatesManager.processUncompressedUpdatesWithLock( project_id, @@ -542,7 +543,7 @@ module.exports = UpdatesManager = { options = {} } if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } return UpdatesManager.getDocUpdates( project_id, @@ -567,7 +568,7 @@ module.exports = UpdatesManager = { options = {} } if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } if (!options.min_count) { options.min_count = 25 @@ -690,7 +691,7 @@ module.exports = UpdatesManager = { fetchUserInfo(users, callback) { if (callback == null) { - callback = function (error, fetchedUserInfo) {} + callback = function () {} } const jobs = [] const fetchedUserInfo = {} @@ -718,7 +719,7 @@ module.exports = UpdatesManager = { fillUserInfo(updates, callback) { let update, user_id if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } const users = {} for (update of Array.from(updates)) { @@ -749,7 +750,7 @@ module.exports = UpdatesManager = { fillSummarizedUserInfo(updates, callback) { let update, user_id, user_ids if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } const users = {} for (update of Array.from(updates)) { diff --git a/services/track-changes/app/js/WebApiManager.js b/services/track-changes/app/js/WebApiManager.js index b0706d8e71..7df8c410ce 100644 --- a/services/track-changes/app/js/WebApiManager.js +++ b/services/track-changes/app/js/WebApiManager.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -26,7 +25,7 @@ const MAX_HTTP_REQUEST_LENGTH = 15000 // 15 seconds module.exports = WebApiManager = { sendRequest(url, callback) { if (callback == null) { - callback = function (error, body) {} + callback = function () {} } return request.get( { @@ -61,7 +60,7 @@ module.exports = WebApiManager = { getUserInfo(user_id, callback) { if (callback == null) { - callback = function (error, userInfo) {} + callback = function () {} } const url = `/user/${user_id}/personal_info` logger.log({ user_id }, 'getting user info from web') @@ -93,7 +92,7 @@ module.exports = WebApiManager = { getProjectDetails(project_id, callback) { if (callback == null) { - callback = function (error, details) {} + callback = function () {} } const url = `/project/${project_id}/details` logger.log({ project_id }, 'getting project details from web') diff --git a/services/track-changes/app/js/ZipManager.js b/services/track-changes/app/js/ZipManager.js index b76b81b4bc..192bcf5076 100644 --- a/services/track-changes/app/js/ZipManager.js +++ b/services/track-changes/app/js/ZipManager.js @@ -151,7 +151,9 @@ async function makeTempDirectory() { */ function cleanupTempDirectory(tmpdir) { fs.promises.rmdir(tmpdir, { recursive: true }).catch(err => { - logger.warn({ tmpdir }, 'Failed to clean up temp directory') + if (err) { + logger.warn({ err, tmpdir }, 'Failed to clean up temp directory') + } }) } diff --git a/services/track-changes/test/acceptance/js/AppendingUpdatesTests.js b/services/track-changes/test/acceptance/js/AppendingUpdatesTests.js index 9292005ba7..bd73105f2c 100644 --- a/services/track-changes/test/acceptance/js/AppendingUpdatesTests.js +++ b/services/track-changes/test/acceptance/js/AppendingUpdatesTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -100,6 +99,7 @@ describe('Appending doc ops to the history', function () { `DocsWithHistoryOps:${this.project_id}`, this.doc_id, (error, member) => { + if (error) return done(error) member.should.equal(0) return done() } diff --git a/services/track-changes/test/acceptance/js/ArchivingUpdatesTests.js b/services/track-changes/test/acceptance/js/ArchivingUpdatesTests.js index 09435bc80c..41aff0d6fb 100644 --- a/services/track-changes/test/acceptance/js/ArchivingUpdatesTests.js +++ b/services/track-changes/test/acceptance/js/ArchivingUpdatesTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-undef, no-unused-vars, */ @@ -221,9 +220,7 @@ describe('Archiving updates', function () { expiresAt: { $exists: true }, }, (err, result) => { - if (typeof error !== 'undefined' && error !== null) { - throw error - } + if (err) return done(err) return db.docHistory.count( { doc_id: ObjectId(this.doc_id) }, (error, count) => { @@ -277,6 +274,7 @@ describe('Archiving updates', function () { this.doc_id, pack_id, (error, doc) => { + if (error) return done(error) doc.n.should.equal(1024) doc.pack.length.should.equal(1024) return done() diff --git a/services/track-changes/test/acceptance/js/FlushingUpdatesTests.js b/services/track-changes/test/acceptance/js/FlushingUpdatesTests.js index 65e5ecc468..71b454a292 100644 --- a/services/track-changes/test/acceptance/js/FlushingUpdatesTests.js +++ b/services/track-changes/test/acceptance/js/FlushingUpdatesTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -64,6 +63,7 @@ describe('Flushing updates', function () { return it('should flush the op into mongo', function (done) { TrackChangesClient.getCompressedUpdates(this.doc_id, (error, updates) => { + if (error) return done(error) expect(updates[0].pack[0].op).to.deep.equal([ { p: 3, @@ -125,6 +125,7 @@ describe('Flushing updates', function () { TrackChangesClient.getCompressedUpdates( this.doc_id, (error, updates) => { + if (error) return done(error) expect(updates[0].expiresAt).to.not.exist return done() } @@ -136,6 +137,7 @@ describe('Flushing updates', function () { TrackChangesClient.getProjectMetaData( this.project_id, (error, project) => { + if (error) return done(error) expect(project.preserveHistory).to.equal(true) return done() } @@ -192,6 +194,7 @@ describe('Flushing updates', function () { TrackChangesClient.getCompressedUpdates( this.doc_id, (error, updates) => { + if (error) return done(error) expect(updates[0].expiresAt).to.exist return done() } @@ -262,6 +265,7 @@ describe('Flushing updates', function () { TrackChangesClient.getCompressedUpdates( this.doc_id, (error, updates) => { + if (error) return done(error) expect(updates[0].expiresAt).to.not.exist return done() } diff --git a/services/track-changes/test/acceptance/js/LockManagerTests.js b/services/track-changes/test/acceptance/js/LockManagerTests.js index 104e7c3220..4577e0280b 100644 --- a/services/track-changes/test/acceptance/js/LockManagerTests.js +++ b/services/track-changes/test/acceptance/js/LockManagerTests.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -37,22 +36,25 @@ describe('Locking document', function () { releaseB => { return releaseA() }, // try to release lock A to see if it wipes out lock B - error => {} + () => {} ), // we never release lock B so nothing should happen here 1500 ) }, // enough time to wait until the lock has expired - error => + err => { // we get here after trying to release lock A + expect(err).to.exist done() + } ) return null }) return it('the new lock should not be removed by the expired locker', function (done) { LockManager.checkLock('doc123', (err, isFree) => { + if (err) return done(err) expect(isFree).to.equal(false) return done() }) diff --git a/services/track-changes/test/acceptance/js/helpers/MockDocStoreApi.js b/services/track-changes/test/acceptance/js/helpers/MockDocStoreApi.js index 12787770a4..8658d302c5 100644 --- a/services/track-changes/test/acceptance/js/helpers/MockDocStoreApi.js +++ b/services/track-changes/test/acceptance/js/helpers/MockDocStoreApi.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -19,7 +18,7 @@ module.exports = MockDocUpdaterApi = { getAllDoc(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return callback(null, this.docs) }, diff --git a/services/track-changes/test/acceptance/js/helpers/MockDocUpdaterApi.js b/services/track-changes/test/acceptance/js/helpers/MockDocUpdaterApi.js index 1c39ff5dbc..1ff7dc622e 100644 --- a/services/track-changes/test/acceptance/js/helpers/MockDocUpdaterApi.js +++ b/services/track-changes/test/acceptance/js/helpers/MockDocUpdaterApi.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-undef, */ // TODO: This file was created by bulk-decaffeinate. @@ -22,14 +21,14 @@ module.exports = MockDocUpdaterApi = { getDoc(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return callback(null, this.docs[doc_id]) }, setDoc(project_id, doc_id, lines, user_id, undoing, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (!this.docs[doc_id]) { this.docs[doc_id] = {} diff --git a/services/track-changes/test/acceptance/js/helpers/MockWebApi.js b/services/track-changes/test/acceptance/js/helpers/MockWebApi.js index db6968dc54..fd8d36c058 100644 --- a/services/track-changes/test/acceptance/js/helpers/MockWebApi.js +++ b/services/track-changes/test/acceptance/js/helpers/MockWebApi.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. @@ -21,14 +20,14 @@ module.exports = MockWebApi = { getUserInfo(user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return callback(null, this.users[user_id] || null) }, getProjectDetails(project_id, callback) { if (callback == null) { - callback = function (error, project) {} + callback = function () {} } return callback(null, this.projects[project_id]) }, diff --git a/services/track-changes/test/acceptance/js/helpers/TrackChangesApp.js b/services/track-changes/test/acceptance/js/helpers/TrackChangesApp.js index f6ff0cc024..8d7d9c49f5 100644 --- a/services/track-changes/test/acceptance/js/helpers/TrackChangesApp.js +++ b/services/track-changes/test/acceptance/js/helpers/TrackChangesApp.js @@ -1,6 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. /* @@ -23,7 +20,7 @@ module.exports = { callbacks: [], ensureRunning(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.running) { return callback() diff --git a/services/track-changes/test/acceptance/js/helpers/TrackChangesClient.js b/services/track-changes/test/acceptance/js/helpers/TrackChangesClient.js index 0216c2c928..b187c4681b 100644 --- a/services/track-changes/test/acceptance/js/helpers/TrackChangesClient.js +++ b/services/track-changes/test/acceptance/js/helpers/TrackChangesClient.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -35,7 +34,7 @@ const S3_BUCKET = Settings.trackchanges.stores.doc_history module.exports = TrackChangesClient = { flushAndGetCompressedUpdates(project_id, doc_id, callback) { if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } return TrackChangesClient.flushDoc(project_id, doc_id, error => { if (error != null) { @@ -47,7 +46,7 @@ module.exports = TrackChangesClient = { flushDoc(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return request.post( { @@ -62,7 +61,7 @@ module.exports = TrackChangesClient = { flushProject(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return request.post( { @@ -77,7 +76,7 @@ module.exports = TrackChangesClient = { getCompressedUpdates(doc_id, callback) { if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } return db.docHistory .find({ doc_id: ObjectId(doc_id) }) @@ -87,7 +86,7 @@ module.exports = TrackChangesClient = { getProjectMetaData(project_id, callback) { if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } return db.projectHistoryMetaData.findOne( { @@ -99,7 +98,7 @@ module.exports = TrackChangesClient = { setPreserveHistoryForProject(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return db.projectHistoryMetaData.updateOne( { @@ -117,7 +116,7 @@ module.exports = TrackChangesClient = { pushRawUpdates(project_id, doc_id, updates, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return rclient.sadd( Keys.docsWithHistoryOps({ project_id }), @@ -137,13 +136,14 @@ module.exports = TrackChangesClient = { getDiff(project_id, doc_id, from, to, callback) { if (callback == null) { - callback = function (error, diff) {} + callback = function () {} } return request.get( { url: `http://localhost:3015/project/${project_id}/doc/${doc_id}/diff?from=${from}&to=${to}`, }, (error, response, body) => { + if (error) return callback(error) response.statusCode.should.equal(200) return callback(null, JSON.parse(body)) } @@ -152,13 +152,14 @@ module.exports = TrackChangesClient = { getUpdates(project_id, options, callback) { if (callback == null) { - callback = function (error, body) {} + callback = function () {} } return request.get( { url: `http://localhost:3015/project/${project_id}/updates?before=${options.before}&min_count=${options.min_count}`, }, (error, response, body) => { + if (error) return callback(error) response.statusCode.should.equal(200) return callback(null, JSON.parse(body)) } @@ -178,7 +179,7 @@ module.exports = TrackChangesClient = { restoreDoc(project_id, doc_id, version, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return request.post( { @@ -188,6 +189,7 @@ module.exports = TrackChangesClient = { }, }, (error, response, body) => { + if (error) return callback(error) response.statusCode.should.equal(204) return callback(null) } @@ -196,7 +198,7 @@ module.exports = TrackChangesClient = { pushDocHistory(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return request.post( { @@ -211,7 +213,7 @@ module.exports = TrackChangesClient = { pullDocHistory(project_id, doc_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return request.post( { @@ -250,7 +252,7 @@ module.exports = TrackChangesClient = { getS3Doc(project_id, doc_id, pack_id, callback) { if (callback == null) { - callback = function (error, body) {} + callback = function () {} } const params = { Bucket: S3_BUCKET, @@ -276,7 +278,7 @@ module.exports = TrackChangesClient = { removeS3Doc(project_id, doc_id, callback) { if (callback == null) { - callback = function (error, res, body) {} + callback = function () {} } let params = { Bucket: S3_BUCKET, diff --git a/services/track-changes/test/unit/js/DocArchive/MongoAWS.js b/services/track-changes/test/unit/js/DocArchive/MongoAWS.js index 72bcaccddf..1fcced3d43 100644 --- a/services/track-changes/test/unit/js/DocArchive/MongoAWS.js +++ b/services/track-changes/test/unit/js/DocArchive/MongoAWS.js @@ -1,5 +1,4 @@ /* eslint-disable - handle-callback-err, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. @@ -66,6 +65,7 @@ describe('MongoAWS', function () { this.doc_id, this.pack_id, (err, result) => { + if (err) return done(err) this.callback() return done() } @@ -80,6 +80,7 @@ describe('MongoAWS', function () { return describe('unArchivePack', function () { beforeEach(function (done) { return zlib.gzip('{"pack":"123"}', (err, zbuf) => { + if (err) return done(err) this.awssdk.config = { update: sinon.stub() } this.awssdk.S3 = sinon.stub() this.S3S.ReadStream = () => @@ -94,6 +95,7 @@ describe('MongoAWS', function () { this.doc_id, this.pack_id, (err, result) => { + if (err) return done(err) this.callback() return done() } diff --git a/services/track-changes/test/unit/js/LockManager/LockManagerTests.js b/services/track-changes/test/unit/js/LockManager/LockManagerTests.js index fd76bc0d2d..3b6a2748c9 100644 --- a/services/track-changes/test/unit/js/LockManager/LockManagerTests.js +++ b/services/track-changes/test/unit/js/LockManager/LockManagerTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, mocha/no-nested-tests, no-return-assign, no-undef, @@ -155,7 +154,7 @@ describe('LockManager', function () { this.LockManager.LOCK_TEST_INTERVAL = 5 this.LockManager.tryLock = function (doc_id, callback) { if (callback == null) { - callback = function (error, isFree) {} + callback = function () {} } if (Date.now() - startTime < 100) { return callback(null, false) @@ -204,7 +203,7 @@ describe('LockManager', function () { beforeEach(function () { this.runner = function (releaseLock) { if (releaseLock == null) { - releaseLock = function (error) {} + releaseLock = function () {} } return releaseLock() } @@ -242,7 +241,7 @@ describe('LockManager', function () { this.error = new Error('oops') this.runner = releaseLock => { if (releaseLock == null) { - releaseLock = function (error) {} + releaseLock = function () {} } return releaseLock(this.error) } diff --git a/services/track-changes/test/unit/js/UpdatesManager/UpdatesManagerTests.js b/services/track-changes/test/unit/js/UpdatesManager/UpdatesManagerTests.js index 74233e6ffa..e73e44bb42 100644 --- a/services/track-changes/test/unit/js/UpdatesManager/UpdatesManagerTests.js +++ b/services/track-changes/test/unit/js/UpdatesManager/UpdatesManagerTests.js @@ -1,6 +1,5 @@ /* eslint-disable camelcase, - handle-callback-err, no-return-assign, no-unused-vars, */ @@ -463,7 +462,7 @@ describe('UpdatesManager', function () { callback ) => { if (callback == null) { - callback = function (error, updates) {} + callback = function () {} } const updates = this.redisArray.slice(0, batchSize) this.redisArray = this.redisArray.slice(batchSize) @@ -890,7 +889,7 @@ describe('UpdatesManager', function () { this.WebApiManager.getUserInfo = (user_id, callback) => { if (callback == null) { - callback = function (error, userInfo) {} + callback = function () {} } return callback(null, this.user_info[user_id]) } @@ -899,6 +898,7 @@ describe('UpdatesManager', function () { return this.UpdatesManager.fillUserInfo( this.updates, (error, results) => { + if (error) return done(error) this.results = results return done() } @@ -963,7 +963,7 @@ describe('UpdatesManager', function () { ] this.WebApiManager.getUserInfo = (user_id, callback) => { if (callback == null) { - callback = function (error, userInfo) {} + callback = function () {} } return callback(null, this.user_info[user_id]) } @@ -972,6 +972,7 @@ describe('UpdatesManager', function () { return this.UpdatesManager.fillUserInfo( this.updates, (error, results) => { + if (error) return done(error) this.results = results return done() } diff --git a/services/web/app/src/Features/Authentication/AuthenticationController.js b/services/web/app/src/Features/Authentication/AuthenticationController.js index a8641cdad5..f18e8a4e91 100644 --- a/services/web/app/src/Features/Authentication/AuthenticationController.js +++ b/services/web/app/src/Features/Authentication/AuthenticationController.js @@ -187,7 +187,10 @@ const AuthenticationController = { ipMatchCheck(req, user) { if (req.ip !== user.lastLoginIp) { - NotificationsBuilder.ipMatcherAffiliation(user._id).create(req.ip) + NotificationsBuilder.ipMatcherAffiliation(user._id).create( + req.ip, + () => {} + ) } return UserUpdater.updateUser(user._id.toString(), { $set: { lastLoginIp: req.ip }, @@ -501,8 +504,8 @@ function _loginAsyncHandlers(req, user, anonymousAnalyticsId, isNewUser) { logger.warn({ err }, 'error setting up login data') } }) - LoginRateLimiter.recordSuccessfulLogin(user.email) - AuthenticationController._recordSuccessfulLogin(user._id) + LoginRateLimiter.recordSuccessfulLogin(user.email, () => {}) + AuthenticationController._recordSuccessfulLogin(user._id, () => {}) AuthenticationController.ipMatchCheck(req, user) Analytics.recordEventForUser(user._id, 'user-logged-in') Analytics.identifyUser(user._id, anonymousAnalyticsId, isNewUser) diff --git a/services/web/app/src/Features/Chat/ChatApiHandler.js b/services/web/app/src/Features/Chat/ChatApiHandler.js index 8afe7319fa..8d3db0e034 100644 --- a/services/web/app/src/Features/Chat/ChatApiHandler.js +++ b/services/web/app/src/Features/Chat/ChatApiHandler.js @@ -19,7 +19,7 @@ const settings = require('@overleaf/settings') module.exports = ChatApiHandler = { _apiRequest(opts, callback) { if (callback == null) { - callback = function (error, data) {} + callback = function () {} } return request(opts, function (error, response, data) { if (error != null) { @@ -71,7 +71,7 @@ module.exports = ChatApiHandler = { sendComment(project_id, thread_id, user_id, content, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { @@ -85,7 +85,7 @@ module.exports = ChatApiHandler = { getThreads(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { @@ -99,7 +99,7 @@ module.exports = ChatApiHandler = { resolveThread(project_id, thread_id, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { @@ -113,7 +113,7 @@ module.exports = ChatApiHandler = { reopenThread(project_id, thread_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { @@ -126,7 +126,7 @@ module.exports = ChatApiHandler = { deleteThread(project_id, thread_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { @@ -139,7 +139,7 @@ module.exports = ChatApiHandler = { editMessage(project_id, thread_id, message_id, content, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { @@ -155,7 +155,7 @@ module.exports = ChatApiHandler = { deleteMessage(project_id, thread_id, message_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ChatApiHandler._apiRequest( { diff --git a/services/web/app/src/Features/Chat/ChatController.js b/services/web/app/src/Features/Chat/ChatController.js index 4b900a3b0f..0a2a890c8f 100644 --- a/services/web/app/src/Features/Chat/ChatController.js +++ b/services/web/app/src/Features/Chat/ChatController.js @@ -87,7 +87,7 @@ module.exports = ChatController = { // user fields let message, thread, thread_id, user_id if (callback == null) { - callback = function (error, threads) {} + callback = function () {} } const user_ids = {} for (thread_id in threads) { diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsHandler.js b/services/web/app/src/Features/Collaborators/CollaboratorsHandler.js index 69e47259ce..b8f1fa56a8 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsHandler.js +++ b/services/web/app/src/Features/Collaborators/CollaboratorsHandler.js @@ -123,7 +123,7 @@ async function addUserIdToProject( } if (addingUserId) { - ContactManager.addContact(addingUserId, userId) + ContactManager.addContact(addingUserId, userId, () => {}) } await Project.updateOne({ _id: projectId }, { $addToSet: level }).exec() diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.js b/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.js index cf5bab90e8..89d3447853 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.js +++ b/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.js @@ -47,7 +47,7 @@ module.exports = CollaboratorsInviteController = { _checkShouldInviteEmail(email, callback) { if (callback == null) { - callback = function (err, shouldAllowInvite) {} + callback = function () {} } if (Settings.restrictInvitesToExistingAccounts === true) { logger.log({ email }, 'checking if user exists with this email') @@ -70,7 +70,7 @@ module.exports = CollaboratorsInviteController = { _checkRateLimit(user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return LimitationsManager.allowedNumberOfCollaboratorsForUser( user_id, diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.js b/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.js index 4f10a46fb9..80c1767873 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.js +++ b/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.js @@ -26,7 +26,7 @@ const { promisifyAll } = require('../../util/promises') const CollaboratorsInviteHandler = { getAllInvites(projectId, callback) { if (callback == null) { - callback = function (err, invites) {} + callback = function () {} } logger.log({ projectId }, 'fetching invites for project') return ProjectInvite.find({ projectId }, function (err, invites) { @@ -46,7 +46,7 @@ const CollaboratorsInviteHandler = { getInviteCount(projectId, callback) { if (callback == null) { - callback = function (err, count) {} + callback = function () {} } logger.log({ projectId }, 'counting invites for project') return ProjectInvite.countDocuments({ projectId }, function (err, count) { @@ -62,7 +62,7 @@ const CollaboratorsInviteHandler = { _trySendInviteNotification(projectId, sendingUser, invite, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } const { email } = invite return UserGetter.getUserByAnyEmail( @@ -124,7 +124,7 @@ const CollaboratorsInviteHandler = { _sendMessages(projectId, sendingUser, invite, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } logger.log( { projectId, inviteId: invite._id }, @@ -156,7 +156,7 @@ const CollaboratorsInviteHandler = { inviteToProject(projectId, sendingUser, email, privileges, callback) { if (callback == null) { - callback = function (err, invite) {} + callback = function () {} } logger.log( { projectId, sendingUserId: sendingUser._id, email, privileges }, @@ -209,7 +209,7 @@ const CollaboratorsInviteHandler = { revokeInvite(projectId, inviteId, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } logger.log({ projectId, inviteId }, 'removing invite') return ProjectInvite.deleteOne( @@ -233,7 +233,7 @@ const CollaboratorsInviteHandler = { resendInvite(projectId, sendingUser, inviteId, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } logger.log({ projectId, inviteId }, 'resending invite email') return ProjectInvite.findOne( @@ -274,7 +274,7 @@ const CollaboratorsInviteHandler = { getInviteByToken(projectId, tokenString, callback) { if (callback == null) { - callback = function (err, invite) {} + callback = function () {} } logger.log({ projectId, tokenString }, 'fetching invite by token') return ProjectInvite.findOne( @@ -297,7 +297,7 @@ const CollaboratorsInviteHandler = { acceptInvite(projectId, tokenString, user, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } logger.log({ projectId, userId: user._id, tokenString }, 'accepting invite') return CollaboratorsInviteHandler.getInviteByToken( diff --git a/services/web/app/src/Features/Compile/ClsiCookieManager.js b/services/web/app/src/Features/Compile/ClsiCookieManager.js index 620f27b450..23f0c04646 100644 --- a/services/web/app/src/Features/Compile/ClsiCookieManager.js +++ b/services/web/app/src/Features/Compile/ClsiCookieManager.js @@ -40,7 +40,7 @@ module.exports = function (backendGroup) { _getServerId(project_id, user_id, callback) { if (callback == null) { - callback = function (err, serverId) {} + callback = function () {} } return rclient.get( this.buildKey(project_id, user_id), @@ -63,7 +63,7 @@ module.exports = function (backendGroup) { _populateServerIdViaRequest(project_id, user_id, callback) { if (callback == null) { - callback = function (err, serverId) {} + callback = function () {} } const url = `${Settings.apis.clsi.url}/project/${project_id}/status` request.post(url, (err, res, body) => { @@ -102,7 +102,7 @@ module.exports = function (backendGroup) { setServerId(project_id, user_id, response, previous, callback) { if (callback == null) { - callback = function (err, serverId) {} + callback = function () {} } if (!clsiCookiesEnabled) { return callback() @@ -127,7 +127,8 @@ module.exports = function (backendGroup) { rclient_secondary, project_id, user_id, - serverId + serverId, + () => {} ) } this._setServerIdInRedis(rclient, project_id, user_id, serverId, err => @@ -137,7 +138,7 @@ module.exports = function (backendGroup) { _setServerIdInRedis(rclient, project_id, user_id, serverId, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } rclient.setex( this.buildKey(project_id, user_id), @@ -149,7 +150,7 @@ module.exports = function (backendGroup) { clearServerId(project_id, user_id, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } if (!clsiCookiesEnabled) { return callback() @@ -159,7 +160,7 @@ module.exports = function (backendGroup) { getCookieJar(project_id, user_id, callback) { if (callback == null) { - callback = function (err, jar, clsiServerId) {} + callback = function () {} } if (!clsiCookiesEnabled) { return callback(null, request.jar(), undefined) diff --git a/services/web/app/src/Features/Compile/ClsiStateManager.js b/services/web/app/src/Features/Compile/ClsiStateManager.js index f19624373e..02a2fd88e4 100644 --- a/services/web/app/src/Features/Compile/ClsiStateManager.js +++ b/services/web/app/src/Features/Compile/ClsiStateManager.js @@ -39,7 +39,7 @@ const buildState = s => module.exports = ClsiStateManager = { computeHash(project, options, callback) { if (callback == null) { - callback = function (err, hash) {} + callback = function () {} } return ProjectEntityHandler.getAllEntitiesFromProject( project, diff --git a/services/web/app/src/Features/Compile/CompileController.js b/services/web/app/src/Features/Compile/CompileController.js index d5b7807530..4314362a1a 100644 --- a/services/web/app/src/Features/Compile/CompileController.js +++ b/services/web/app/src/Features/Compile/CompileController.js @@ -109,7 +109,7 @@ module.exports = CompileController = { stopCompile(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const project_id = req.params.Project_id const user_id = SessionManager.getLoggedInUserId(req.session) @@ -124,7 +124,7 @@ module.exports = CompileController = { // Used for submissions through the public API compileSubmission(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } res.setTimeout(COMPILE_TIMEOUT_MS) const { submission_id } = req.params @@ -194,7 +194,7 @@ module.exports = CompileController = { downloadPdf(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } Metrics.inc('pdf-downloads') const project_id = req.params.Project_id @@ -308,7 +308,7 @@ module.exports = CompileController = { getFileFromClsi(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const project_id = req.params.Project_id return CompileController._downloadAsUser(req, function (error, user_id) { @@ -327,7 +327,7 @@ module.exports = CompileController = { getFileFromClsiWithoutUser(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const { submission_id } = req.params const url = CompileController._getFileUrl( @@ -377,7 +377,7 @@ module.exports = CompileController = { proxySyncPdf(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const project_id = req.params.Project_id const { page, h, v } = req.query @@ -413,7 +413,7 @@ module.exports = CompileController = { proxySyncCode(req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const project_id = req.params.Project_id const { file, line, column } = req.query @@ -457,7 +457,7 @@ module.exports = CompileController = { proxyToClsi(project_id, url, req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } if (req.query != null ? req.query.compileGroup : undefined) { return CompileController.proxyToClsiWithLimits( @@ -490,7 +490,7 @@ module.exports = CompileController = { proxyToClsiWithLimits(project_id, url, limits, req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } _getPersistenceOptions(req, project_id, (err, persistenceOptions) => { let qs diff --git a/services/web/app/src/Features/Compile/CompileManager.js b/services/web/app/src/Features/Compile/CompileManager.js index c4c7bd3561..fe43537b3b 100644 --- a/services/web/app/src/Features/Compile/CompileManager.js +++ b/services/web/app/src/Features/Compile/CompileManager.js @@ -30,7 +30,7 @@ module.exports = CompileManager = { options = {} } if (_callback == null) { - _callback = function (error) {} + _callback = function () {} } const timer = new Metrics.Timer('editor.compile') const callback = function (...args) { @@ -127,7 +127,7 @@ module.exports = CompileManager = { stopCompile(project_id, user_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return CompileManager.getProjectCompileLimits( project_id, @@ -142,7 +142,7 @@ module.exports = CompileManager = { deleteAuxFiles(project_id, user_id, clsiserverid, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return CompileManager.getProjectCompileLimits( project_id, @@ -163,7 +163,7 @@ module.exports = CompileManager = { getProjectCompileLimits(project_id, callback) { if (callback == null) { - callback = function (error, limits) {} + callback = function () {} } return ProjectGetter.getProject( project_id, @@ -201,7 +201,7 @@ module.exports = CompileManager = { COMPILE_DELAY: 1, // seconds _checkIfRecentlyCompiled(project_id, user_id, callback) { if (callback == null) { - callback = function (error, recentlyCompiled) {} + callback = function () {} } const key = `compile:${project_id}:${user_id}` return rclient.set( @@ -225,7 +225,7 @@ module.exports = CompileManager = { _checkCompileGroupAutoCompileLimit(isAutoCompile, compileGroup, callback) { if (callback == null) { - callback = function (err, canCompile) {} + callback = function () {} } if (!isAutoCompile) { return callback(null, true) @@ -245,7 +245,7 @@ module.exports = CompileManager = { _checkIfAutoCompileLimitHasBeenHit(isAutoCompile, compileGroup, callback) { if (callback == null) { - callback = function (err, canCompile) {} + callback = function () {} } if (!isAutoCompile) { return callback(null, true) @@ -270,7 +270,7 @@ module.exports = CompileManager = { wordCount(project_id, user_id, file, clsiserverid, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return CompileManager.getProjectCompileLimits( project_id, diff --git a/services/web/app/src/Features/Contacts/ContactManager.js b/services/web/app/src/Features/Contacts/ContactManager.js index 11caf6c1eb..a90a8d72a6 100644 --- a/services/web/app/src/Features/Contacts/ContactManager.js +++ b/services/web/app/src/Features/Contacts/ContactManager.js @@ -23,7 +23,7 @@ module.exports = ContactManager = { options = { limits: 50 } } if (callback == null) { - callback = function (error, contacts) {} + callback = function () {} } const url = `${settings.apis.contacts.url}/user/${user_id}/contacts` return request.get( @@ -55,7 +55,7 @@ module.exports = ContactManager = { addContact(user_id, contact_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const url = `${settings.apis.contacts.url}/user/${user_id}/contacts` return request.post( diff --git a/services/web/app/src/Features/Cooldown/CooldownManager.js b/services/web/app/src/Features/Cooldown/CooldownManager.js index 645b1245a7..4ae7da6182 100644 --- a/services/web/app/src/Features/Cooldown/CooldownManager.js +++ b/services/web/app/src/Features/Cooldown/CooldownManager.js @@ -24,7 +24,7 @@ module.exports = CooldownManager = { putProjectOnCooldown(projectId, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } logger.log( { projectId }, @@ -41,7 +41,7 @@ module.exports = CooldownManager = { isProjectOnCooldown(projectId, callback) { if (callback == null) { - callback = function (err, isOnCooldown) {} + callback = function () {} } return rclient.get( CooldownManager._buildKey(projectId), diff --git a/services/web/app/src/Features/Editor/EditorController.js b/services/web/app/src/Features/Editor/EditorController.js index 21ba77d9f7..1788ae2902 100644 --- a/services/web/app/src/Features/Editor/EditorController.js +++ b/services/web/app/src/Features/Editor/EditorController.js @@ -30,7 +30,7 @@ const { promisifyAll } = require('../../util/promises') const EditorController = { addDoc(project_id, folder_id, docName, docLines, source, user_id, callback) { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } return EditorController.addDocWithRanges( project_id, @@ -55,7 +55,7 @@ const EditorController = { callback ) { if (callback == null) { - callback = function (error, doc) {} + callback = function () {} } docName = docName.trim() Metrics.inc('editor.add-doc') @@ -98,7 +98,7 @@ const EditorController = { callback ) { if (callback == null) { - callback = function (error, file) {} + callback = function () {} } fileName = fileName.trim() Metrics.inc('editor.add-file') @@ -142,7 +142,7 @@ const EditorController = { callback ) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectEntityUpdateHandler.upsertDoc( project_id, @@ -178,7 +178,7 @@ const EditorController = { callback ) { if (callback == null) { - callback = function (err, file) {} + callback = function () {} } return ProjectEntityUpdateHandler.upsertFile( project_id, @@ -318,7 +318,7 @@ const EditorController = { addFolder(project_id, folder_id, folderName, source, userId, callback) { if (callback == null) { - callback = function (error, folder) {} + callback = function () {} } folderName = folderName.trim() Metrics.inc('editor.add-folder') @@ -354,7 +354,7 @@ const EditorController = { mkdirp(project_id, path, callback) { if (callback == null) { - callback = function (error, newFolders, lastFolder) {} + callback = function () {} } logger.log({ project_id, path }, "making directories if they don't exist") return ProjectEntityUpdateHandler.mkdirp( @@ -385,7 +385,7 @@ const EditorController = { deleteEntity(project_id, entity_id, entityType, source, userId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } Metrics.inc('editor.delete-entity') return ProjectEntityUpdateHandler.deleteEntity( @@ -474,7 +474,7 @@ const EditorController = { renameEntity(project_id, entity_id, entityType, newName, userId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } Metrics.inc('editor.rename-entity') return ProjectEntityUpdateHandler.renameEntity( @@ -508,7 +508,7 @@ const EditorController = { moveEntity(project_id, entity_id, folder_id, entityType, userId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } Metrics.inc('editor.move-entity') return ProjectEntityUpdateHandler.moveEntity( @@ -539,7 +539,7 @@ const EditorController = { renameProject(project_id, newName, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectDetailsHandler.renameProject( project_id, @@ -564,7 +564,7 @@ const EditorController = { setCompiler(project_id, compiler, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectOptionsHandler.setCompiler( project_id, @@ -585,7 +585,7 @@ const EditorController = { setImageName(project_id, imageName, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectOptionsHandler.setImageName( project_id, @@ -606,7 +606,7 @@ const EditorController = { setSpellCheckLanguage(project_id, languageCode, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectOptionsHandler.setSpellCheckLanguage( project_id, @@ -627,7 +627,7 @@ const EditorController = { setPublicAccessLevel(project_id, newAccessLevel, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectDetailsHandler.setPublicAccessLevel( project_id, @@ -665,7 +665,7 @@ const EditorController = { setRootDoc(project_id, newRootDocID, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectEntityUpdateHandler.setRootDoc( project_id, @@ -686,7 +686,7 @@ const EditorController = { _notifyProjectUsersOfNewFolders(project_id, folders, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return async.eachSeries( folders, @@ -710,7 +710,7 @@ const EditorController = { callback ) { if (callback == null) { - callback = function (error) {} + callback = function () {} } EditorRealTimeController.emitToRoom( project_id, diff --git a/services/web/app/src/Features/Exports/ExportsHandler.js b/services/web/app/src/Features/Exports/ExportsHandler.js index b39aa572d7..21cc94b27c 100644 --- a/services/web/app/src/Features/Exports/ExportsHandler.js +++ b/services/web/app/src/Features/Exports/ExportsHandler.js @@ -30,7 +30,7 @@ settings = require('@overleaf/settings') module.exports = ExportsHandler = self = { exportProject(export_params, callback) { if (callback == null) { - callback = function (error, export_data) {} + callback = function () {} } return self._buildExport(export_params, function (err, export_data) { if (err != null) { @@ -50,7 +50,7 @@ module.exports = ExportsHandler = self = { _buildExport(export_params, callback) { if (callback == null) { - callback = function (err, export_data) {} + callback = function () {} } const { project_id, @@ -168,7 +168,7 @@ module.exports = ExportsHandler = self = { _requestExport(export_data, callback) { if (callback == null) { - callback = function (err, export_v1_id) {} + callback = function () {} } return request.post( { @@ -199,7 +199,7 @@ module.exports = ExportsHandler = self = { _requestVersion(project_id, callback) { if (callback == null) { - callback = function (err, export_v1_id) {} + callback = function () {} } return request.get( { @@ -227,7 +227,7 @@ module.exports = ExportsHandler = self = { fetchExport(export_id, callback) { if (callback == null) { - callback = function (err, export_json) {} + callback = function () {} } return request.get( { @@ -255,7 +255,7 @@ module.exports = ExportsHandler = self = { fetchDownload(export_id, type, callback) { if (callback == null) { - callback = function (err, file_url) {} + callback = function () {} } return request.get( { diff --git a/services/web/app/src/Features/FileStore/FileHashManager.js b/services/web/app/src/Features/FileStore/FileHashManager.js index 05c88c1aad..bde054fa06 100644 --- a/services/web/app/src/Features/FileStore/FileHashManager.js +++ b/services/web/app/src/Features/FileStore/FileHashManager.js @@ -20,7 +20,7 @@ const _ = require('underscore') module.exports = FileHashManager = { computeHash(filePath, callback) { if (callback == null) { - callback = function (error, hashValue) {} + callback = function () {} } callback = _.once(callback) // avoid double callbacks diff --git a/services/web/app/src/Features/History/RestoreManager.js b/services/web/app/src/Features/History/RestoreManager.js index 4d4e229c10..925f695033 100644 --- a/services/web/app/src/Features/History/RestoreManager.js +++ b/services/web/app/src/Features/History/RestoreManager.js @@ -28,7 +28,7 @@ module.exports = RestoreManager = { // It looks up the deleted doc's contents, and then creates a new doc with the same content. // We don't actually remove the deleted doc entry, just create a new one from its lines. if (callback == null) { - callback = function (error, doc, folder_id) {} + callback = function () {} } return ProjectEntityHandler.getDoc( project_id, @@ -59,7 +59,7 @@ module.exports = RestoreManager = { restoreFileFromV2(user_id, project_id, version, pathname, callback) { if (callback == null) { - callback = function (error, entity) {} + callback = function () {} } return RestoreManager._writeFileVersionToDisk( project_id, @@ -105,7 +105,7 @@ module.exports = RestoreManager = { _findOrCreateFolder(project_id, dirname, callback) { if (callback == null) { - callback = function (error, folder_id) {} + callback = function () {} } return EditorController.mkdirp( project_id, @@ -121,7 +121,7 @@ module.exports = RestoreManager = { _addEntityWithUniqueName(addEntityWithName, basename, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return addEntityWithName(basename, function (error, entity) { if (error != null) { @@ -147,7 +147,7 @@ module.exports = RestoreManager = { _writeFileVersionToDisk(project_id, version, pathname, callback) { if (callback == null) { - callback = function (error, fsPath) {} + callback = function () {} } const url = `${ Settings.apis.project_history.url diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.js b/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.js index 1df9af65c3..678cb7aa81 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.js +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesHandler.js @@ -28,7 +28,7 @@ const { module.exports = LinkedFilesHandler = { getFileById(project_id, file_id, callback) { if (callback == null) { - callback = function (err, file) {} + callback = function () {} } return ProjectLocator.findElement( { @@ -47,7 +47,7 @@ module.exports = LinkedFilesHandler = { getSourceProject(data, callback) { if (callback == null) { - callback = function (err, project) {} + callback = function () {} } const projection = { _id: 1, name: 1 } if (data.v1_source_doc_id != null) { @@ -93,7 +93,7 @@ module.exports = LinkedFilesHandler = { callback ) { if (callback == null) { - callback = function (err, file) {} + callback = function () {} } callback = _.once(callback) return FileWriter.writeStreamToDisk( @@ -132,7 +132,7 @@ module.exports = LinkedFilesHandler = { callback ) { if (callback == null) { - callback = function (err, file) {} + callback = function () {} } callback = _.once(callback) return FileWriter.writeContentToDisk( diff --git a/services/web/app/src/Features/LinkedFiles/ProjectFileAgent.js b/services/web/app/src/Features/LinkedFiles/ProjectFileAgent.js index 80cf49db25..d47b82b7d5 100644 --- a/services/web/app/src/Features/LinkedFiles/ProjectFileAgent.js +++ b/services/web/app/src/Features/LinkedFiles/ProjectFileAgent.js @@ -73,7 +73,7 @@ module.exports = ProjectFileAgent = { _prepare(project_id, linkedFileData, user_id, callback) { if (callback == null) { - callback = function (err, linkedFileData) {} + callback = function () {} } return this._checkAuth( project_id, @@ -174,7 +174,7 @@ module.exports = ProjectFileAgent = { _getEntity(linkedFileData, current_user_id, callback) { if (callback == null) { - callback = function (err, entity, type) {} + callback = function () {} } callback = _.once(callback) const { source_entity_path } = linkedFileData @@ -236,7 +236,7 @@ module.exports = ProjectFileAgent = { _checkAuth(project_id, data, current_user_id, callback) { if (callback == null) { - callback = function (error, allowed) {} + callback = function () {} } callback = _.once(callback) if (!ProjectFileAgent._validate(data)) { diff --git a/services/web/app/src/Features/Metadata/MetaHandler.js b/services/web/app/src/Features/Metadata/MetaHandler.js index a37b3ddcc0..31c1028776 100644 --- a/services/web/app/src/Features/Metadata/MetaHandler.js +++ b/services/web/app/src/Features/Metadata/MetaHandler.js @@ -33,7 +33,7 @@ module.exports = MetaHandler = { getAllMetaForProject(projectId, callback) { if (callback == null) { - callback = function (err, projectMeta) {} + callback = function () {} } return DocumentUpdaterHandler.flushProjectToMongo( projectId, @@ -54,7 +54,7 @@ module.exports = MetaHandler = { getMetaForDoc(projectId, docId, callback) { if (callback == null) { - callback = function (err, docMeta) {} + callback = function () {} } return DocumentUpdaterHandler.flushDocToMongo( projectId, diff --git a/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js b/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js index 0235942856..01562eb4c2 100644 --- a/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js +++ b/services/web/app/src/Features/Project/ProjectCollabratecDetailsHandler.js @@ -25,7 +25,7 @@ module.exports = ProjectCollabratecDetailsHandler = { callback ) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectCollabratecDetailsHandler.setCollabratecUsers( project_id, @@ -36,7 +36,7 @@ module.exports = ProjectCollabratecDetailsHandler = { isLinkedCollabratecUserProject(project_id, user_id, callback) { if (callback == null) { - callback = function (err, isLinked) {} + callback = function () {} } try { project_id = ObjectId(project_id) @@ -68,7 +68,7 @@ module.exports = ProjectCollabratecDetailsHandler = { callback ) { if (callback == null) { - callback = function (err) {} + callback = function () {} } try { project_id = ObjectId(project_id) @@ -102,7 +102,7 @@ module.exports = ProjectCollabratecDetailsHandler = { setCollabratecUsers(project_id, collabratec_users, callback) { let err if (callback == null) { - callback = function (err) {} + callback = function () {} } try { project_id = ObjectId(project_id) @@ -127,7 +127,7 @@ module.exports = ProjectCollabratecDetailsHandler = { unlinkCollabratecUserProject(project_id, user_id, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } try { project_id = ObjectId(project_id) @@ -149,7 +149,7 @@ module.exports = ProjectCollabratecDetailsHandler = { updateCollabratecUserIds(old_user_id, new_user_id, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } try { old_user_id = ObjectId(old_user_id) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index fdea927257..9f22af22ca 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -567,7 +567,10 @@ const ProjectController = { // in v2 add notifications for matching university IPs if (Settings.overleaf != null && req.ip !== user.lastLoginIp) { - NotificationsBuilder.ipMatcherAffiliation(user._id).create(req.ip) + NotificationsBuilder.ipMatcherAffiliation(user._id).create( + req.ip, + () => {} + ) } ProjectController._injectProjectUsers(projects, (error, projects) => { diff --git a/services/web/app/src/Features/Project/ProjectHistoryHandler.js b/services/web/app/src/Features/Project/ProjectHistoryHandler.js index f3f7c39c5b..8c6c69a656 100644 --- a/services/web/app/src/Features/Project/ProjectHistoryHandler.js +++ b/services/web/app/src/Features/Project/ProjectHistoryHandler.js @@ -25,7 +25,7 @@ const ProjectHistoryHandler = { setHistoryId(project_id, history_id, callback) { // reject invalid history ids if (callback == null) { - callback = function (err) {} + callback = function () {} } if (!history_id || typeof history_id !== 'number') { return callback(new Error('invalid history id')) @@ -48,7 +48,7 @@ const ProjectHistoryHandler = { getHistoryId(project_id, callback) { if (callback == null) { - callback = function (err, result) {} + callback = function () {} } return ProjectDetailsHandler.getDetails( project_id, @@ -73,7 +73,7 @@ const ProjectHistoryHandler = { upgradeHistory(project_id, callback) { // project must have an overleaf.history.id before allowing display of new history if (callback == null) { - callback = function (err, result) {} + callback = function () {} } return Project.updateOne( { _id: project_id, 'overleaf.history.id': { $exists: true } }, @@ -96,7 +96,7 @@ const ProjectHistoryHandler = { downgradeHistory(project_id, callback) { if (callback == null) { - callback = function (err, result) {} + callback = function () {} } return Project.updateOne( { _id: project_id, 'overleaf.history.upgradedAt': { $exists: true } }, @@ -123,7 +123,7 @@ const ProjectHistoryHandler = { // state. Setting a history id when one wasn't present before is ok, // because undefined history ids aren't cached. if (callback == null) { - callback = function (err) {} + callback = function () {} } return ProjectHistoryHandler.getHistoryId( project_id, diff --git a/services/web/app/src/Features/Project/ProjectRootDocManager.js b/services/web/app/src/Features/Project/ProjectRootDocManager.js index aa4af9a0fb..232f5687da 100644 --- a/services/web/app/src/Features/Project/ProjectRootDocManager.js +++ b/services/web/app/src/Features/Project/ProjectRootDocManager.js @@ -28,7 +28,7 @@ const _ = require('underscore') module.exports = ProjectRootDocManager = { setRootDocAutomatically(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ProjectEntityHandler.getAllDocs(project_id, function (error, docs) { if (error != null) { @@ -70,7 +70,7 @@ module.exports = ProjectRootDocManager = { findRootDocFileFromDirectory(directoryPath, callback) { if (callback == null) { - callback = function (error, path, content) {} + callback = function () {} } const filePathsPromise = globby(['**/*.{tex,Rtex}'], { cwd: directoryPath, @@ -131,7 +131,7 @@ module.exports = ProjectRootDocManager = { setRootDocFromName(project_id, rootDocName, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ProjectEntityHandler.getAllDocPathsFromProjectById( project_id, @@ -180,7 +180,7 @@ module.exports = ProjectRootDocManager = { ensureRootDocumentIsSet(project_id, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return ProjectGetter.getProject( project_id, @@ -246,7 +246,7 @@ module.exports = ProjectRootDocManager = { _sortFileList(listToSort, rootDirectory, callback) { if (callback == null) { - callback = function (error, result) {} + callback = function () {} } return async.mapLimit( listToSort, diff --git a/services/web/app/src/Features/Publishers/PublishersGetter.js b/services/web/app/src/Features/Publishers/PublishersGetter.js index 4397abb421..03b038fd6b 100644 --- a/services/web/app/src/Features/Publishers/PublishersGetter.js +++ b/services/web/app/src/Features/Publishers/PublishersGetter.js @@ -21,7 +21,7 @@ const _ = require('underscore') module.exports = PublishersGetter = { getManagedPublishers(user_id, callback) { if (callback == null) { - callback = function (error, managedPublishers) {} + callback = function () {} } return UserMembershipsHandler.getEntitiesByUser( UserMembershipEntityConfigs.publisher, diff --git a/services/web/app/src/Features/References/ReferencesHandler.js b/services/web/app/src/Features/References/ReferencesHandler.js index 87d8636c72..df90d0c979 100644 --- a/services/web/app/src/Features/References/ReferencesHandler.js +++ b/services/web/app/src/Features/References/ReferencesHandler.js @@ -78,7 +78,7 @@ module.exports = ReferencesHandler = { _isFullIndex(project, callback) { if (callback == null) { - callback = function (err, result) {} + callback = function () {} } return UserGetter.getUser( project.owner_ref, @@ -99,7 +99,7 @@ module.exports = ReferencesHandler = { indexAll(projectId, callback) { if (callback == null) { - callback = function (err, data) {} + callback = function () {} } return ProjectGetter.getProject( projectId, @@ -127,7 +127,7 @@ module.exports = ReferencesHandler = { index(projectId, docIds, callback) { if (callback == null) { - callback = function (err, data) {} + callback = function () {} } return ProjectGetter.getProject( projectId, diff --git a/services/web/app/src/Features/StaticPages/HomeController.js b/services/web/app/src/Features/StaticPages/HomeController.js index 1db71bc746..2a9a745b60 100644 --- a/services/web/app/src/Features/StaticPages/HomeController.js +++ b/services/web/app/src/Features/StaticPages/HomeController.js @@ -49,7 +49,7 @@ module.exports = HomeController = { externalPage(page, title) { return function (req, res, next) { if (next == null) { - next = function (error) {} + next = function () {} } const path = Path.join(__dirname, `/../../../views/external/${page}.pug`) return fs.exists(path, function (exists) { diff --git a/services/web/app/src/Features/Subscription/RecurlyWrapper.js b/services/web/app/src/Features/Subscription/RecurlyWrapper.js index e1f3060b99..92755e7d94 100644 --- a/services/web/app/src/Features/Subscription/RecurlyWrapper.js +++ b/services/web/app/src/Features/Subscription/RecurlyWrapper.js @@ -830,7 +830,7 @@ const RecurlyWrapper = { listAccountActiveSubscriptions(account_id, callback) { if (callback == null) { - callback = function (error, subscriptions) {} + callback = function () {} } return RecurlyWrapper.apiRequest( { diff --git a/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js b/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js index 25b920c918..0b60c7ebd4 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js +++ b/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js @@ -71,7 +71,7 @@ const SubscriptionGroupHandler = { isUserPartOfGroup(user_id, subscription_id, callback) { if (callback == null) { - callback = function (err, partOfGroup) {} + callback = function () {} } return SubscriptionLocator.getSubscriptionByMemberIdAndId( user_id, @@ -90,7 +90,7 @@ const SubscriptionGroupHandler = { getTotalConfirmedUsersInGroup(subscription_id, callback) { if (callback == null) { - callback = function (err, totalUsers) {} + callback = function () {} } return SubscriptionLocator.getSubscription( subscription_id, diff --git a/services/web/app/src/Features/Subscription/SubscriptionLocator.js b/services/web/app/src/Features/Subscription/SubscriptionLocator.js index 3c7d8b5832..b12cd392d7 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionLocator.js +++ b/services/web/app/src/Features/Subscription/SubscriptionLocator.js @@ -43,7 +43,7 @@ const SubscriptionLocator = { getManagedGroupSubscriptions(user_or_id, callback) { if (callback == null) { - callback = function (error, managedSubscriptions) {} + callback = function () {} } const user_id = SubscriptionLocator._getUserId(user_or_id) return Subscription.find({ diff --git a/services/web/app/src/Features/Subscription/V1SubscriptionManager.js b/services/web/app/src/Features/Subscription/V1SubscriptionManager.js index 0fdef3e6c9..b0c0ff3946 100644 --- a/services/web/app/src/Features/Subscription/V1SubscriptionManager.js +++ b/services/web/app/src/Features/Subscription/V1SubscriptionManager.js @@ -27,7 +27,7 @@ module.exports = V1SubscriptionManager = { // - 'v1_free' getPlanCodeFromV1(userId, callback) { if (callback == null) { - callback = function (err, planCode, v1Id) {} + callback = function () {} } return V1SubscriptionManager._v1Request( userId, @@ -55,7 +55,7 @@ module.exports = V1SubscriptionManager = { getSubscriptionsFromV1(userId, callback) { if (callback == null) { - callback = function (err, subscriptions, v1Id) {} + callback = function () {} } return V1SubscriptionManager._v1Request( userId, @@ -71,7 +71,7 @@ module.exports = V1SubscriptionManager = { getSubscriptionStatusFromV1(userId, callback) { if (callback == null) { - callback = function (err, status) {} + callback = function () {} } return V1SubscriptionManager._v1Request( userId, @@ -87,7 +87,7 @@ module.exports = V1SubscriptionManager = { cancelV1Subscription(userId, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } return V1SubscriptionManager._v1Request( userId, @@ -103,7 +103,7 @@ module.exports = V1SubscriptionManager = { v1IdForUser(userId, callback) { if (callback == null) { - callback = function (err, v1Id) {} + callback = function () {} } return UserGetter.getUser( userId, @@ -142,7 +142,7 @@ module.exports = V1SubscriptionManager = { _v1Request(userId, options, callback) { if (callback == null) { - callback = function (err, body, v1Id) {} + callback = function () {} } if (!settings.apis.v1.url) { return callback(null, null) diff --git a/services/web/app/src/Features/SystemMessages/SystemMessageManager.js b/services/web/app/src/Features/SystemMessages/SystemMessageManager.js index 632cb0a841..5c936c3824 100644 --- a/services/web/app/src/Features/SystemMessages/SystemMessageManager.js +++ b/services/web/app/src/Features/SystemMessages/SystemMessageManager.js @@ -15,28 +15,28 @@ const { SystemMessage } = require('../../models/SystemMessage') module.exports = SystemMessageManager = { getMessages(callback) { if (callback == null) { - callback = function (error, messages) {} + callback = function () {} } callback(null, this._cachedMessages) }, getMessagesFromDB(callback) { if (callback == null) { - callback = function (error, messages) {} + callback = function () {} } return SystemMessage.find({}, callback) }, clearMessages(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return SystemMessage.deleteMany({}, callback) }, createMessage(content, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const message = new SystemMessage({ content }) return message.save(callback) diff --git a/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js b/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js index 6940d204db..dbf861a1a6 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js +++ b/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js @@ -25,7 +25,7 @@ const ProjectEntityHandler = require('../Project/ProjectEntityHandler') module.exports = UpdateMerger = { mergeUpdate(user_id, project_id, path, updateRequest, source, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return FileWriter.writeStreamToDisk( project_id, @@ -73,7 +73,7 @@ module.exports = UpdateMerger = { _determineFileType(project_id, path, fsPath, callback) { if (callback == null) { - callback = function (err, fileType) {} + callback = function () {} } // check if there is an existing file with the same path (we either need // to overwrite it or delete it) @@ -132,7 +132,7 @@ module.exports = UpdateMerger = { _mergeUpdate(user_id, project_id, path, fsPath, source, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return UpdateMerger._determineFileType( project_id, diff --git a/services/web/app/src/Features/TokenGenerator/TokenGenerator.js b/services/web/app/src/Features/TokenGenerator/TokenGenerator.js index 0e47b65f8f..45f666d1fb 100644 --- a/services/web/app/src/Features/TokenGenerator/TokenGenerator.js +++ b/services/web/app/src/Features/TokenGenerator/TokenGenerator.js @@ -61,7 +61,7 @@ const TokenGenerator = { generateUniqueReadOnlyToken(callback) { if (callback == null) { - callback = function (err, token) {} + callback = function () {} } return Async.retry( 10, diff --git a/services/web/app/src/Features/Uploads/ArchiveManager.js b/services/web/app/src/Features/Uploads/ArchiveManager.js index 6efcbe97fc..eced8d4169 100644 --- a/services/web/app/src/Features/Uploads/ArchiveManager.js +++ b/services/web/app/src/Features/Uploads/ArchiveManager.js @@ -33,7 +33,7 @@ const ONE_MEG = 1024 * 1024 const ArchiveManager = { _isZipTooLarge(source, callback) { if (callback == null) { - callback = function (err, isTooLarge) {} + callback = function () {} } callback = _.once(callback) @@ -79,7 +79,7 @@ const ArchiveManager = { _checkFilePath(entry, destination, callback) { // transform backslashes to forwardslashes to accommodate badly-behaved zip archives if (callback == null) { - callback = function (err, destFile) {} + callback = function () {} } const transformedFilename = entry.fileName.replace(/\\/g, '/') // check if the entry is a directory @@ -104,7 +104,7 @@ const ArchiveManager = { _writeFileEntry(zipfile, entry, destFile, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } callback = _.once(callback) @@ -135,7 +135,7 @@ const ArchiveManager = { _extractZipFiles(source, destination, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } callback = _.once(callback) @@ -201,7 +201,7 @@ const ArchiveManager = { extractZipArchive(source, destination, _callback) { if (_callback == null) { - _callback = function (err) {} + _callback = function () {} } const callback = function (...args) { _callback(...Array.from(args || [])) @@ -242,7 +242,7 @@ const ArchiveManager = { findTopLevelDirectory(directory, callback) { if (callback == null) { - callback = function (error, topLevelDir) {} + callback = function () {} } return fs.readdir(directory, function (error, files) { if (error != null) { diff --git a/services/web/app/src/Features/User/UserController.js b/services/web/app/src/Features/User/UserController.js index 4e016e499e..fbfdec5ee6 100644 --- a/services/web/app/src/Features/User/UserController.js +++ b/services/web/app/src/Features/User/UserController.js @@ -249,7 +249,7 @@ const UserController = { OError.tag(err, 'error destroying session') return next(err) } - UserSessionsManager.untrackSession(user, sessionId) + UserSessionsManager.untrackSession(user, sessionId, () => {}) res.sendStatus(200) }) } @@ -418,7 +418,7 @@ const UserController = { return cb(err) } if (user != null) { - UserSessionsManager.untrackSession(user, sessionId) + UserSessionsManager.untrackSession(user, sessionId, () => {}) } cb() }) diff --git a/services/web/app/src/Features/UserMembership/UserMembershipHandler.js b/services/web/app/src/Features/UserMembership/UserMembershipHandler.js index 8f9f32d4de..6a70cfa764 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipHandler.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipHandler.js @@ -29,7 +29,7 @@ const UserMembershipEntityConfigs = require('./UserMembershipEntityConfigs') const UserMembershipHandler = { getEntityWithoutAuthorizationCheck(entityId, entityConfig, callback) { if (callback == null) { - callback = function (error, entity) {} + callback = function () {} } const query = buildEntityQuery(entityId, entityConfig) return EntityModels[entityConfig.modelName].findOne(query, callback) @@ -37,7 +37,7 @@ const UserMembershipHandler = { createEntity(entityId, entityConfig, callback) { if (callback == null) { - callback = function (error, entity) {} + callback = function () {} } const data = buildEntityQuery(entityId, entityConfig) return EntityModels[entityConfig.modelName].create(data, callback) @@ -45,7 +45,7 @@ const UserMembershipHandler = { getUsers(entity, entityConfig, callback) { if (callback == null) { - callback = function (error, users) {} + callback = function () {} } const attributes = entityConfig.fields.read return getPopulatedListOfMembers(entity, attributes, callback) @@ -53,7 +53,7 @@ const UserMembershipHandler = { addUser(entity, entityConfig, email, callback) { if (callback == null) { - callback = function (error, user) {} + callback = function () {} } const attribute = entityConfig.fields.write return UserGetter.getUserByAnyEmail(email, function (error, user) { @@ -77,7 +77,7 @@ const UserMembershipHandler = { removeUser(entity, entityConfig, userId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const attribute = entityConfig.fields.write if (entity.admin_id != null ? entity.admin_id.equals(userId) : undefined) { @@ -93,7 +93,7 @@ module.exports = UserMembershipHandler function getPopulatedListOfMembers(entity, attributes, callback) { if (callback == null) { - callback = function (error, users) {} + callback = function () {} } const userObjects = [] @@ -112,7 +112,7 @@ function getPopulatedListOfMembers(entity, attributes, callback) { function addUserToEntity(entity, attribute, user, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const fieldUpdate = {} fieldUpdate[attribute] = user._id @@ -121,7 +121,7 @@ function addUserToEntity(entity, attribute, user, callback) { function removeUserFromEntity(entity, attribute, userId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const fieldUpdate = {} fieldUpdate[attribute] = userId diff --git a/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js b/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js index 99ba0fb71e..66653e6e39 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js @@ -25,7 +25,7 @@ module.exports = UserMembershipViewModel = { buildAsync(userOrIdOrEmail, callback) { if (callback == null) { - callback = function (error, viewModel) {} + callback = function () {} } if (!isObjectIdInstance(userOrIdOrEmail)) { // userOrIdOrEmail is a user or an email and can be parsed by #build diff --git a/services/web/app/src/Features/UserMembership/UserMembershipsHandler.js b/services/web/app/src/Features/UserMembership/UserMembershipsHandler.js index 004d8acdac..f20d78d43d 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipsHandler.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipsHandler.js @@ -23,7 +23,7 @@ const UserMembershipsHandler = { removeUserFromAllEntities(userId, callback) { // get all writable entity types if (callback == null) { - callback = function (error) {} + callback = function () {} } const entityConfigs = [] for (const key in UserMembershipEntityConfigs) { @@ -48,7 +48,7 @@ const UserMembershipsHandler = { removeUserFromEntities(entityConfig, userId, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } const removeOperation = { $pull: {} } removeOperation.$pull[entityConfig.fields.write] = userId @@ -61,7 +61,7 @@ const UserMembershipsHandler = { getEntitiesByUser(entityConfig, userId, callback) { if (callback == null) { - callback = function (error, entities) {} + callback = function () {} } const query = Object.assign({}, entityConfig.baseQuery) query[entityConfig.fields.access] = userId diff --git a/services/web/app/src/infrastructure/FileWriter.js b/services/web/app/src/infrastructure/FileWriter.js index 55e5faba8f..a5301b22e1 100644 --- a/services/web/app/src/infrastructure/FileWriter.js +++ b/services/web/app/src/infrastructure/FileWriter.js @@ -59,7 +59,7 @@ class SizeLimitedStream extends Transform { const FileWriter = { ensureDumpFolderExists(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } return fs.mkdir(Settings.path.dumpFolder, function (error) { if (error != null && error.code !== 'EEXIST') { @@ -72,14 +72,14 @@ const FileWriter = { writeLinesToDisk(identifier, lines, callback) { if (callback == null) { - callback = function (error, fsPath) {} + callback = function () {} } return FileWriter.writeContentToDisk(identifier, lines.join('\n'), callback) }, writeContentToDisk(identifier, content, callback) { if (callback == null) { - callback = function (error, fsPath) {} + callback = function () {} } callback = _.once(callback) const fsPath = `${Settings.path.dumpFolder}/${identifier}_${uuid.v4()}` @@ -102,7 +102,7 @@ const FileWriter = { options = {} } if (callback == null) { - callback = function (error, fsPath) {} + callback = function () {} } options = options || {} @@ -168,7 +168,7 @@ const FileWriter = { options = {} } if (callback == null) { - callback = function (error, fsPath) {} + callback = function () {} } options = options || {} callback = _.once(callback) diff --git a/services/web/frontend/js/ide/editor/Document.js b/services/web/frontend/js/ide/editor/Document.js index c592b841df..da6a562d2d 100644 --- a/services/web/frontend/js/ide/editor/Document.js +++ b/services/web/frontend/js/ide/editor/Document.js @@ -250,7 +250,7 @@ export default Document = (function () { join(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } this.wantToBeJoined = true this._cancelLeave() @@ -266,7 +266,7 @@ export default Document = (function () { leave(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } this.flush() // force an immediate flush when leaving document this.wantToBeJoined = false @@ -472,7 +472,7 @@ export default Document = (function () { _joinDoc(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (this.doc != null) { this.ide.pushEvent('joinDoc:existing', { @@ -563,7 +563,7 @@ export default Document = (function () { _leaveDoc(callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } this.ide.pushEvent('leaveDoc', { doc_id: this.doc_id, diff --git a/services/web/frontend/js/ide/editor/EditorManager.js b/services/web/frontend/js/ide/editor/EditorManager.js index 9ca4da9631..f3ab9a4974 100644 --- a/services/web/frontend/js/ide/editor/EditorManager.js +++ b/services/web/frontend/js/ide/editor/EditorManager.js @@ -284,7 +284,7 @@ export default EditorManager = (function () { _doOpenNewDocument(doc, callback) { if (callback == null) { - callback = function (error, sharejs_doc) {} + callback = function () {} } sl_console.log('[_doOpenNewDocument] Opening...') const new_sharejs_doc = Document.getDocument(this.ide, doc.id) diff --git a/services/web/frontend/js/ide/file-tree/FileTreeManager.js b/services/web/frontend/js/ide/file-tree/FileTreeManager.js index 9657a8ee68..5f13ae62ea 100644 --- a/services/web/frontend/js/ide/file-tree/FileTreeManager.js +++ b/services/web/frontend/js/ide/file-tree/FileTreeManager.js @@ -320,7 +320,7 @@ export default FileTreeManager = class FileTreeManager { forEachEntity(callback) { if (callback == null) { - callback = function (entity, parent_folder, path) {} + callback = function () {} } this._forEachEntityInFolder(this.$scope.rootFolder, null, callback) @@ -621,7 +621,7 @@ export default FileTreeManager = class FileTreeManager { renameEntity(entity, name, callback) { if (callback == null) { - callback = function (error) {} + callback = function () {} } if (entity.name === name) { return @@ -651,7 +651,7 @@ export default FileTreeManager = class FileTreeManager { // We'll wait for the socket.io notification to // delete from scope. if (callback == null) { - callback = function (error) {} + callback = function () {} } return this.ide.queuedHttp({ method: 'DELETE', diff --git a/services/web/frontend/js/services/validateCaptcha.js b/services/web/frontend/js/services/validateCaptcha.js index 1d8a01b084..7b8cbf41dc 100644 --- a/services/web/frontend/js/services/validateCaptcha.js +++ b/services/web/frontend/js/services/validateCaptcha.js @@ -23,7 +23,7 @@ export default App.factory('validateCaptcha', function () { let recaptchaId = null const validateCaptcha = (callback, captchaDisabled) => { if (callback == null) { - callback = function (response) {} + callback = function () {} } if ( typeof grecaptcha === 'undefined' || diff --git a/services/web/modules/launchpad/app/src/LaunchpadController.js b/services/web/modules/launchpad/app/src/LaunchpadController.js index ab40ddcf77..a46c4d83c5 100644 --- a/services/web/modules/launchpad/app/src/LaunchpadController.js +++ b/services/web/modules/launchpad/app/src/LaunchpadController.js @@ -84,7 +84,7 @@ module.exports = LaunchpadController = { _atLeastOneAdminExists(callback) { if (callback == null) { - callback = function (err, exists) {} + callback = function () {} } return UserGetter.getUser( { isAdmin: true }, diff --git a/services/web/test/acceptance/src/helpers/redis.js b/services/web/test/acceptance/src/helpers/redis.js index e1cd72dd35..b954ccce81 100644 --- a/services/web/test/acceptance/src/helpers/redis.js +++ b/services/web/test/acceptance/src/helpers/redis.js @@ -23,7 +23,7 @@ const rclient = UserSessionsRedis.client() module.exports = { getUserSessions(user, callback) { if (callback == null) { - callback = function (err, sessionsSet) {} + callback = function () {} } return rclient.smembers( UserSessionsRedis.sessionSetKey(user), @@ -33,7 +33,7 @@ module.exports = { clearUserSessions(user, callback) { if (callback == null) { - callback = function (err) {} + callback = function () {} } const sessionSetKey = UserSessionsRedis.sessionSetKey(user) return rclient.smembers(sessionSetKey, (err, sessionKeys) => { diff --git a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js index 58797e5bb2..eab475847d 100644 --- a/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js +++ b/services/web/test/unit/src/infrastructure/LockManager/getLockTests.js @@ -83,7 +83,7 @@ describe('LockManager - getting the lock', function () { this.LockManager.LOCK_TEST_INTERVAL = 5 this.LockManager._tryLock = function (key, namespace, callback) { if (callback == null) { - callback = function (error, isFree) {} + callback = function () {} } if (Date.now() - startTime < 20 || tries < 2) { tries = tries + 1 @@ -135,7 +135,7 @@ describe('LockManager - getting the lock', function () { this.LockManager.LOCK_TEST_INTERVAL = 1 this.LockManager._tryLock = function (key, namespace, callback) { if (callback == null) { - callback = function (error, gotLock, lockValue) {} + callback = function () {} } if (locked) { return callback(null, false)