Desktop app crashes with RangeError: Invalid string length in main process during Chronicle initialization

Resolved 💬 3 comments Opened Jun 1, 2026 by resatu Closed Jun 1, 2026

Bug Report: Desktop app crashes with RangeError: Invalid string length in main process

Description

The Codex desktop application crashes with an uncaught exception in the main Electron process shortly after launch or during "Setting up Chronicle" / Computer Use initialization.

The crash occurs in the stdout/MCP message handler when processing data from the codex_chronicle sidecar (screen recording / visual activity / Computer Use feature).

Stack Trace

Uncaught Exception:
RangeError: Invalid string length
at Pd.write (/Applications/Codex.app/Contents/Resources/app.asar/.vite/build/src-DJzHq3CP.js:285:21)
at Socket.onStdoutData (/Applications/Codex.app/Contents/Resources/app.asar/.vite/build/src-DJzHq3CP.js:285:4145)
at Socket.emit (node:events:508:28)
at addChunk (node:internal/streams/readable:563:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:514:3)
at Readable.push (node:internal/streams/readable:394:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)

Steps to Reproduce

  1. Launch Codex desktop app (v26.527.31326 / recent build).
  2. The app begins "Setting up Chronicle" (visible in the UI).
  3. Crash dialog appears with the above error.
  4. Happens even when no chat/thread is open (on the main screen).
  5. Reproducible across multiple launches and after force-killing processes.

Observed Behavior

  • The main process crashes hard.
  • Chronicle (screen recording + OCR + visual evidence collection) generates large amounts of data.
  • This data is sent over stdout to the main process's MCP handler.
  • The handler (Pd.write / onStdoutData) performs operations that cause V8 to throw RangeError: Invalid string length (likely string concatenation or toString() on a very large buffer).

Expected Behavior

  • The app should not crash.
  • Chronicle / Computer Use should either work stably or be properly disabled without causing crashes during initialization.
  • Large stdout payloads from sidecars should be handled safely (streaming, chunking, or length limits).

Environment

  • App: Codex Desktop (OpenAI)
  • OS: macOS (Apple Silicon)
  • Version: Recent build (~26.527.31326)
  • Feature: Chronicle / Computer Use / screen recording enabled (or attempting to initialize)

Additional Context

  • The crash persists even after attempts to disable Chronicle via global state (chronicle-consent-accepted: false).
  • Background codex_chronicle and SkyComputerUseClient processes are highly active (constant screenshot capture + OCR).
  • Similar crashes have been observed tied to large lineBytes values (500MB+) in MCP messages in application logs (~/Library/Logs/com.openai.codex/).
  • Workarounds like repeatedly killing chronicle processes only delay the issue; the app re-initializes it on launch.

Suggested Fix Areas

  • Improve robustness of the stdout / MCP message handler in the main process (avoid unbounded string operations on large payloads).
  • Add proper size limits, streaming, or chunking for data coming from codex_chronicle.
  • Make the disable toggle for Computer Use / Chronicle more effective so it doesn't attempt initialization when disabled.
  • Better error handling around large sidecar output.

Logs

Relevant logs are in ~/Library/Logs/com.openai.codex/ (t0 main process logs show heavy chronicle activity with "wrote snapshot", "OCR record", slow frame processing warnings immediately before crashes).

Screenshots

(See attached screenshot showing the crash dialog appearing while "Setting up Chronicle" is in progress.)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗