Added some additional error handlers to get a better grip on connection issues

Summary: I think it is good to have error handlers where-ever possible, so that there is historical data in our monitoring when we need it, and can track from which point of the code it originates :)

Reviewed By: jknoxville

Differential Revision: D21040059

fbshipit-source-id: 1c07fbfa65379739554bc98f83761ae97870ba82
This commit is contained in:
Michel Weststrate
2020-04-17 05:00:29 -07:00
committed by Facebook GitHub Bot
parent 2d68006e3f
commit a5e5ed5b7b
2 changed files with 9 additions and 2 deletions

View File

@@ -174,6 +174,9 @@ export default class Client extends EventEmitter {
onSubscribe(subscription) {
subscription.request(Number.MAX_SAFE_INTEGER);
},
onError(payload) {
console.error('[client] connection status error ', payload);
},
});
}
}

View File

@@ -230,7 +230,8 @@ class Server extends EventEmitter {
cleanup();
});
ws.on('error', () => {
ws.on('error', (error) => {
console.error('[server] ws connection error ', error);
cleanup();
});
});
@@ -265,7 +266,7 @@ class Server extends EventEmitter {
onNext(payload) {
if (payload.kind == 'ERROR' || payload.kind == 'CLOSED') {
client.then((client) => {
console.debug(`Device disconnected ${client.id}`, 'server');
console.log(`Device disconnected ${client.id}`, 'server', payload);
server.removeConnection(client.id);
});
}
@@ -273,6 +274,9 @@ class Server extends EventEmitter {
onSubscribe(subscription) {
subscription.request(Number.MAX_SAFE_INTEGER);
},
onError(error) {
console.error('[server] connection status error ', error);
},
});
return {