Skip to content

Commit

Permalink
Fix crash with websocket tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Feb 9, 2018
1 parent 53ac144 commit 1e9d7b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,18 @@ 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)
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' }))
Expand Down
4 changes: 2 additions & 2 deletions server/helpers/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1e9d7b6

Please sign in to comment.