Track trampoline server/client errors separately

We don't need to close the server when the error comes from the client.
This commit is contained in:
Sergio Padrino 2021-03-11 13:56:27 +01:00
parent 5162e0c641
commit 3f4da2c8b9

View file

@ -66,7 +66,7 @@ export class TrampolineServer {
this.server.listen(0, '127.0.0.1', async () => {
// Replace the error handler
this.server.removeAllListeners('error')
this.server.on('error', this.onError)
this.server.on('error', this.onServerError)
resolve()
})
@ -126,7 +126,7 @@ export class TrampolineServer {
this.onDataReceived(socket, parser, data)
})
socket.on('error', this.onError)
socket.on('error', this.onClientError)
}
private onDataReceived(
@ -179,10 +179,14 @@ export class TrampolineServer {
}
}
private onError = (error: Error) => {
private onServerError = (error: Error) => {
sendNonFatalException('trampolineServer', error)
this.close()
}
private onClientError = (error: Error) => {
sendNonFatalException('trampolineClient', error)
}
}
export const trampolineServer = new TrampolineServer()