MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / retryDiskEvents

Method retryDiskEvents

packages/telemetry/src/transport.ts:124–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122 }
123
124 async retryDiskEvents(): Promise<void> {
125 let entries: string[];
126 try {
127 entries = readdirSync(this.telemetryDir());
128 } catch {
129 return;
130 }
131
132 const now = this.now();
133 for (const entry of entries) {
134 if (!entry.startsWith('failed_') || !entry.endsWith('.jsonl')) continue;
135 const path = join(this.telemetryDir(), entry);
136 try {
137 const stat = statSync(path);
138 if (now - stat.mtimeMs > DISK_EVENT_MAX_AGE_MS) {
139 unlinkSync(path);
140 continue;
141 }
142 } catch {
143 continue;
144 }
145
146 let events: EnrichedTelemetryEvent[];
147 let payload: TelemetryPayload;
148 try {
149 events = readJsonl(path);
150 payload = buildPayload(events, this.deviceId);
151 } catch (error) {
152 if (error instanceof SyntaxError || error instanceof TypeError) {
153 try {
154 unlinkSync(path);
155 } catch {
156 // best effort cleanup.
157 }
158 }
159 continue;
160 }
161
162 try {
163 await this.sendHttp(payload);
164 unlinkSync(path);
165 } catch (error) {
166 if (error instanceof TransientTelemetryError) continue;
167 }
168 }
169 }
170
171 private async sendHttp(payload: TelemetryPayload, signal?: AbortSignal): Promise<void> {
172 const token = this.getAccessToken === null ? null : await this.getAccessToken();

Callers

nothing calls this directly

Calls 5

telemetryDirMethod · 0.95
sendHttpMethod · 0.95
readJsonlFunction · 0.85
buildPayloadFunction · 0.85
nowMethod · 0.65

Tested by

no test coverage detected