Skip to content

Commit 6d76f10

Browse files
committed
fix(console) execute: on(kill) -> once(kill), removeListener
1 parent 0ebdd03 commit 6d76f10

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/server/console.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,15 @@
9999

100100
function execute(socket, command, cwd) {
101101
var isDone,
102-
spawn = spawnify(command, {
102+
spawn = spawnify(command, {
103103
cwd: cwd()
104-
});
104+
}),
105+
106+
kill = function() {
107+
spawn.kill();
108+
};
105109

106-
socket.on('kill', function() {
107-
spawn.kill();
108-
});
110+
socket.once('kill', kill);
109111

110112
spawn.on('error', function(error) {
111113
isDone = true;
@@ -127,6 +129,8 @@
127129
});
128130

129131
spawn.on('close', function() {
132+
socket.removeListener('kill', kill);
133+
130134
if (!isDone);
131135
socket.emit('data', '');
132136
});

0 commit comments

Comments
 (0)