Node.js based forum software built for the modern web
feat: display stack trace on winston.error
Barış Soner Uşaklıe80379dc0e87
diff --git a/install/web.js b/install/web.jsindex 56bf322a92..0bccdc1847 100644--- a/install/web.js+++ b/install/web.js@@ -81,7 +81,7 @@ web.install = function (port) {async.parallel([compileLess, compileJS, copyCSS, loadDefaults], function (err) {if (err) {- winston.error(err);+ winston.error(err.stack);}setupRoutes();launchExpress(port);@@ -225,12 +225,12 @@ function launch(req, res) {function compileLess(callback) {fs.readFile(path.join(__dirname, '../public/less/install.less'), function (err, style) {if (err) {- return winston.error('Unable to read LESS install file: ', err);+ return winston.error('Unable to read LESS install file: ', err.stack);}less.render(style.toString(), function (err, css) {if (err) {- return winston.error('Unable to compile LESS: ', err);+ return winston.error('Unable to compile LESS: ', err.stack);}fs.writeFile(path.join(__dirname, '../public/installer.css'), css.css, callback);diff --git a/src/analytics.js b/src/analytics.jsindex 3db38cba27..dcc9c2ac9d 100644--- a/src/analytics.js+++ b/src/analytics.js@@ -138,7 +138,7 @@ Analytics.writeData = async function () {try {await Promise.all(dbQueue);} catch (err) {- winston.error('[analytics] Encountered error while writing analytics to data store', err);+ winston.error('[analytics] Encountered error while writing analytics to data store', err.stack);throw err;}};diff --git a/src/cli/manage.js b/src/cli/manage.jsindex 3eeb0d0686..de250ce4aa 100644--- a/src/cli/manage.js+++ b/src/cli/manage.js@@ -85,7 +85,7 @@ function activate(plugin) {},], function (err) {if (err) {- winston.error('An error occurred during plugin activation', err);+ winston.error('An error occurred during plugin activation', err.stack);throw err;}process.exit(0);@@ -219,7 +219,7 @@ function info() {function buildWrapper(targets, options) {build.build(targets, options, function (err) {if (err) {- winston.error(err);+ winston.error(err.stack);process.exit(1);}process.exit(0);diff --git a/src/cli/reset.js b/src/cli/reset.jsindex ad3cd1b2c3..e913de916c 100644--- a/src/cli/reset.js+++ b/src/cli/reset.js@@ -141,7 +141,7 @@ async function resetPlugin(pluginId) {throw new Error('plugin-not-active');}} catch (err) {- winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s', err);+ winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s', err.stack);throw err;}}diff --git a/src/cli/setup.js b/src/cli/setup.jsindex 897356b945..4c8ff06188 100644--- a/src/cli/setup.js+++ b/src/cli/setup.js@@ -51,7 +51,7 @@ function setup(initConfig) {console.log('\n' + separator + '\n');if (err) {- winston.error('There was a problem completing NodeBB setup', err);+ winston.error('There was a problem completing NodeBB setup', err.stack);throw err;} else {if (data.hasOwnProperty('password')) {diff --git a/src/controllers/admin/dashboard.js b/src/controllers/admin/dashboard.jsindex 73c50e468f..bf9081ced9 100644--- a/src/controllers/admin/dashboard.js+++ b/src/controllers/admin/dashboard.js@@ -67,10 +67,9 @@ async function getNotices() {async function getLatestVersion() {try {- const result = await versions.getLatestVersion();- return result;+ return await versions.getLatestVersion();} catch (err) {- winston.error('[acp] Failed to fetch latest version', err);+ winston.error('[acp] Failed to fetch latest version', err.stack);}return null;}diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.jsindex 4c1182e6f7..87f808a2e5 100644--- a/src/controllers/admin/info.js+++ b/src/controllers/admin/info.js@@ -52,7 +52,7 @@ pubsub.on('sync:node:info:start', async function () {data.id = os.hostname() + ':' + nconf.get('port');pubsub.publish('sync:node:info:end', { data: data, id: data.id });} catch (err) {- winston.error(err);+ winston.error(err.stack);}});@@ -99,7 +99,7 @@ async function getGitInfo() {function get(cmd, callback) {exec(cmd, function (err, stdout) {if (err) {- winston.error(err);+ winston.error(err.stack);}callback(null, stdout ? stdout.replace(/\n$/, '') : 'no-git-info');});diff --git a/src/controllers/admin/logs.js b/src/controllers/admin/logs.jsindex bbdd20cca8..51ed116eca 100644--- a/src/controllers/admin/logs.js+++ b/src/controllers/admin/logs.js@@ -12,7 +12,7 @@ logsController.get = async function (req, res) {try {logs = await meta.logs.get();} catch (err) {- winston.error(err);+ winston.error(err.stack);}res.render('admin/advanced/logs', {data: validator.escape(logs),diff --git a/src/controllers/admin/plugins.js b/src/controllers/admin/plugins.jsindex 4bfefff5b4..6467f27b49 100644--- a/src/controllers/admin/plugins.js+++ b/src/controllers/admin/plugins.js@@ -52,7 +52,7 @@ async function getPlugins(matching) {const pluginsData = await plugins.list(matching);return pluginsData || [];} catch (err) {- winston.error(err);+ winston.error(err.stack);return [];}}diff --git a/src/controllers/topics.js b/src/controllers/topics.jsindex 33f048b853..758650d75c 100644--- a/src/controllers/topics.js+++ b/src/controllers/topics.js@@ -143,7 +143,7 @@ function markAsRead(req, tid) {if (req.loggedIn) {topics.markAsRead([tid], req.uid, function (err, markedRead) {if (err) {- return winston.error(err);+ return winston.error(err.stack);}if (markedRead) {topics.pushUnreadCount(req.uid);diff --git a/src/database/postgres/pubsub.js b/src/database/postgres/pubsub.jsindex 3b9d03f007..4a3f280936 100644--- a/src/database/postgres/pubsub.js+++ b/src/database/postgres/pubsub.js@@ -13,13 +13,13 @@ const PubSub = function () {subClient.connect(function (err) {if (err) {- winston.error(err);+ winston.error(err.stack);return;}subClient.query('LISTEN pubsub', function (err) {if (err) {- winston.error(err);+ winston.error(err.stack);}});diff --git a/src/database/redis.js b/src/database/redis.jsindex c235712ef0..82a6eead47 100644--- a/src/database/redis.js+++ b/src/database/redis.js@@ -40,7 +40,7 @@ redisModule.init = function (callback) {callback = callback || function () { };redisModule.client = connection.connect(nconf.get('redis'), function (err) {if (err) {- winston.error('NodeBB could not connect to your Redis database. Redis returned the following error', err);+ winston.error('NodeBB could not connect to your Redis database. Redis returned the following error', err.stack);return callback(err);}require('./redis/promisify')(redisModule.client);diff --git a/src/database/redis/connection.js b/src/database/redis/connection.jsindex 50ee98baa5..b291b1f284 100644--- a/src/database/redis/connection.js+++ b/src/database/redis/connection.js@@ -58,7 +58,7 @@ connection.connect = function (options, callback) {if (dbIdx >= 0) {cxn.select(dbIdx, function (err) {if (err) {- winston.error('NodeBB could not select Redis database. Redis returned the following error', err);+ winston.error('NodeBB could not select Redis database. Redis returned the following error', err.stack);throw err;}});diff --git a/src/emailer.js b/src/emailer.jsindex 2f7bb1e147..51211aa1ec 100644--- a/src/emailer.js+++ b/src/emailer.js@@ -193,7 +193,7 @@ Emailer.send = async function (template, uid, params) {try {await Emailer.sendToEmail(template, userData.email, userSettings.userLang, params);} catch (err) {- winston.error(err);+ winston.error(err.stack);}};@@ -286,7 +286,7 @@ Emailer.sendViaFallback = function (data, callback) {winston.verbose('[emailer] Sending email to uid ' + data.uid + ' (' + data.to + ')');Emailer.fallbackTransport.sendMail(data, function (err) {if (err) {- winston.error(err);+ winston.error(err.stack);}callback();});@@ -322,7 +322,7 @@ async function buildCustomTemplates(config) {Benchpress.flush();winston.verbose('[emailer] Built custom email templates');} catch (err) {- winston.error('[emailer] Failed to build custom email templates', err);+ winston.error('[emailer] Failed to build custom email templates', err.stack);}}diff --git a/src/flags.js b/src/flags.jsindex 890617fa99..6668895098 100644--- a/src/flags.js+++ b/src/flags.js@@ -78,7 +78,7 @@ Flags.init = async function () {const data = await plugins.fireHook('filter:flags.getFilters', hookData);Flags._filters = data.filters;} catch (err) {- winston.error('[flags/init] Could not retrieve filters', err);+ winston.error('[flags/init] Could not retrieve filters', err.stack);Flags._filters = {};}};diff --git a/src/groups/join.js b/src/groups/join.jsindex 1a64c3ca08..06519ce57b 100644--- a/src/groups/join.js+++ b/src/groups/join.js@@ -82,7 +82,7 @@ module.exports = function (Groups) {});} catch (err) {if (err && err.message !== '[[error:group-already-exists]]') {- winston.error('[groups.join] Could not create new hidden group', err);+ winston.error('[groups.join] Could not create new hidden group', err.stack);throw err;}}diff --git a/src/install.js b/src/install.jsindex 634e932fd3..78410e98fc 100644--- a/src/install.js+++ b/src/install.js@@ -607,7 +607,7 @@ install.save = function (server_conf, callback) {fs.writeFile(serverConfigPath, JSON.stringify(server_conf, null, 4), function (err) {if (err) {- winston.error('Error saving server configuration!', err);+ winston.error('Error saving server configuration!', err.stack);return callback(err);}diff --git a/src/logger.js b/src/logger.jsindex 632c9b84ca..9db812143d 100644--- a/src/logger.js+++ b/src/logger.js@@ -88,7 +88,7 @@ Logger.open = function (value) {if (stream) {stream.on('error', function (err) {- winston.error(err);+ winston.error(err.stack);});}} else {diff --git a/src/meta/build.js b/src/meta/build.jsindex a6315edeeb..392f541f8d 100644--- a/src/meta/build.js+++ b/src/meta/build.js@@ -114,7 +114,7 @@ function beforeBuild(targets, callback) {},], function (err) {if (err) {- winston.error('[build] Encountered error preparing for build', err);+ winston.error('[build] Encountered error preparing for build', err.stack);return callback(err);}@@ -218,7 +218,7 @@ exports.build = function (targets, options, callback) {},], function (err) {if (err) {- winston.error('[build] Encountered error during build step', err);+ winston.error('[build] Encountered error during build step', err.stack);return callback(err);}diff --git a/src/meta/configs.js b/src/meta/configs.jsindex da07f68fbd..c8794916d1 100644--- a/src/meta/configs.js+++ b/src/meta/configs.js@@ -44,7 +44,7 @@ function deserialize(config) {try {deserialized[key] = JSON.parse(config[key] || '[]');} catch (err) {- winston.error(err);+ winston.error(err.stack);deserialized[key] = defaults[key];}} else {diff --git a/src/meta/errors.js b/src/meta/errors.jsindex 43b92ba4b1..6aff66da17 100644--- a/src/meta/errors.js+++ b/src/meta/errors.js@@ -30,7 +30,7 @@ Errors.writeData = async function () {await db.sortedSetIncrBy('errors:404', _counters[key], key);}} catch (err) {- winston.error(err);+ winston.error(err.stack);}};diff --git a/src/middleware/render.js b/src/middleware/render.jsindex 1e9d20b0b0..a82bac03b5 100644--- a/src/middleware/render.js+++ b/src/middleware/render.js@@ -113,7 +113,7 @@ module.exports = function (middleware) {try {p = utils.slugify(decodeURIComponent(p));} catch (err) {- winston.error(err);+ winston.error(err.stack);p = '';}p = validator.escape(String(p));diff --git a/src/notifications.js b/src/notifications.jsindex 12482b0272..1b307cf9b6 100644--- a/src/notifications.js+++ b/src/notifications.js@@ -326,7 +326,7 @@ Notifications.prune = async function () {}, { batch: 500, interval: 100 });} catch (err) {if (err) {- winston.error('Encountered error pruning notifications', err);+ winston.error('Encountered error pruning notifications', err.stack);}}};diff --git a/src/plugins/data.js b/src/plugins/data.jsindex d127bd9bd5..76c780e8a6 100644--- a/src/plugins/data.js+++ b/src/plugins/data.js@@ -48,7 +48,7 @@ Data.loadPluginInfo = async function (pluginPath) {} catch (err) {var pluginDir = path.basename(pluginPath);- winston.error('[plugins/' + pluginDir + '] Error in plugin.json or package.json!', err);+ winston.error('[plugins/' + pluginDir + '] Error in plugin.json or package.json!', err.stack);throw new Error('[[error:parse-error]]');}return pluginData;diff --git a/src/plugins/index.js b/src/plugins/index.jsindex 1a04d7064a..9d5e93abce 100644--- a/src/plugins/index.js+++ b/src/plugins/index.js@@ -291,7 +291,7 @@ Plugins.showInstalled = async function () {pluginData.error = false;return pluginData;} catch (err) {- winston.error(err);+ winston.error(err.stack);}}const plugins = await Promise.all(pluginPaths.map(file => load(file)));diff --git a/src/plugins/usage.js b/src/plugins/usage.jsindex 1c1d86478f..78d95c3e35 100644--- a/src/plugins/usage.js+++ b/src/plugins/usage.js@@ -33,7 +33,7 @@ module.exports = function (Plugins) {timeout: 5000,}, function (err, res, body) {if (err) {- return winston.error(err);+ return winston.error(err.stack);}if (res.statusCode !== 200) {winston.error('[plugins.submitUsageData] received ' + res.statusCode + ' ' + body);diff --git a/src/socket.io/admin/user.js b/src/socket.io/admin/user.jsindex e9a7994ee3..fde65426cd 100644--- a/src/socket.io/admin/user.js+++ b/src/socket.io/admin/user.js@@ -173,7 +173,7 @@ async function deleteUsers(socket, uids, method) {try {await Promise.all(uids.map(uid => doDelete(uid)));} catch (err) {- winston.error(err);+ winston.error(err.stack);}}diff --git a/src/start.js b/src/start.jsindex 0be889173f..687168f2ac 100644--- a/src/start.js+++ b/src/start.js@@ -113,7 +113,7 @@ function addProcessHandlers() {process.on('SIGINT', shutdown);process.on('SIGHUP', restart);process.on('uncaughtException', function (err) {- winston.error(err);+ winston.error(err.stack);require('./meta').js.killMinifier();shutdown(1);diff --git a/src/user/digest.js b/src/user/digest.jsindex cebabccf29..90b85bc038 100644--- a/src/user/digest.js+++ b/src/user/digest.js@@ -35,7 +35,7 @@ Digest.execute = async function (payload) {});winston.info('[user/jobs] Digest (' + payload.interval + ') scheduling completed. Sending emails; this may take some time...');} catch (err) {- winston.error('[user/jobs] Could not send digests (' + payload.interval + ')', err);+ winston.error('[user/jobs] Could not send digests (' + payload.interval + ')', err.stack);throw err;}};@@ -139,7 +139,7 @@ Digest.send = async function (data) {showUnsubscribe: true,});} catch (err) {- winston.error('[user/jobs] Could not send digest email', err);+ winston.error('[user/jobs] Could not send digest email', err.stack);}if (data.interval !== 'alltime') {diff --git a/src/user/notifications.js b/src/user/notifications.jsindex fa30b0e2e1..fe22127c5a 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -190,7 +190,7 @@ UserNotifications.sendTopicNotificationToFollowers = async function (uid, topicDawait notifications.push(notifObj, followers);} catch (err) {- winston.error(err);+ winston.error(err.stack);}};diff --git a/src/webserver.js b/src/webserver.jsindex 3b2e0b8cd2..77f0d4b474 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -48,9 +48,9 @@ module.exports.app = app;server.on('error', function (err) {if (err.code === 'EADDRINUSE') {- winston.error('NodeBB address in use, exiting...', err);+ winston.error('NodeBB address in use, exiting...', err.stack);} else {- winston.error(err);+ winston.error(err.stack);}throw err;@@ -265,7 +265,7 @@ function listen(callback) {oldUmask = process.umask('0000');module.exports.testSocket(socketPath, function (err) {if (err) {- winston.error('[startup] NodeBB was unable to secure domain socket access (' + socketPath + ')', err);+ winston.error('[startup] NodeBB was unable to secure domain socket access (' + socketPath + ')', err.stack);throw err;}