fix(server): tokens of deleted accounts are refused; a failing message or fight can no longer crash the server
After a database reset an old (still signed) token made economy.load insert a save for a missing user; the FOREIGN KEY error escaped the WebSocket handler and took the process down in a restart loop.
This commit is contained in:
@@ -36,14 +36,14 @@ function attach(server, { lobby }) {
|
||||
clearTimeout(helloTimer);
|
||||
user = u;
|
||||
send({ t: 'welcome', uid: u.uid, name: u.name, serverTime: Date.now(), v: RC.Proto.VERSION });
|
||||
lobby.join({ uid: u.uid, name: u.name, admin: u.admin, send });
|
||||
try { lobby.join({ uid: u.uid, name: u.name, admin: u.admin, send }); } catch (e) { console.error('[ws] join failed', e); bye(1011, 'SERVER_ERROR'); }
|
||||
return;
|
||||
}
|
||||
if (msg.t === 'hello') return;
|
||||
lobby.handle(user.uid, msg);
|
||||
try { lobby.handle(user.uid, msg); } catch (e) { console.error('[ws] handler failed for', msg.t, e); send({ t: 'error', code: 'SERVER_ERROR' }); }
|
||||
});
|
||||
|
||||
ws.on('close', () => { clearTimeout(helloTimer); if (user) lobby.leave(user.uid, send); });
|
||||
ws.on('close', () => { clearTimeout(helloTimer); if (user) { try { lobby.leave(user.uid, send); } catch (e) { console.error('[ws] leave failed', e); } } });
|
||||
ws.on('error', () => {});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user