mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
🚱 Prevent stdout/stderr data listener leaks
Old listeners were not cleaned up before new ones were being added causing the following console message: warning: possible EventEmitter memory leak detected. Refs #7033
This commit is contained in:
@@ -100,11 +100,12 @@ class Task
|
||||
@childProcess.removeAllListeners()
|
||||
@childProcess.on 'message', ({event, args}) =>
|
||||
@emit(event, args...) if @childProcess?
|
||||
|
||||
# Catch the errors that happened before task-bootstrap.
|
||||
@childProcess.stdout.on 'data', (data) ->
|
||||
console.log data.toString()
|
||||
@childProcess.stderr.on 'data', (data) ->
|
||||
console.error data.toString()
|
||||
@childProcess.stdout.removeAllListeners()
|
||||
@childProcess.stdout.on 'data', (data) -> console.log data.toString()
|
||||
@childProcess.stderr.removeAllListeners()
|
||||
@childProcess.stderr.on 'data', (data) -> console.error data.toString()
|
||||
|
||||
# Public: Starts the task.
|
||||
#
|
||||
@@ -152,6 +153,8 @@ class Task
|
||||
return unless @childProcess?
|
||||
|
||||
@childProcess.removeAllListeners()
|
||||
@childProcess.stdout.removeAllListeners()
|
||||
@childProcess.stderr.removeAllListeners()
|
||||
@childProcess.kill()
|
||||
@childProcess = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user