MCPcopy
hub / github.com/codeaashu/claude-code / periodicWrite

Function periodicWrite

src/utils/telemetry/perfettoTracing.ts:990–1005  ·  view source on GitHub ↗

* Write the full trace to disk. Errors are logged but swallowed so that a * transient I/O problem does not crash the session — the next periodic tick * (or the final exit write) will retry with a complete snapshot.

()

Source from the content-addressed store, hash-verified

988 * (or the final exit write) will retry with a complete snapshot.
989 */
990async function periodicWrite(): Promise<void> {
991 if (!isEnabled || !tracePath || traceWritten) return
992
993 try {
994 await mkdir(dirname(tracePath), { recursive: true })
995 await writeFile(tracePath, buildTraceDocument())
996 logForDebugging(
997 `[Perfetto] Periodic write: ${events.length} events to ${tracePath}`,
998 )
999 } catch (error) {
1000 logForDebugging(
1001 `[Perfetto] Periodic write failed: ${errorMessage(error)}`,
1002 { level: 'error' },
1003 )
1004 }
1005}
1006
1007/**
1008 * Final async write: close open spans and write the complete trace.

Callers 2

Calls 4

mkdirFunction · 0.85
buildTraceDocumentFunction · 0.85
logForDebuggingFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected