* 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.
()
| 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 { |
no test coverage detected