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
@@ -589,6 +589,23 @@ describe('IdentityService', () => {
|
||||
lastError: expect.stringMatching(/locked/i),
|
||||
lastFailureAt: suspendedFailureAt,
|
||||
});
|
||||
const skipLogsBeforeBurst = seen.filter((entry) =>
|
||||
/persistence write skipped/.test(entry.message),
|
||||
).length;
|
||||
expect(skipLogsBeforeBurst).toBe(1);
|
||||
for (let i = 0; i < 50; i += 1) {
|
||||
identity.rememberRequestIdentity({
|
||||
uid: `u_skip_burst_${i}`,
|
||||
uin: 500_000 + i,
|
||||
});
|
||||
}
|
||||
expect(seen.filter((entry) => /persistence write skipped/.test(entry.message)))
|
||||
.toHaveLength(1);
|
||||
await vi.advanceTimersByTimeAsync(60_000);
|
||||
identity.rememberRequestIdentity({ uid: 'u_skip_after_minute', uin: 600_000 });
|
||||
const skipLogs = seen.filter((entry) => /persistence write skipped/.test(entry.message));
|
||||
expect(skipLogs).toHaveLength(2);
|
||||
expect(skipLogs[1]?.message).toMatch(/suppressed=50/);
|
||||
|
||||
releaseLock();
|
||||
identity.close();
|
||||
|
||||
Reference in new issue
Block a user