MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / persistSync

Method persistSync

src/telemetry/index.ts:387–396  ·  view source on GitHub ↗

* Synchronous, tiny, exit-safe: drain in-memory deltas to the JSONL queue. * Runs on `process.on('exit')`, so it must never be async or slow.

()

Source from the content-addressed store, hash-verified

385 * Runs on `process.on('exit')`, so it must never be async or slow.
386 */
387 persistSync(): void {
388 if (this.counts.size === 0 && this.events.length === 0) return;
389 const lines: BufferLine[] = [...this.counts.values(), ...this.events];
390 this.counts.clear();
391 this.events = [];
392 // Re-check at persist time: `codegraph telemetry off` mid-process must not
393 // have its own invocation resurrect the queue file at exit.
394 if (!this.isEnabled()) return;
395 this.appendLines(lines);
396 }
397
398 private appendLines(lines: BufferLine[]): void {
399 try {

Callers 3

flushNowMethod · 0.95
registerForExitFunction · 0.80
telemetry.test.tsFile · 0.80

Calls 3

isEnabledMethod · 0.95
appendLinesMethod · 0.95
clearMethod · 0.45

Tested by

no test coverage detected