Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: reject canceled Piper synthesis before spawning (#9770)
Adam Eivy756fa272ca0d
diff --git a/server/services/voice/tts-piper.js b/server/services/voice/tts-piper.jsindex 1de5802c54..766fa5e7a0 100644--- a/server/services/voice/tts-piper.js+++ b/server/services/voice/tts-piper.js@@ -16,6 +16,8 @@ const PIPER_BIN = join(voiceHome(), 'piper', PIPER_BIN_NAME);const voicePathFor = (id) => join(VOICES_DIR, `${id}.onnx`);export const synthesizePiper = (text, cfg, signal) => {+ if (signal?.aborted) return Promise.reject(new Error('piper synthesis aborted'));+const voiceId = cfg.piper.voice;const voicePath = expandPath(cfg.piper.voicePath || voicePathFor(voiceId));if (!existsSync(voicePath)) {@@ -80,11 +82,6 @@ export const synthesizePiper = (text, cfg, signal) => {}, PIPER_TIMEOUT_MS);if (signal) {- if (signal.aborted) {- killed = true;- try { child.kill('SIGTERM'); } catch { /* already gone */ }- return doReject(new Error('piper synthesis aborted'));- }signal.addEventListener('abort', () => {killed = true;try { child.kill('SIGTERM'); } catch { /* already gone */ }diff --git a/server/services/voice/tts-piper.test.js b/server/services/voice/tts-piper.test.jsindex b55c2e1268..0406ce6c39 100644--- a/server/services/voice/tts-piper.test.js+++ b/server/services/voice/tts-piper.test.js@@ -14,6 +14,11 @@ vi.mock('../../lib/childProcess.js', async (importOriginal) => {return { ...actual, spawn: (...args) => (spawnOverride ? spawnOverride(...args) : actual.spawn(...args)) };});+vi.mock('./config.js', async (importOriginal) => ({+ ...await importOriginal(),+ getVoiceConfig: vi.fn(),+}));+const { synthesizePiper } = await import('./tts-piper.js');const { IS_WIN } = await import('./config.js');@@ -45,6 +50,32 @@ describe('synthesizePiper', () => {await rm(voiceDir, { recursive: true, force: true });});+ it('rejects a pre-aborted request without spawning a child', async () => {+ const controller = new AbortController();+ controller.abort();+ spawnOverride = vi.fn(() => makeFakeChild());++ await expect(synthesizePiper('hello', { piper: { voicePath } }, controller.signal))+ .rejects.toThrow('piper synthesis aborted');+ expect(spawnOverride).not.toHaveBeenCalled();+ });++ it('creates no Piper child when the turn aborts during facade configuration loading', async () => {+ const { getVoiceConfig } = await import('./config.js');+ const { synthesize } = await import('./tts.js');+ const controller = new AbortController();+ let resolveConfig;+ getVoiceConfig.mockReturnValueOnce(new Promise((resolve) => { resolveConfig = resolve; }));+ spawnOverride = vi.fn(() => makeFakeChild());++ const promise = synthesize('hello', { signal: controller.signal });+ controller.abort();+ resolveConfig({ tts: { engine: 'piper', piper: { voicePath } } });++ await expect(promise).rejects.toThrow('piper synthesis aborted');+ expect(spawnOverride).not.toHaveBeenCalled();+ });+// #7006: an unlistened 'error' on child.stdin re-throws in Node and crashes// the whole server process (there is no request lifecycle to catch it).// Piper emits exactly this when it exits (missing shared libs, bad flags)