From ad27a76fab884ae1d939aee094ec7414ee174ab7 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Tue, 11 Jun 2024 22:45:00 +0200 Subject: [PATCH] Deregister prosodyctl interval callback when spawn.stdin disappears To avoid running into "write EPIPE" errors. --- CHANGELOG.md | 1 + server/lib/prosody/ctl.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01fc2fd3..90cc318c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ TODO: tag conversejs livechat branch, and replace commit ID in build-converse.js ### Minor changes and fixes * Fix cleanup on channel deletion. +* #416: Deregister prosodyctl interval callback when spawn.stdin disappears. ## 10.0.2 diff --git a/server/lib/prosody/ctl.ts b/server/lib/prosody/ctl.ts index bdadc048..d717027c 100644 --- a/server/lib/prosody/ctl.ts +++ b/server/lib/prosody/ctl.ts @@ -165,6 +165,14 @@ async function prosodyCtl ( options.peertubeHelpers.logger.debug('ProsodyCtl was called in yesMode, writing to standard input.') spawned.stdin.write('\n') }, 10) + spawned.stdin.on('close', () => { + options.peertubeHelpers.logger.debug('ProsodyCtl standard input closed, clearing interval.') + clearInterval(yesModeInterval) + }) + spawned.stdin.on('error', () => { + options.peertubeHelpers.logger.debug('ProsodyCtl standard input errored, clearing interval.') + clearInterval(yesModeInterval) + }) } spawned.stdout.on('data', (data) => { @@ -186,7 +194,6 @@ async function prosodyCtl ( // on 'close' and not 'exit', to be sure everything is done // (else it can cause trouble by cleaning AppImage extract too soon) spawned.on('close', (code) => { - if (yesModeInterval) { clearInterval(yesModeInterval) } resolve({ code: code, stdout: d,