fix(protocol): stop flooding logs when disk writes fail
After identity persistence is suspended, later observations were still logged one-by-one. That filled Docker logs and made the WebUI log stream unusable while the bot kept receiving messages. Report the skip once, then at most once a minute with a count. Console write failures must not throw into message handling.
This commit is contained in:
5 files changed
+64
-4
No files matched your search
@@ -506,7 +506,13 @@ class FileWriter {
|
||||
}
|
||||
|
||||
if (!this.quota.reserve(this.file.path, bytes)) return false;
|
||||
this.file.stream.write(data);
|
||||
try {
|
||||
this.file.stream.write(data);
|
||||
} catch (error) {
|
||||
this.disabled = true;
|
||||
this.quota.writeFailed(this.file.path, error);
|
||||
return false;
|
||||
}
|
||||
this.file.bytes += bytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,13 @@ function emit(
|
||||
// and ESC (0x1B) so multi-line records (stack traces) and ANSI color
|
||||
// sequences emitted by render() pass through intact.
|
||||
// eslint-disable-next-line no-control-regex
|
||||
stream.write(line.replace(/[\x00-\x08\x0B-\x1A\x1C-\x1F\x7F]/g, '') + '\n');
|
||||
const consoleLine = line.replace(/[\x00-\x08\x0B-\x1A\x1C-\x1F\x7F]/g, '') + '\n';
|
||||
try {
|
||||
stream.write(consoleLine);
|
||||
} catch {
|
||||
// A full Docker json-file log volume can make stdout/stderr throw.
|
||||
// Logging must not take down message handling or the WebUI.
|
||||
}
|
||||
}
|
||||
|
||||
// File transport sees levels >= currentFileLevel (SNOWLUMA_LOG_FILE_LEVEL,
|
||||
|
||||
Reference in new issue
Block a user