I'm making an app in Node JS (or actually Node-Webkit) that plays images and video that is periodically downloaded. However, sometimes during download I get connection-errorince which look like this:
AssertionError: null == true
at TLSSocket.socketOnData (_http_client.js:270:3)
at TLSSocket.EventEmitter.emit (events.js:98:17)
at readableAddChunk (_stream_readable.js:156:16)
at TLSSocket.Readable.push (_stream_readable.js:123:10)
at TCP.onread (net.js:509:20)
This is a problem in itself, which I would love to solve, but I think this will be hard/impossible/out of scope and maybe I just need to handle it. I now wrap my connections in a domain and log the errors and then call domain.dispose:
var self = this;
this.domain.on("error", function (err) {
log.error(err, "connection error, file: " + self.filename); //my own errorlogger
self.domain.dispose();
});
I am able to restart the whole application, but I don't want to do this because it would interrupt the playing of the downloaded files (ie. a playlist). But what happens if I don't do that is that there is a memory-leak which of course gets bigger and then makes the whole application crash (eventually).
Since domain.dispose() doesn't really work, how do I handle errors of this kind so they don't make my app crash (without interrupting the other tasks) ?