From: Chocobozzz Date: Fri, 9 Feb 2018 12:15:40 +0000 (+0100) Subject: Fix crash with websocket tracker X-Git-Tag: v0.0.23-alpha~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1e9d7b60cd93ad5d1aed47fd157f1993d4b4eac0;p=oweals%2Fpeertube.git Fix crash with websocket tracker --- diff --git a/server.ts b/server.ts index 8f280f6c2..dc7a71d60 100644 --- a/server.ts +++ b/server.ts @@ -104,11 +104,11 @@ const trackerServer = new TrackerServer({ }) trackerServer.on('error', function (err) { - logger.error(err) + logger.error('Error in websocket tracker.', err) }) trackerServer.on('warning', function (err) { - logger.error(err) + logger.error('Warning in websocket tracker.', err) }) const server = http.createServer(app) @@ -116,7 +116,6 @@ const wss = new WebSocketServer({ server: server, path: '/tracker/socket' }) wss.on('connection', function (ws) { trackerServer.onWebSocketConnection(ws) }) -wss.on('error', err => logger.error('Error in websocket server.', err)) const onHttpRequest = trackerServer.onHttpRequest.bind(trackerServer) app.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { action: 'announce' })) diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 7624b3cff..201ea2235 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts @@ -26,12 +26,12 @@ const loggerFormat = winston.format.printf((info) => { if (additionalInfos === '{}') additionalInfos = '' else additionalInfos = ' ' + additionalInfos - if (info.message.stack !== undefined) info.message = info.message.stack + if (info.message && info.message.stack !== undefined) info.message = info.message.stack return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` }) const timestampFormatter = winston.format.timestamp({ - format: 'YYYY-MM-DD hh:mm:ss.SSS' + format: 'YYYY-MM-dd HH:mm:ss.SSS' }) const labelFormatter = winston.format.label({ label