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
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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 ↗

3 Comments

resatu · 2 months ago

<img width="792" height="458" alt="Image" src="https://github.com/user-attachments/assets/d416aa9f-d711-41c3-b9df-47be288dc230" />

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #24367

Powered by Codex Action

resatu · 2 months ago

Closing this from my side after local cleanup.

What fixed it locally:

  • Reinstalled Codex Desktop from a fresh DMG.
  • Removed the local Chronicle/Computer Use suppressor LaunchAgent that was continuously killing codex_chronicle, SkyComputerUseClient, and Codex Computer Use.
  • Moved aside a corrupted/oversized local rollout thread, 019e5d4e-19d5-7763-af37-8db9ea0c306e, whose JSONL had grown to about 1.4 GB.
  • Cleared stale desktop/global-state references to that thread.
  • Rotated the large local Codex log DB/state artifacts.

After cleanup, Codex Desktop launches, Chronicle and Computer Use processes start normally, and I no longer see new RangeError: Invalid string length, lineBytes=537MB+, or MCP parse errors in the fresh app logs.

This still looks like a real robustness issue worth guarding against in the app: a single oversized or malformed rollout/MCP response should not be able to crash the Electron main process. But my local installation is unblocked now, so I’m closing this report.