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

Function installCrashHandlersForClient

packages/telemetry/src/crash.ts:19–46  ·  view source on GitHub ↗
(client: TelemetryClient)

Source from the content-addressed store, hash-verified

17}
18
19export function installCrashHandlersForClient(client: TelemetryClient): () => void {
20 if (installed && installedUncaughtHandler !== null) {
21 return () => {
22 uninstallCrashHandlers();
23 };
24 }
25 const trackCrash = (errorType: string, source: string) => {
26 try {
27 client.track('crash', {
28 error_type: errorType,
29 where: phase,
30 source,
31 });
32 client.flushSync();
33 } catch {
34 // Crash telemetry must never mask the original exception.
35 }
36 };
37 installedUncaughtHandler = (error, origin) => {
38 if (isAbortError(error)) return;
39 trackCrash(error.name || error.constructor.name, origin);
40 };
41 process.on('uncaughtExceptionMonitor', installedUncaughtHandler);
42 installed = true;
43 return () => {
44 uninstallCrashHandlers();
45 };
46}
47
48export function uninstallCrashHandlers(): void {
49 if (!installed) return;

Callers 2

telemetry.test.tsFile · 0.90
installCrashHandlersFunction · 0.85

Calls 4

uninstallCrashHandlersFunction · 0.85
trackCrashFunction · 0.85
isAbortErrorFunction · 0.70
onMethod · 0.65

Tested by

no test coverage detected