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

Function runTelemetryCrashScript

packages/telemetry/test/telemetry.test.ts:850–889  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

848}
849
850async function runTelemetryCrashScript(body: string): Promise<number> {
851 const dir = await tempHome();
852 const scriptPath = join(dir, 'crash-worker.ts');
853 const testDir = import.meta.dirname;
854 const tsxCli = join(
855 dirname(fileURLToPath(import.meta.resolve('tsx/package.json'))),
856 'dist/cli.mjs',
857 );
858 const crashModuleUrl = pathToFileURL(join(testDir, '../src/crash.ts')).href;
859 const clientModuleUrl = pathToFileURL(join(testDir, '../src/client.ts')).href;
860 writeFileSync(
861 scriptPath,
862 `
863 import { TelemetryClient } from ${JSON.stringify(clientModuleUrl)};
864 import { installCrashHandlersForClient } from ${JSON.stringify(crashModuleUrl)};
865
866 ${body}
867 `,
868 );
869
870 return new Promise((resolve, reject) => {
871 const child = spawn(process.execPath, [tsxCli, scriptPath], {
872 cwd: join(testDir, '../../..'),
873 stdio: ['ignore', 'ignore', 'pipe'],
874 });
875 let stderr = '';
876 child.stderr.setEncoding('utf8');
877 child.stderr.on('data', (chunk: string) => {
878 stderr += chunk;
879 });
880 child.on('error', reject);
881 child.on('close', (code) => {
882 if (code === null) {
883 reject(new Error(`Crash script exited without a code: ${stderr}`));
884 return;
885 }
886 resolve(code);
887 });
888 });
889}

Callers 1

telemetry.test.tsFile · 0.85

Calls 6

rejectFunction · 0.85
tempHomeFunction · 0.70
resolveMethod · 0.65
onMethod · 0.65
spawnFunction · 0.50
resolveFunction · 0.50

Tested by

no test coverage detected