terminal-code icon indicating copy to clipboard operation
terminal-code copied to clipboard

--split crashes on Intel Mac (windowCommand missing ELECTRON_RUN_AS_NODE)

Open devtm1123 opened this issue 2 months ago • 9 comments

On an Intel Mac, tode --split right opens a new pane, but the editor never shows up. The window process exits right away.

windowCommand in dist/launch.js runs process.execPath main.js --window <url> without ELECTRON_RUN_AS_NODE=1. So Electron Helper boots full Chromium instead of node, and its GPU child crashes right away. The macOS crash report says EXC_BREAKPOINT (SIGTRAP), "Trace/BPT trap: 5".

export ELECTRON_RUN_AS_NODE=1 in my shell fixes it. Probably only works on arm64 by luck.

tode 0.4.2 darwin-x64, macOS 26.7, MacBookPro16,2, Ghostty 1.3.1

devtm1123 avatar Oct 05 '26 20:10 devtm1123

I can reproduce a similar issue on an Apple Silicon Mac (M5 Pro). Setup

  • macOS: 27.0.1
  • Herdr: 0.9.5
  • Ghostty: 1.3.1
  • Tode: 0.4.3

What happens: When Tode is open inside Herdr, the whole Ghostty terminal becomes extremely laggy: mouse movement, selecting text, and typing are all slow. Closing Tode immediately restores normal performance.

This affects every project. The same workflow works normally on Linux.

tode --timing reports “workbench ready” in about 1.3 seconds, so the slowdown seems to happen during use rather than initial loading.

raa2015 avatar Oct 25 '26 23:10 raa2015

@zenbu-bot look into this

RobPruzan avatar Oct 30 '26 13:10 RobPruzan

--split pane starts Electron Helper without ELECTRON_RUN_AS_NODE; GPU crash on Intel Mac

Problem

tode --split right in Ghostty starts the window process in the new pane without ELECTRON_RUN_AS_NODE=1. On an x86_64 Mac, Electron Helper then boots Chromium instead of node. Its GPU process crashes with EXC_BREAKPOINT (SIGTRAP), and the window process exits with code 133 (128 + SIGTRAP).

Steps to reproduce

  1. On an Intel Mac, install tode 0.4.x and open Ghostty 1.3.x.
  2. Run tode --split right in a folder.
  3. Ghostty opens a new pane and runs <Electron Helper> dist/main.js --window <url> through /bin/sh -c, using Ghostty's environment.
  4. Watch the new pane: no editor appears, and the process exits.
  5. Open ~/Library/Logs/DiagnosticReports/Electron Helper-*.ips: the crash type is EXC_BREAKPOINT, signal SIGTRAP.
  6. Run the same pane command with ELECTRON_RUN_AS_NODE=1 set: the window opens.

Expected

The pane's window process runs Electron Helper as node, connects to the tode daemon, and shows the editor.

Actual

The pane's window process boots Chromium. stderr shows GPU process exited unexpectedly: exit_code=5 several times, then FATAL ... GPU process isn't usable. Goodbye., and the process exits with code 133.

Cause

windowCommand() in src/launch.ts returns [process.execPath, main.js, "--window", url] and sets no environment. Pane.openSplit() passes that command to terminal.split(). Ghostty starts the new pane with its own environment, not the caller's. So the export ELECTRON_RUN_AS_NODE=1 in the bin/tode shim (scripts/dist.sh, scripts/release.sh) does not reach the pane. Without that variable, process.execPath (Electron Helper) starts as a Chromium browser process. Not verified: why the reporter sees no crash on arm64 Macs.

Evidence

Reproduction on main@b049d7c:

https://github.com/user-attachments/assets/f12f2407-0154-41a8-a66b-2acd1d646469

Simulated: This ran on a real Intel Mac (macos-15-intel, x86_64) in real Ghostty. A helper script captures the command from the real Pane.openSplit() (only detect() is stubbed) and runs it with /bin/sh -c, without ELECTRON_RUN_AS_NODE, as a Ghostty pane does. Ghostty's AppleScript split itself was not called. The machine is a CI VM, and its missing GPU may also play a part in the GPU crash.

Reproduced on main@b049d7c by the test test/split-window-env.test.js:

---
  duration_ms: 4.171457
  type: 'test'
  location: '/Users/runner/zb/base/test/split-window-env.test.js:27:1'
  failureType: 'testCodeFailure'
  error: 'split command must set ELECTRON_RUN_AS_NODE=1 before /usr/local/Cellar/node@22/22.23.2_1/bin/node, got ["/usr/local/Cellar/node@22/22.23.2_1/bin/node","/Users/runner/zb/base/dist/main.js","--window","http://127.0.0.1:8080/"]'
  code: 'ERR_ASSERTION'
  name: 'AssertionError'
  expected: true
  actual: false
  operator: '=='
  stack: |-
    TestContext.<anonymous> (/Users/runner/zb/base/test/split-window-env.test.js:39:10)
    async Test.run (node:internal/test_runner/test:1054:7)
    async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)
  ...
1..1
# tests 1
# suites 0
# pass 0
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 342.388123
Extra information
Job 41124456218-1
Handler issue.enhance
Classification bug
Sandbox real Mac on GitHub Actions (macos-15-intel: x64, macOS 15.7.9)
Test command npx tsc -p tsconfig.json > /dev/null; node scripts/write-cjs-boundary.js && node --test test/split-window-env.test.js
Log GitHub Actions run

zenbu-bot[bot] avatar Oct 30 '26 13:10 zenbu-bot[bot]

@zenbu-bot reproduce this on a real Intel Mac, with the crash and the fix shown in Ghostty

RobPruzan avatar Oct 30 '26 15:10 RobPruzan

@zenbu-bot reproduce this on a real Intel Mac, with the crash and the fix shown in Ghostty

RobPruzan avatar Oct 30 '26 16:10 RobPruzan

@zenbu-bot reproduce this on a real Intel Mac, with the crash and the fix shown in Ghostty

RobPruzan avatar Oct 30 '26 17:10 RobPruzan

@zenbu-bot reproduce this on a real Intel Mac, with the crash and the fix shown in Ghostty

RobPruzan avatar Oct 30 '26 18:10 RobPruzan

@zenbu-bot reproduce this on a real Intel Mac, with the crash and the fix shown in Ghostty

RobPruzan avatar Oct 30 '26 19:10 RobPruzan

@zenbu-bot reproduce this on a real Intel Mac, with the crash and the fix shown in Ghostty

RobPruzan avatar Oct 30 '26 20:10 RobPruzan