Fix stuck flushScheduled flag and permanent failedSegments in EventNdjsonLogger
Bug 1: The flushScheduled flag could become stuck true if scheduleFlush() failed or was interrupted, preventing future timer-based flushes for low-volume threads. Fix: always clear flushScheduled after any drain, and reset the flag on schedule failure via catchCause. Bug 2: A single transient I/O error permanently added a thread segment to failedSegments, silencing all future logging for that thread. Fix: start each drain with a fresh failedSegments set so transient errors don't block subsequent flush attempts.
This commit is contained in:
1 file changed
+10
-3
@@ -318,7 +318,7 @@ function drainPending(input: {
|
||||
}
|
||||
|
||||
const sinks = new Map(input.state.sinks);
|
||||
const failedSegments = new Set(input.state.failedSegments);
|
||||
const failedSegments = new Set<string>();
|
||||
const failures: Array<FileOperationFailure> = [];
|
||||
const attributionByStream = new Map<
|
||||
EventNdjsonStream,
|
||||
@@ -399,7 +399,7 @@ function drainPending(input: {
|
||||
pendingBytes: 0,
|
||||
sinks,
|
||||
failedSegments,
|
||||
flushScheduled: input.timerFired ? false : input.state.flushScheduled,
|
||||
flushScheduled: false,
|
||||
closed: input.close,
|
||||
lastRetentionAt: retentionDue ? input.now : input.state.lastRetentionAt,
|
||||
},
|
||||
@@ -557,7 +557,14 @@ export const makeEventNdjsonLogStore = Effect.fnUntraced(function* (
|
||||
if (action.flush) {
|
||||
yield* flush(false, false);
|
||||
} else if (action.schedule) {
|
||||
yield* scheduleFlush();
|
||||
yield* scheduleFlush().pipe(
|
||||
Effect.catchCause(() =>
|
||||
SynchronizedRef.update(stateRef, (state) => ({
|
||||
...state,
|
||||
flushScheduled: false,
|
||||
})),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user