Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Commit aa00904

Browse files
committed
Remove listeners for specific events in Task class
This change is necessary for Electron 3 to a bug in Node.js 10.2.x which causes the `removeAllListeners` method to no longer remove all listeners for any event name when no argument is passed: nodejs/node#20924 This issue has been fixed in Node.js 10.3.0+ so we will have to remove this workaround when we move to Electron 4.0 to avoid future event handler leaks.
1 parent 4a85f62 commit aa00904

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/task.coffee

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ class Task
8484

8585
# Routes messages from the child to the appropriate event.
8686
handleEvents: ->
87-
@childProcess.removeAllListeners()
87+
@childProcess.removeAllListeners('message')
8888
@childProcess.on 'message', ({event, args}) =>
8989
@emitter.emit(event, args) if @childProcess?
9090

9191
# Catch the errors that happened before task-bootstrap.
9292
if @childProcess.stdout?
93-
@childProcess.stdout.removeAllListeners()
93+
@childProcess.stdout.removeAllListeners('data')
9494
@childProcess.stdout.on 'data', (data) -> console.log data.toString()
9595

9696
if @childProcess.stderr?
97-
@childProcess.stderr.removeAllListeners()
97+
@childProcess.stderr.removeAllListeners('data')
9898
@childProcess.stderr.on 'data', (data) -> console.error data.toString()
9999

100100
# Public: Starts the task.
@@ -147,9 +147,9 @@ class Task
147147
terminate: ->
148148
return false unless @childProcess?
149149

150-
@childProcess.removeAllListeners()
151-
@childProcess.stdout?.removeAllListeners()
152-
@childProcess.stderr?.removeAllListeners()
150+
@childProcess.removeAllListeners('message')
151+
@childProcess.stdout?.removeAllListeners('data')
152+
@childProcess.stderr?.removeAllListeners('data')
153153
@childProcess.kill()
154154
@childProcess = null
155155

0 commit comments

Comments
 (0)