fix: use res.on('close') to avoid premature kill

This commit is contained in:
aedes
2026-04-20 16:59:38 +03:00
parent 10e8d8df1a
commit ba7130d967

View File

@@ -71,7 +71,9 @@ app.post('/api/chat', (req, res) => {
res.end(); res.end();
}); });
req.on('close', () => { try { proc.kill(); } catch (e) {} }); let finished = false;
proc.on('close', () => { finished = true; });
res.on('close', () => { if (!finished) try { proc.kill(); } catch (e) {} });
}); });
app.listen(8108, () => console.log('sechenov :8108')); app.listen(8108, () => console.log('sechenov :8108'));