Fix WeFax start/stop/SSE reliability

- Replace blocking stdout.read() with select()-based non-blocking reads
  so the decode thread responds to stop within 0.5s
- Make stop() non-blocking by releasing the lock before terminating the
  process and removing the redundant wait()
- Move initial scanning SSE event from start() into the decode thread so
  it fires after the frontend EventSource connects
- Update frontend stop() to give immediate UI feedback before the fetch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-02-24 16:10:34 +00:00
parent b72a2f1092
commit 9745215038
2 changed files with 42 additions and 19 deletions
+7 -3
View File
@@ -205,16 +205,20 @@ var WeFax = (function () {
}
function stop() {
// Immediate UI feedback before waiting for backend response
state.running = false;
updateButtons(false);
setStatus('Stopping...');
disconnectSSE();
fetch('/wefax/stop', { method: 'POST' })
.then(function (r) { return r.json(); })
.then(function () {
state.running = false;
updateButtons(false);
setStatus('Stopped');
disconnectSSE();
loadImages();
})
.catch(function (err) {
setStatus('Stopped');
console.error('WeFax stop error:', err);
});
}