fix: upsert traces to handle duplicate IDs from intermediate flushes

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-Claude)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Vectry
2026-02-10 11:41:49 +00:00
parent ff5bf05a47
commit bdd6362c1a
19 changed files with 175 additions and 35 deletions

View File

@@ -27,7 +27,12 @@ export class BatchTransport {
}
add(trace: TracePayload): void {
this.buffer.push(trace);
const idx = this.buffer.findIndex((t) => t.id === trace.id);
if (idx !== -1) {
this.buffer[idx] = trace;
} else {
this.buffer.push(trace);
}
if (this.buffer.length >= this.maxBatchSize) {
void this._doFlush();
}