Fix test event leak
This commit is contained in:
parent
91ae3c4a54
commit
706a450fe6
|
@ -221,11 +221,17 @@ export class PeerTubeServer {
|
||||||
|
|
||||||
this.app = fork(join(root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions)
|
this.app = fork(join(root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions)
|
||||||
|
|
||||||
const onExit = function () {
|
const onPeerTubeExit = () => rej(new Error('Process exited'))
|
||||||
return rej(new Error('Process exited'))
|
const onParentExit = () => {
|
||||||
|
if (!this.app || !this.app.pid) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
process.kill(self.app.pid)
|
||||||
|
} catch { /* empty */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
this.app.on('exit', onExit)
|
this.app.on('exit', onPeerTubeExit)
|
||||||
|
process.on('exit', onParentExit)
|
||||||
|
|
||||||
this.app.stdout.on('data', function onStdout (data) {
|
this.app.stdout.on('data', function onStdout (data) {
|
||||||
let dontContinue = false
|
let dontContinue = false
|
||||||
|
@ -254,16 +260,11 @@ export class PeerTubeServer {
|
||||||
if (options.hideLogs === false) {
|
if (options.hideLogs === false) {
|
||||||
console.log(data.toString())
|
console.log(data.toString())
|
||||||
} else {
|
} else {
|
||||||
|
process.removeListener('exit', onParentExit)
|
||||||
self.app.stdout.removeListener('data', onStdout)
|
self.app.stdout.removeListener('data', onStdout)
|
||||||
self.app.removeListener('exit', onExit)
|
self.app.removeListener('exit', onPeerTubeExit)
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('exit', () => {
|
|
||||||
try {
|
|
||||||
process.kill(self.app.pid)
|
|
||||||
} catch { /* empty */ }
|
|
||||||
})
|
|
||||||
|
|
||||||
res()
|
res()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue