Catch and report cloud stream writing errors

If an error fires when writing to the cloud stream, it can stop any
calling processes from completing. Given that a logging failure should
not cause other processes to cancel, we catch and report the error but
otherwise do nothing else.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-09-17 14:41:37 +01:00
parent 7ef4880beb
commit 7d1da38184

View File

@ -203,8 +203,12 @@ export class BalenaLogBackend extends LogBackend {
}
if (this.writable) {
this.writable = this.stream.write(JSON.stringify(message) + '\n');
this.flush();
try {
this.writable = this.stream.write(JSON.stringify(message) + '\n');
this.flush();
} catch (e) {
log.error('Failed to write to logging stream, dropping message.', e);
}
} else {
this.dropCount += 1;
}