microsoft / microsoft/TypeScript

Bad tsserverPath in the unstable/sync API client surfaces as bare "EPIPE: broken pipe, write" instead of naming the executable

Aperta
#63,885 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Possible Improvement
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

Version
  • typescript@7.0.2 (gitHead 2bd066d87f5bafd315be9f40889d0a60b9e58e0b),
    @typescript/typescript-linux-x64@7.0.2
  • Node v22.22.0, Linux x86_64 (Fedora 43)
Repro
import { API } from "typescript/unstable/sync";

const api = new API({ tsserverPath: "/nonexistent/binary" });
api.parseConfigFile("/some/tsconfig.json");
Expected

An error identifying the executable, along the lines of the default path's
Executable not found: <path>, or the channel's own
Unexpected EOF while reading from child process (exited with code N).

Actual
Error: EPIPE: broken pipe, write
    at writeSync (node:fs:922:3)
    at SyncRpcChannel.writeAllBuf (.../dist/api/syncChannel.js:495:27)
    at SyncRpcChannel.writeTuple (.../dist/api/syncChannel.js:314:18)
    at SyncRpcChannel.requestBytesSync (.../dist/api/syncChannel.js:221:14)
    at Client.apiRequest (.../dist/api/sync/client.js:58:37)

The same EPIPE appears for any tsserverPath that is not an API server —
/bin/cat and /bin/sleep both produce it — so the message never distinguishes
"executable missing" from "executable is not a tsgo API server".

Analysis
  • resolveExePath (dist/api/options.js) returns options.tsserverPath
    unchecked: return options.tsserverPath ?? getExePath();. The default branch,
    getExePath (lib/getExePath.js), does fs.existsSync(exe) and throws
    Executable not found: <path> — the explicit-path branch has no such check.
  • SyncRpcChannel.writeAllBuf (dist/api/syncChannel.js) catches only
    EAGAIN/EWOULDBLOCK and rethrows everything else raw. The read side has an
    eofError() helper that reports the child's exitCode/signalCode; the write
    side has no equivalent, so a child that died before the first request produces
    the low-level errno instead.
  • The spawn "error" event (ENOENT) is never observed on the child.

A check in resolveExePath mirroring getExePath's existsSync, plus an
EPIPE branch in writeAllBuf that raises the channel's eofError(), would
cover both shapes.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da resolveExePath in dist/api/options.js e confrontalo con getExePath in lib/getExePath.js, quindi esamina SyncRpcChannel.writeAllBuf ed eofError in dist/api/syncChannel.js. Esegui nuovamente l’esempio fornito di sync API con /nonexistent/binary e un eseguibile che non sia un server; il lavoro è completato quando gli errori identificano l’eseguibile o l’uscita del processo figlio invece di esporre un semplice EPIPE.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
node.js, typescript
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
70/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.