mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
fix: ensure proper cleanup of message listeners on stop
This commit is contained in:
@@ -98,16 +98,18 @@ function init (id: number, filePath: string | string[], options: WatchOpts) {
|
||||
console.log(`watch process ${id} >`, filePath, 'stop')
|
||||
promiseQueue.length = 0
|
||||
watcher.close()
|
||||
process.off('message', onMessage)
|
||||
process.off('exit', stop)
|
||||
}
|
||||
|
||||
function onMessage (message: Message) {
|
||||
if (message.id === id && message.type === 'stop') {
|
||||
stop()
|
||||
process.off('message', onMessage)
|
||||
}
|
||||
}
|
||||
|
||||
process.on('message', onMessage)
|
||||
process.on('exit', stop)
|
||||
}
|
||||
|
||||
process.on('message', (message: Message) => {
|
||||
|
||||
Reference in New Issue
Block a user