tree-kill can throw from a signal handler and has no tests

Aperta
#284 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@tylrcc ci sta già lavorando.

Dal 11/11/2026.

  • #290 di @tylrcc — aperta

Valutazione

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

Direzione di ricerca

Start with src/lib/tree-kill/tree-kill.ts and the signal handler in src/bin/nf.ts; the issue identifies the failure paths and expected behavior. Trace how the process tree is collected and traversed, then add the requested two-level process-tree test. Done when taskkill errors are caught, helper PIDs are skipped, children are killed before parents, and the test passes.

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

Descrizione

bug tests
Which package is this bug report for?

@nanoforge-dev/cli

Which command is this bug report for?

other

Issue description

treeKill has a few problems and no tests (read from the code, not run). Related to #104, which added it.

  • On Windows, execSync("taskkill ...") throws inside the Promise executor when taskkill fails (src/lib/tree-kill/tree-kill.ts#L12). The signal listener in src/bin/nf.ts#L16-L19 awaits it without a catch, which gives an unhandled rejection on Ctrl+C.
  • On Linux/macOS, the tree includes the ps/pgrep helpers the function itself spawned (src/lib/tree-kill/tree-kill.ts#L35).
  • killAll kills in descending numeric PID order (Object.keys(tree).reverse(), src/lib/tree-kill/tree-kill.ts#L52). That is only children-first when PIDs never wrapped around.
  • The module uses function declarations, where the team style asks for arrow functions.

Expected: taskkill errors are caught, children are killed before their parents by walking the tree, the helper PIDs are skipped, and a test kills a two-level process tree.

Found during a read-only audit of main at e95b881 (2026-11-11).

Code sample
execSync("taskkill /pid " + pid + " /T /F"); // throws on failure, inside new Promise(...)
resolve();
Versions
  • @nanoforge-dev/cli 3.0.1 (main, e95b881)
  • Node.js 26.7.0
  • Bun 1.3.14 (bundled)
  • Linux
Issue priority

Low (slightly annoying)

I have tested this issue on a development release

No response

Lingua principale
TypeScript
Stelle
2
Fork
2
Merge medio
2g 18h
PR unite (30g)
17

Preparare l'ambiente

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.

Altre issue di NanoForge-dev/CLI

Tutte le issue di NanoForge-dev/CLI

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.