`ce-polish` refuses a concurrent `start` with a context-free error, dropping the holder PID and the `EEXIST` cause

Aperta Adatta ai principianti
#2,085 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend, cli

Direzione di ricerca

Leggi in skills/ce-polish/scripts/live-endpoint.js le righe 903–918 intorno a acquireStartLock e la gestione degli errori in main() intorno alla riga 2835. Riproduci il rifiuto con un PID attivo in state/start.lock, poi aggiorna l’errore affinché includa il PID del titolare e il percorso del lock, e conserva l’EEXIST intercettato come causa. Il lavoro è completato quando la CLI identifica il titolare e l’errore conserva la propria causa.

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

Descrizione

Environment

  • EveryInc/compound-engineering-plugin at commit 122f9f90330df0b54da865e12cbecb81ffd0ae53
  • skills/ce-polish/scripts/live-endpoint.js, acquireStartLock lines 903-918
  • Node.js 24, Windows/macOS/Linux

Summary

A second start for the same root is correctly refused while another live start holds state/start.lock, but the refusal is reported as the bare sentence Another \start` for this root is in progress. The catch block that detects the held lock throws a new Error: the EEXISTit caught (which carries the lock path) is not attached ascause, and the holder PID it has just read from the lock file is not included. main()prints onlyerror.message`, so nothing else reaches the operator.

The refusal itself is correct and documented. With several roots or agents running, the message does not say which process holds the lock, and stop --root does not clear state/start.lock.

Root cause

// skills/ce-polish/scripts/live-endpoint.js:903-918
function acquireStartLock(options) {
  const lockPath = path.join(options.stateDir, "start.lock")
  let lockFd
  try {
    lockFd = fs.openSync(lockPath, "wx", 0o600)
  } catch (error) {
    if (error.code !== "EEXIST") throw error
    const holder = Number(fs.readFileSync(lockPath, "utf8")) || null
    if (holder && processAlive(holder)) throw new Error("Another `start` for this root is in progress")
    ...

The replacement Error keeps neither error nor holder nor lockPath, although all three are available at the throw.

Affected code

skills/ce-polish/scripts/live-endpoint.js, line 911 (the throw inside acquireStartLock).

Reproduction

  1. Create a root with a state/start.lock containing the PID of a live process (this is the state a running start leaves).
  2. Run the documented command against that root:
node skills/ce-polish/scripts/live-endpoint.js start --root <root>

Observed on Node 24.21.0:

$ node skills/ce-polish/scripts/live-endpoint.js start --root <root>
Another `start` for this root is in progress
$ echo $?
1

The caught object is EEXIST: file already exists, open '<root>/state/start.lock' with code, syscall, errno and path; it is not reachable from the thrown error. The thrown error has only stack and message, and its own-property list is ["stack","message"] (no cause). The PID read at line 910 is discarded. A clean run without any instrumentation shows the same stderr and exit code.

A control that changes only line 911 to include the holder and the lock path and to pass { cause: error } prints Another \start` for this root is in progress (holder pid 28648, lock /state/start.lock)and exposes theEEXISTonerror.cause`.

Expected behavior

The refusal should keep its wording but also identify the blocking process, and the caught EEXIST should be chained as cause:

if (holder && processAlive(holder)) {
  throw new Error(
    `Another \`start\` for this root is in progress (holder pid ${holder}, lock ${lockPath})`,
    { cause: error },
  )
}

Actual behavior

The thrown error contains only the generic sentence. The EEXIST details, the lock path and the holder PID are all dropped, and main() at line 2835 prints only error.message, so an operator cannot identify the process that holds the lock.

Suggested fix

Attach the holder and the cause as above. If terse CLI output is preferred, keep the short message but print error.cause (or error.stack) under a debug flag in main(), so the information remains available instead of being discarded at the boundary.

Lingua principale
TypeScript
Stelle
25.6k
Fork
2.1k
Merge medio
3h 57m
PR unite (30g)
170

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 EveryInc/compound-engineering-plugin

Tutte le issue di EveryInc/compound-engineering-plugin

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.