Skip to content

[bug] Bridge: необработанный EPIPE при раннем закрытии stdin hook #2668

Closed

Description

@Hoyass

Version

LifeOS 8.761.0 · attestation: 258 system file(s) differ from danielmiessler/LifeOS@v8.761.0 · 44 system file(s) missing:

  • hooks/TurnOutcome.hook.ts
  • hooks/DriftReminder.hook.ts
  • hooks/VerificationGate.hook.ts
  • hooks/MemoryIndexRefresh.hook.ts
  • hooks/SatisfactionCapture.hook.ts
  • hooks/MemoryDeltaSurface.hook.ts
  • hooks/lib/response-cache.ts
  • hooks/lib/label-redact.ts
  • hooks/lib/egress-shapes.ts
  • hooks/lib/lane-rules.ts
  • hooks/WorkCompletionLearning.hook.ts
  • hooks/AlgorithmNudge.hook.ts
  • hooks/LastResponseCache.hook.ts
  • hooks/FormatGate.hook.ts
  • hooks/EventLogger.hook.ts
  • hooks/MemoryReviewFire.hook.ts
  • hooks/handlers/UpdateCounts.ts
  • hooks/handlers/TabState.ts
  • skills/Prioritize/Tools/Prioritize.ts
  • skills/Upgrade/Setup.md
  • skills/Upgrade/SKILL.md
  • skills/Upgrade/Intents/Upgrade.md
  • skills/AudioEditor/Tools/Transcribe.ts
  • skills/LifeOSHooks/hooks/lib/egress-shapes.ts
  • skills/LifeOSHooks/hooks/LifeOSHooks.ts
  • skills/Interceptor/Tools/VerifyViewport.ts
  • commands/context-search.md
  • commands/lu.md
  • commands/teach-me.md
  • LIFEOS/TOOLS/SystemContext.ts
  • LIFEOS/TOOLS/CortexHealth.ts
  • LIFEOS/TOOLS/CoachReview.ts
  • LIFEOS/TOOLS/MemoryStatus.ts
  • LIFEOS/TOOLS/Upgrades.ts
  • LIFEOS/TOOLS/IntegrityCheck.ts
  • LIFEOS/TOOLS/com.lifeos.coach.plist.template
  • LIFEOS/TOOLS/ReferenceCheck.ts
  • LIFEOS/TOOLS/Inference.ts
  • LIFEOS/TOOLS/WorkSweep.ts
  • LIFEOS/TOOLS/MemoryRetriever.ts
  • …and 218 more

What is broken

Общий мост Codex падает с необработанным EPIPE, если командный hook закрывает stdin до завершения записи JSON. Это происходит как в runCommandHook, так и в spawnDetached: try/catch вокруг stdin.end не перехватывает асинхронное событие error. Ошибка может прийти после завершения Promise, поэтому результат проверялся по коду выхода дочернего процесса. Ошибка воспроизведена на чистом публичном исходнике danielmiessler/LifeOS, commit f6ab5e0; настройки и hooks личной установки в пробе не используются. Три контрольных прогона завершились с EPIPE. После двух обработчиков stdin.error три прогона дают 7 pass / 0 fail; отдельно сохранены exit 2, JSON deny, decision:block и continue:false. Метаданные версии и attestation ниже описывают локальную установку инструмента Report, а воспроизведение относится к указанному публичному commit.

Where (file:line)

LifeOS/install/LIFEOS/CODEX/Bridge.ts:313-340 — runCommandHook и spawnDetached

Repro on a clean tree

git clone https://github.com/danielmiessler/LifeOS.git
cd LifeOS
git checkout f6ab5e0
bun --no-env-file -e '
import { runCommandHook, spawnDetached } from "./LifeOS/install/LIFEOS/CODEX/Bridge.ts";
const input = { cwd: process.cwd(), padding: "x".repeat(512 * 1024) };
const env = { PATH: process.env.PATH ?? "/usr/bin:/bin" };
await runCommandHook({ type: "command", command: "exec 0<&-; sleep 0.02" }, input, env, 2000);
spawnDetached({ type: "command", command: "exec 0<&-; sleep 0.02" }, input, env);
await Bun.sleep(200);
console.log("hook stdin: success");
'

Ожидается: оба hook завершаются без падения процесса моста.
Фактически: процесс завершается с необработанным EPIPE; синхронный try/catch его не перехватывает.
Полная проверка в нашей изолированной пробе дополнительно запускает каждый случай в отдельном процессе, поскольку ошибка может возникнуть после завершения Promise.

Negative control

Probe: cd ~/Workspace/infra/lifeos-contrib-1042 && bun --no-env-file -e 'import {runCommandHook,spawnDetached} from "./LifeOS/install/LIFEOS/CODEX/Bridge.ts"; const input={cwd:process.cwd(),padding:"x".repeat(512*1024)}; const env={PATH:process.env.PATH??"/usr/bin:/bin"}; await runCommandHook({type:"command",command:"exec 0<&-; sleep 0.02"},input,env,2000); spawnDetached({type:"command",command:"exec 0<&-; sleep 0.02"},input,env); await Bun.sleep(200); console.log("hook stdin: success");' · exit 1 · captured 2026-11-08T09:23:25.895Z

Red looks like: EPIPE

hook stdin: success

--- stderr ---
45 |       return applyHandlers(handlers, emitter, args), !0;
46 |   }
47 |   let er;
48 |   if (args.length > 0)
49 |     er = args[0];
50 |     throw er;
                ^
error: EPIPE: broken pipe, write
      at emitError (node:events:50:13)
      at emitErrorNT (internal:streams/destroy:88:12)
      at emitErrorCloseNT (internal:streams/destroy:69:14)
45 |       return applyHandlers(handlers, emitter, args), !0;
46 |   }
47 |   let er;
48 |   if (args.length > 0)
49 |     er = args[0];
50 |     throw er;
                ^
error: EPIPE: broken pipe, write
      at emitError (node:events:50:13)
      at emitErrorNT (internal:streams/destroy:88:12)
      at emitErrorCloseNT (internal:streams/destroy:69:14)

Bun v1.4.4 (macOS arm64)

Suggested fix

Добавить обработчик события error к child.stdin до вызова end в runCommandHook и spawnDetached. Раннее закрытие входного потока hook не должно завершать процесс моста; результат выполнения hook и разбор его явного запрета остаются прежними. Подготовлен независимый минимальный патч и семь регрессионных проверок на синтетических данных. В этом первом сообщении публикуются воспроизведение и описание исправления; полный diff пока не отправляется.

Verified after fix

Probe: cd ~/Workspace/infra/lifeos-contrib-1042 && bun --no-env-file -e 'import {runCommandHook,spawnDetached} from "./LifeOS/install/LIFEOS/CODEX/Bridge.ts"; const input={cwd:process.cwd(),padding:"x".repeat(512*1024)}; const env={PATH:process.env.PATH??"/usr/bin:/bin"}; await runCommandHook({type:"command",command:"exec 0<&-; sleep 0.02"},input,env,2000); spawnDetached({type:"command",command:"exec 0<&-; sleep 0.02"},input,env); await Bun.sleep(200); console.log("hook stdin: success");' · exit 0 · captured 2026-11-08T09:23:53.318Z

hook stdin: success

Environment

  • OS: macOS 27.2 (arm64)
  • Harness: claude-code
  • bun: 1.4.4 · git: 2.54.0
  • Doctor broken: none

Activity

  1. danielmiessler commented on Nov 12, 2026

    @danielmiessler
    Owner

    Note

    🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

    Thanks @Hoyass, you found an unhandled EPIPE in the Bridge when a hook closes its stdin early. Both runCommandHook and spawnDetached now swallow the stdin error before ending the stream, in LIFEOS/CODEX/Bridge.ts. It ships in the next public release after 8.761.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions