mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: display stack trace on winston.error
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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 [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ Logger.open = function (value) {
|
||||
|
||||
if (stream) {
|
||||
stream.on('error', function (err) {
|
||||
winston.error(err);
|
||||
winston.error(err.stack);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -190,7 +190,7 @@ UserNotifications.sendTopicNotificationToFollowers = async function (uid, topicD
|
||||
|
||||
await notifications.push(notifObj, followers);
|
||||
} catch (err) {
|
||||
winston.error(err);
|
||||
winston.error(err.stack);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user