MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / writeRunState

Function writeRunState

src/workflow/persistence.ts:46–63  ·  view source on GitHub ↗
(
  runsDir: string,
  run: RunProgress,
)

Source from the content-addressed store, hash-verified

44 * Failure is best-effort: IO exceptions only log a warn, do not throw (workflow already succeeded; persistence failure only means it cannot be retrieved after restart).
45 */
46export async function writeRunState(
47 runsDir: string,
48 run: RunProgress,
49): Promise<void> {
50 const dir = join(runsDir, run.runId)
51 const target = join(dir, STATE_FILE)
52 const tmp = join(dir, STATE_TMP)
53 const payload: StateFile = { schemaVersion: SCHEMA_VERSION, run }
54 try {
55 await mkdir(dir, { recursive: true })
56 await writeFile(tmp, JSON.stringify(payload), 'utf-8')
57 await rename(tmp, target)
58 } catch (e) {
59 logForDebugging(
60 `[workflow warn] writeRunState failed for ${run.runId}: ${(e as Error).message}`,
61 )
62 }
63}
64
65/**
66 * Read <runsDir>/<runId>/state.json with fault tolerance:

Callers 3

service.test.tsFile · 0.85

Calls 3

mkdirFunction · 0.85
renameFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected