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

Function emulateCreate

packages/node-sdk/examples/t8-race-direct.ts:35–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33const delayMs = Number(process.argv[6] ?? '0');
34
35async function emulateCreate(): Promise<void> {
36 const sessionsDir = join(homeDir, 'sessions');
37 // Step 1: check index
38 const idx = await readIndexLocal(homeDir);
39 const present = idx.has(sessionId);
40 console.log(JSON.stringify({ label, step: 'check', present, pid: process.pid, t: Date.now() }));
41 if (present) {
42 console.log(JSON.stringify({ label, step: 'reject', pid: process.pid }));
43 return;
44 }
45 // Step 2: simulate "isDirectory" check + mkdir gap
46 const dir = join(sessionsDir, 'wd_dummy', sessionId);
47 // recursive mkdir is non-fatal if exists
48 if (delayMs > 0) {
49 await new Promise<void>((resolve) => {
50 setTimeout(resolve, delayMs);
51 });
52 }
53 await mkdir(dir, { recursive: true, mode: 0o700 });
54 // Step 3: append index
55 await appendIndexLocal(homeDir, { sessionId, sessionDir: dir, workDir });
56 console.log(JSON.stringify({ label, step: 'append', pid: process.pid, t: Date.now() }));
57}
58
59await emulateCreate();
60process.exit(0);

Callers 1

t8-race-direct.tsFile · 0.85

Calls 6

readIndexLocalFunction · 0.85
appendIndexLocalFunction · 0.85
hasMethod · 0.65
logMethod · 0.65
nowMethod · 0.65
mkdirFunction · 0.50

Tested by

no test coverage detected