Bug: async work (fetch / cmd.exec) inside mod event handlers is dropped or never resolves in the interactive TUI
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- cli
Línea de trabajo
Comienza con el dispatch de TUI interactiva para los manejadores de eventos run_end y onRunEnd, y luego reproduce el problema usando el mod proporcionado con fetch y cmd.exec. Compara el comportamiento de la TUI interactiva con la ejecución headless de -p; se considera terminado cuando las promesas posteriores al turno se resuelven o rechazan de forma fiable y los subprocesos regresan sin requerir un proceso auxiliar.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug: async work (fetch / cmd.exec) inside mod event handlers is dropped or never resolves in the interactive TUI
Summary
When a mod runs fetch (or cmd.exec) inside an event handler like run_end or onRunEnd, the promise never resolves in the interactive TUI — even though the same call resolves in ~1s standalone. The mod's async work is silently dropped, so post-turn hooks that do network I/O never complete.
Repro
Minimal mod:
export default function (cmd: any) {
cmd.on('run_end', (event) => {
void fetch('https://api.commandcode.ai/provider/v1/chat/completions', {
method: 'POST',
headers: {'Content-Type': 'application/json', Authorization: 'Bearer ' + require('node:fs').readFileSync(require('node:os').homedir() + '/.commandcode/auth.json', 'utf8') /* parse */},
body: JSON.stringify({model: 'moonshotai/Kimi-K2.7-Code-Highspeed', messages: [{role: 'system', content: 'Reply OK'}], max_tokens: 10}),
signal: AbortSignal.timeout(60_000),
})
.then(r => console.error('RESOLVED', r.status))
.catch(e => console.error('FAILED', e.message));
});
}
Expected: RESOLVED 200 within ~2s of the run ending.
Actual: neither RESOLVED nor FAILED ever logs — the promise never settles. Same with cmd.exec({command: 'curl', ...}) inside onRunEnd: the exec starts (a telltale writes) but never returns.
Evidence (from the suggester mod's debug log)
20:31:39.354 run_end fired, scheduling regenerate
20:31:39.385 fetch: attempt 0 start
20:32:00.078 fetch: attempt 0 status=200 ← resolves 21s later, or never in some runs
Timing is inconsistent: sometimes it resolves after ~20s, sometimes never. In the interactive TUI it's far more likely to never resolve than in headless -p.
What I had to do to work around it
Spawn a standalone helper process (a separate node script) from the mod: the mod writes a request file (sync), spawns the helper with child_process.spawn, and the helper does the fetch in a normal process where it works reliably. This is ugly but necessary — in-module async network I/O is not dependable.
Notes
onRunEndis documented as "awaited before the run_end event" — the hook itself runs, but its async body doesn't complete.cmd.execinsideonRunEnd/run_endshows the same behavior (starts, never returns).- This is why the docs' "must-complete work" claim for
onRunEnddoesn't hold for I/O.
Environment
- Command Code 1.15.0, macOS 26 (arm64)
- Mods loaded from
~/.commandcode/mods/(user scope)
Impact
Any mod that does network I/O or subprocess work in a post-turn hook is unreliable. The workaround (helper process) is a significant complexity tax on mod authors.
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 4k
- Forks
- 350
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de CommandCodeAI/command-code
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CommandCodeAI/command-code#855 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
CommandCodeAI/command-code#841 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CommandCodeAI/command-code#655 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CommandCodeAI/command-code#608 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
CommandCodeAI/command-code#893 ·
Todos los issues de CommandCodeAI/command-code
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
qgis/QGIS-Documentation#11275 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
milvus-io/birdwatcher#545 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
area:tools bug good first issue help wanted priority:P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
TaewoooPark/Motifcode#14 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
newrelic-experimental/preflight#793 · 1 comentario ·