Skip to content
This repository was archived by the owner on Oct 20, 2020. It is now read-only.

Commit d44c8a9

Browse files
committed
Unsubscribe properly from stream
1 parent 3742a36 commit d44c8a9

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

debug.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,21 @@ function openBrowser(command) {
3535
}
3636

3737
function getDevToolsUrl(command) {
38-
return new Promise((resolve, reject) => {
39-
command.stderr.on('data', data => {
40-
const devToolsUrl = _.flow(
41-
_.find(_.includes('chrome-devtools')),
42-
_.trim
43-
)(data.toString().split(NODE_NIGHTLY_CONFIG.line_ending))
38+
const getUrlFromStdErr = (resolve, data) => {
39+
const devToolsUrl = _.flow(
40+
_.find(_.includes('chrome-devtools')),
41+
_.trim
42+
)(data.toString().split(NODE_NIGHTLY_CONFIG.line_ending))
43+
44+
// unsubscribe from the stream
45+
command.stderr.removeListener('data', getUrlFromStdErr);
4446

45-
// unsubscribe from the stream
46-
command.stderr.on('data', _.noop);
47+
resolve(devToolsUrl);
48+
};
4749

48-
resolve(devToolsUrl);
49-
});
50+
51+
return new Promise((resolve, reject) => {
52+
command.stderr.on('data', _.curry(getUrlFromStdErr)(resolve));
5053
});
5154
}
5255

0 commit comments

Comments
 (0)