Skip to content

fix(pty): stop logging bogus 'PTY cwd missing' for valid directories#730

Merged
h0x91b merged 1 commit into
mainfrom
fix/dev3-pty-cwd-false-error
Jun 27, 2026
Merged

fix(pty): stop logging bogus 'PTY cwd missing' for valid directories#730
h0x91b merged 1 commit into
mainfrom
fix/dev3-pty-cwd-false-error

Conversation

@h0x91b

@h0x91b h0x91b commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Hi — this is Claude (the AI assistant working on this branch).

Summary

The PTY existence check used Bun.file(session.cwd).exists() to verify a terminal's working directory. But a PTY's cwd is always a directory (worktree / project path / ops work dir), and Bun.file().exists() has file semantics — it returns false for every directory. So ERROR [pty] PTY cwd missing was logged on every spawn for valid dirs, flooding the ERROR log and masking any genuine missing-cwd race. The check never blocked spawning, so terminals worked anyway — it was pure diagnostic noise.

Fix: extract an exported cwdExists(cwd) helper in src/bun/pty-server.ts that uses fs.access (from node:fs/promises), which resolves directories correctly. spawnPty now calls it. Still best-effort and non-blocking — only the existence probe changed; genuinely missing cwds are still logged.

Found while investigating a UI "stuck on loading" incident; this is the one clean, self-contained fix from that investigation.

  • src/bun/pty-server.tscwdExists() helper + use it in spawnPty
  • src/bun/__tests__/pty-server.test.ts — 3 regression tests (existing dir, existing file, nonexistent path)
  • decisions/081-pty-cwd-exists-fs-access.md — rationale
  • change-logs/2026/06/27/fix-pty-cwd-false-error.md

Bun.file(dir).exists() returns false for directories, so spawnPty logged a
bogus 'PTY cwd missing' error for every valid worktree/project terminal dir.
Extract an exported cwdExists() helper backed by fs.access (correct for dirs)
and cover it with regression tests. Non-blocking diagnostic behaviour unchanged.
@h0x91b h0x91b enabled auto-merge (squash) June 27, 2026 16:19
@h0x91b h0x91b merged commit 9276395 into main Jun 27, 2026
4 checks passed
@h0x91b h0x91b deleted the fix/dev3-pty-cwd-false-error branch June 27, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant