Skip to content

Commit

Permalink
🐛 Increase error threshhold
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj committed Dec 29, 2019
1 parent 0a0cd3f commit 26466c7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/src/sockets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const socketIO = require('socket.io');

const {
MAX_ERROR_COUNT = 20
} = process.env;

module.exports = (server) => {
const io = socketIO(server);

Expand All @@ -24,8 +28,10 @@ module.exports = (server) => {
errors[socket.id] += 1;
socket.emit('update-error', message);
console.error(socket.id, message);
if (errors[socket.id] > 10) {
console.error(socket.id, 'Max error limit reached.', 'Disconnecting...');
if (errors[socket.id] > MAX_ERROR_COUNT) {
const error = 'Max error limit reached.';
socket.emit('update-error', error);
console.error(socket.id, error, 'Disconnecting...');
socket.disconnect(true);
}
};
Expand Down

0 comments on commit 26466c7

Please sign in to comment.