mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-09 15:02:30 +02:00
`writeBridgeAtomic` wrote to a fixed `${target}.tmp` path before
calling `renameSync`. When two processes write to the same session
bridge concurrently (e.g. PostToolUse `ecc-metrics-bridge` + the
background `ecc-statusline`, both calling `writeBridgeAtomic(sessionId, ...)`),
the canonical atomic-rename race fires:
1. Process A: writeFileSync(target.tmp, JSON_A) — tmp file exists.
2. Process B: writeFileSync(target.tmp, JSON_B) — tmp file overwritten.
3. Process A: renameSync(target.tmp, target) — succeeds; target = JSON_B
(A's payload silently corrupted en-route).
4. Process B: renameSync(target.tmp, target) — throws ENOENT (the
rename consumed the file).
Every caller in the repo wraps `writeBridgeAtomic` in `try {} catch {}`,
so the ENOENT exception is swallowed and the user-visible symptom is
just "the bridge file occasionally contains the wrong process's
payload" with no diagnostic.
Reproduced before this commit:
$ # two concurrent writers, each calling writeBridgeAtomic 500 times
$ # against the same session ID
[A] errors=244 # 244 ENOENT exceptions swallowed
[B] errors=248 # ditto
After this commit the same workload reports 0 errors in both
subprocesses: tmp paths no longer collide.
Fix: change `${target}.tmp` to
`${target}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`,
matching the pattern already used by `writeCostWarningIfChanged` in
`scripts/hooks/ecc-metrics-bridge.js` (commit
|
||
|---|---|---|
| .. | ||
| ci | ||
| codemaps | ||
| codex | ||
| codex-git-hooks | ||
| hooks | ||
| lib | ||
| auto-update.js | ||
| build-opencode.js | ||
| catalog.js | ||
| claw.js | ||
| consult.js | ||
| discussion-audit.js | ||
| doctor.js | ||
| ecc.js | ||
| gan-harness.sh | ||
| gemini-adapt-agents.js | ||
| harness-adapter-compliance.js | ||
| harness-audit.js | ||
| install-apply.js | ||
| install-plan.js | ||
| list-installed.js | ||
| loop-status.js | ||
| observability-readiness.js | ||
| operator-readiness-dashboard.js | ||
| orchestrate-codex-worker.sh | ||
| orchestrate-worktrees.js | ||
| orchestration-status.js | ||
| platform-audit.js | ||
| preview-pack-smoke.js | ||
| release.sh | ||
| repair.js | ||
| session-inspect.js | ||
| sessions-cli.js | ||
| setup-package-manager.js | ||
| skill-create-output.js | ||
| skills-health.js | ||
| status.js | ||
| sync-ecc-to-codex.sh | ||
| uninstall.js | ||
| work-items.js | ||