Skip to content

vp hangs when spawned by lefthook (opens /dev/tty) #1396

@spalger

Description

@spalger

Describe the bug

vp commands hang indefinitely when spawned as child processes by lefthook git hooks. The same commands complete in ~1 second when run directly in a terminal.

# Works fine (~1s):
vp run typecheck

# Hangs indefinitely:
git add lefthook.yml && npx lefthook run pre-commit

Both vp run <script> and vp test are affected.

Root cause

lsof on the hanging vp process shows it opens /dev/tty directly (fd 9), bypassing stdin:

COMMAND   PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
vp      11794 spalger    0u   CHR   16,0      0t0  895 /dev/ttys000
vp      11794 spalger    1u   CHR   16,0      0t0  895 /dev/ttys000
vp      11794 spalger    2u   CHR   16,0      0t0  895 /dev/ttys000
vp      11794 spalger    9u   CHR    2,0     0t26  335 /dev/tty

Lefthook allocates pseudo-TTYs for child processes. When vp opens /dev/tty and reads from it, it blocks because there's no input on the pseudo-TTY.

This is partly a lefthook issue too — lefthook gives non-interactive child processes a controlling terminal even though it already treats them as non-interactive (null stdin per evilmartians/lefthook#732). But vp could also handle the case where /dev/tty isn't truly interactive more gracefully, rather than blocking indefinitely.

Workaround

Redirect stdin from /dev/null:

pre-commit:
  commands:
    typecheck:
      run: vp run typecheck </dev/null
    test:
      run: vp test </dev/null

Reproduction

Can't manage to run curl -fsSL https://vite.plus | bash in stackblitz sandboxes...

Steps to reproduce

  • Install lefthook npm install --save-dev lefthook
  • Write lefthook.yml file

lefthook.yml:

pre-commit:
  commands:
    typecheck:
      run: vp run typecheck
  • Run npx lefthook run pre-commit

System Info

VITE+ - The Unified Toolchain for the Web

Environment:
  Version  24.14.1
  Source   lts

Tool Paths:
  node  /Users/spalger/.vite-plus/js_runtime/node/24.14.1/bin/node
  npm   /Users/spalger/.vite-plus/js_runtime/node/24.14.1/bin/npm
  npx   /Users/spalger/.vite-plus/js_runtime/node/24.14.1/bin/npx

vp v0.1.16

Local vite-plus:
  vite-plus  Not found

Tools:
  vite             Not found
  rolldown         Not found
  vitest           Not found
  oxfmt            Not found
  oxlint           Not found
  oxlint-tsgolint  Not found
  tsdown           Not found

Environment:
  Package manager  pnpm v10.33.0
  Node.js          v24.14.1

Used Package Manager

pnpm

Logs

Validations

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions