Fix periodic rageshake log flush never running

The throttled flush callback returned this.flush instead of calling it
(regressed in #2607), so logs were only persisted to IndexedDB on
rageshake submission or beforeunload. When the host removes the widget
iframe at hangup, the whole call's logs were lost, so a rageshake filed
from a later call carries nothing from the affected one.
This commit is contained in:
Matthew Hodgson
2026-09-02 18:46:12 +01:00
parent efdee7dcdb
commit 2db24e2868

View File

@@ -204,10 +204,13 @@ class IndexedDBLogStore {
// Throttled function to flush logs. We use throttle rather // Throttled function to flush logs. We use throttle rather
// than debounce as we want logs to be written regularly, otherwise // than debounce as we want logs to be written regularly, otherwise
// if there's a constant stream of logging, we'd never write anything. // if there's a constant stream of logging, we'd never write anything.
private throttledFlush = throttle(() => this.flush, MAX_FLUSH_INTERVAL_MS, { private throttledFlush = throttle(
leading: false, () => {
trailing: true, this.flush().catch((e) => logger.error("Failed to flush logs", e));
}); },
MAX_FLUSH_INTERVAL_MS,
{ leading: false, trailing: true },
);
/** /**
* Flush logs to disk. * Flush logs to disk.