Skip to content

Commit c96a65d

Browse files
committed
Ensure timer is only marked inactive after flushHook executes
1 parent 53f0acb commit c96a65d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/core/src/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ function setupWeightBasedFlushing<
131131
flushFn(client);
132132
} else if (!isTimerActive) {
133133
// Only start timer if one isn't already running.
134-
// This prevents flushing being delayed by logs that arrive close to the timeout limit
135-
// and thus resetting the flushing timeout and delaying logs being flushed.
134+
// This prevents flushing being delayed by items that arrive close to the timeout limit
135+
// and thus resetting the flushing timeout and delaying items being flushed.
136136
isTimerActive = true;
137137
flushTimeout = setTimeout(() => {
138138
flushFn(client);
139-
isTimerActive = false;
139+
// Note: isTimerActive is reset by the flushHook handler above, not here,
140+
// to avoid race conditions when new items arrive during the flush.
140141
}, DEFAULT_FLUSH_INTERVAL);
141142
}
142143
});

0 commit comments

Comments
 (0)