From 617f6afdd85bc8d713a6c9169dfd1cedcc717698 Mon Sep 17 00:00:00 2001 From: t123yh Date: Thu, 24 Aug 2017 23:20:12 +0800 Subject: [PATCH] Do not crash on join errors. --- src/frontend-syzoj/socketio.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frontend-syzoj/socketio.ts b/src/frontend-syzoj/socketio.ts index dc71b30..bc4efc4 100644 --- a/src/frontend-syzoj/socketio.ts +++ b/src/frontend-syzoj/socketio.ts @@ -133,18 +133,18 @@ export function initializeSocketIO(s: http.Server) { throw new Error("Request type in token mismatch."); } clientDisplayConfigList[socket.id] = req.displayConfig; + const taskId = req.taskId; + winston.verbose(`A client trying to join ${name} namespace for ${taskId}.`); + socket.join(taskId.toString()); + exec(req, socket).then(x => cb(x), err => cb({ ok: false, message: err.toString() })); } catch (err) { - winston.info('The client has an incorrect token.'); + winston.info('Error while joining.'); cb({ ok: false, message: err.toString() }); return; } - const taskId = req.taskId; - winston.verbose(`A client trying to join ${name} namespace for ${taskId}.`); - socket.join(taskId.toString()); - exec(req, socket).then(x => cb(x), err => cb({ ok: false, message: err.toString() })); }); }); return newNamespace;