Skip to content

Commit 757955e

Browse files
committed
fix(CLI-BH): deduplicate trace logs missing timestamp_precise in follow mode
When timestamp_precise is absent, use a Set of seen log IDs to prevent the same logs from being re-displayed on every poll cycle. Logs with timestamp_precise still use the fast numeric comparison.
1 parent 06c7183 commit 757955e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/commands/log/list.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ export const listCommand = buildListCommand("log", {
452452

453453
if (flags.follow) {
454454
const traceId = flags.trace;
455+
// Track IDs of logs seen without timestamp_precise so they are
456+
// shown once but not duplicated on subsequent polls.
457+
const seenWithoutTs = new Set<string>();
455458
await executeFollowMode({
456459
stdout,
457460
stderr,
@@ -465,11 +468,17 @@ export const listCommand = buildListCommand("log", {
465468
statsPeriod,
466469
}),
467470
extractNew: (logs, lastTs) =>
468-
logs.filter(
469-
(l) =>
470-
l.timestamp_precise === undefined ||
471-
l.timestamp_precise > lastTs
472-
),
471+
logs.filter((l) => {
472+
if (l.timestamp_precise !== undefined) {
473+
return l.timestamp_precise > lastTs;
474+
}
475+
// No precise timestamp — deduplicate by id
476+
if (seenWithoutTs.has(l.id)) {
477+
return false;
478+
}
479+
seenWithoutTs.add(l.id);
480+
return true;
481+
}),
473482
});
474483
} else {
475484
await executeTraceSingleFetch(stdout, org, flags.trace, flags);

0 commit comments

Comments
 (0)