Deregister prosodyctl interval callback when spawn.stdin disappears

To avoid running into "write EPIPE" errors.
This commit is contained in:
OPNA2608 2024-06-11 22:45:00 +02:00
parent 79848b7988
commit ad27a76fab
2 changed files with 9 additions and 1 deletions

View File

@ -13,6 +13,7 @@ TODO: tag conversejs livechat branch, and replace commit ID in build-converse.js
### Minor changes and fixes ### Minor changes and fixes
* Fix cleanup on channel deletion. * Fix cleanup on channel deletion.
* #416: Deregister prosodyctl interval callback when spawn.stdin disappears.
## 10.0.2 ## 10.0.2

View File

@ -165,6 +165,14 @@ async function prosodyCtl (
options.peertubeHelpers.logger.debug('ProsodyCtl was called in yesMode, writing to standard input.') options.peertubeHelpers.logger.debug('ProsodyCtl was called in yesMode, writing to standard input.')
spawned.stdin.write('\n') spawned.stdin.write('\n')
}, 10) }, 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) => { spawned.stdout.on('data', (data) => {
@ -186,7 +194,6 @@ async function prosodyCtl (
// on 'close' and not 'exit', to be sure everything is done // on 'close' and not 'exit', to be sure everything is done
// (else it can cause trouble by cleaning AppImage extract too soon) // (else it can cause trouble by cleaning AppImage extract too soon)
spawned.on('close', (code) => { spawned.on('close', (code) => {
if (yesModeInterval) { clearInterval(yesModeInterval) }
resolve({ resolve({
code: code, code: code,
stdout: d, stdout: d,