Client should throw when server unexpectedly closes the connection

Reviewed By: @natthu

Differential Revision: D2425357
This commit is contained in:
Amjad Masad
2015-09-09 16:30:22 -07:00
committed by facebook-github-bot-7
parent 3cfac35fd8
commit 9b27116798
3 changed files with 32 additions and 14 deletions

View File

@@ -59,7 +59,12 @@ class SocketServer {
const bunser = new bser.BunserBuf();
sock.on('data', (buf) => bunser.append(buf));
bunser.on('value', (m) => this._handleMessage(sock, m));
bunser.on('error', (e) => console.error(e));
bunser.on('error', (e) => {
e.message = 'Unhandled error from the bser buffer. ' +
'Either error on encoding or message handling: \n' +
e.message;
throw e;
});
}
_handleMessage(sock, m) {